Skip to content

Conversation

@kirya-dev
Copy link
Contributor

@kirya-dev kirya-dev commented Oct 15, 2024

Points of improvement:

  • Made Close device after Discconnect. Previously, cant reconnect to the device (ERR_DEVICE_IN_USE).
  • Avoid debug log after error log.
  • Raising abnormal exception around connection to the J2534 device.
  • Fix error J2534 Error: CAN_ID_BOTH and CAN_29BIT_ID are the only valid ConnectFlags according J2534 standard.
  • Fix error Parameter pInput must be NULL.
  • Add read_vbatt for j2534 connection
  • Avoid extra access to DLL (log_last_operation)
  • Fix PassThruStartMsgFilter for any interfaces according standard (Sets 0xCCCC_CCCC as a stub. Devices like OpenPoprt and Pulsar are not receiving messages correctly)

@kirya-dev kirya-dev changed the title Impovent with handling J2534 Connection Improvement with processing J2534 Connection Oct 15, 2024
# Set up a J2534 interface using the DLL provided
self.interface = J2534(windll=windll, rxid=rxid, txid=txid, txFlags=txFlags)
try:
self.interface = J2534(windll=windll, rxid=rxid, txid=txid, txFlags=txFlags)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You changed an exception for another. What is the purpose?
The new exception doesn't say what was looked for, can you add it?

Copy link
Contributor Author

@kirya-dev kirya-dev Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly FileNotFoundException controls it. No more information about inaccessible dll file in exception message.
In some times error message(depends locale) are different and we should control these.
In future we need create common udsoncan exceptions for common behaviour when dll or device inaccessible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we should controls in annotations which exceptions can be raised this library. We have one type RuntimeException for all situations… more stable application when it handles much more exception

@pylessard
Copy link
Owner

Thank you for this. I added 2 comments.
Will merge as soon as I get your feedback and CI is green (will enable it for this PR soon)

# Open the interface (connect to the DLL)
self.result, self.devID = self.interface.PassThruOpen()
self.log_last_operation("PassThruOpen", with_raise=True)
except WindowsError as e:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this new exception causes CI to fail because CI runs on Linux and this is unknown.
We would probably need a more complex config that sets the OS to win32 when analyzing this file. I think this is doable with a .mypy.ini

result = dllPassThruGetLastError(pErrorDescription)

return Error_ID(hex(result)), str(pErrorDescription.value)
return Error_ID(hex(result)), pErrorDescription.value.decode()
Copy link
Contributor Author

@kirya-dev kirya-dev Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previosly returns byte object like this b'Device is not opened'.
Now returns string Device is not opened.

@pylessard
Copy link
Owner

Right now my PC is out of order. Will check to make CI happy next week

@kirya-dev
Copy link
Contributor Author

kirya-dev commented Nov 15, 2024

I dont know why. Devices like OpenPort and Pulsar are not receiving messages correctly when no set RxStatus & ExtraDataindex stub value 0xCCCC_CCCC.

@pylessard
Copy link
Owner

I can't help. I never used J2534 :(

@kirya-dev
Copy link
Contributor Author

I think it is some legacy.

@pylessard
Copy link
Owner

Do you plan other modifications?

@kirya-dev
Copy link
Contributor Author

Do you plan other modifications?

I work with this software every day on different devices and find different bugs 🐞.
At the moment, the udsoncan library is working quite stable.

@pylessard
Copy link
Owner

Can you apply this patch to your PR? That will make static analysis happy.
The CI machine up and running

ci.patch

@kirya-dev
Copy link
Contributor Author

Hmm. Container ubuntu:20.04 not same win32 😁

@kirya-dev
Copy link
Contributor Author

Definition of WindowsError in builtins.pyi

if sys.platform == "win32":
    WindowsError = OSError

I just replaced the exception type.

@pylessard
Copy link
Owner

Yeah. Will do a cleaner fix later. I think I can force mypy to assume windows through a mypy.ini

@pylessard pylessard merged commit a4b66db into pylessard:master Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants