admin管理员组

文章数量:1026989

Running Python 3.13 (with venv in Windows 11) with PEAK's can adapter and trying to achieve the following:

  • initialize a connection to PEAK's adapter
  • send raw-can messages with cob-id 0x82 (data bytes are non-relevant)
  • wait for 1s
  • send few UDS requests, handle the response, exc.
  • uninitialize the connection
  • quit

Now, the pickle is that when i run the script from cmd it all works fine (I can tell the adapter is sending the messages from another adapter in the same bus), but when i pack the script with pyinstaller to an .exe it partly works; the first messages are not sent, but the uds requests and responses work like a charm. One thing to note is that the raw-can messages use functions from different class as the uds messages (in which the initialization function is belonging to).

I'm importing and using the manufacturer provided code for all the function calls handling the DLL-calls (PCAN_UDS_2013.py, PCAN_ISO_TP_2016.py, PCANBasic.py for those familiar) and all the dll imports seem to complete quite fine when using pyinstaller.

All in all there is only one visible "error"; the failing part of the code "write"-function is returning "Non-initialized"-state, which I could understand if it would function the same way when trying to run it from the command line.

Any pointers, where to look next/how to get more information if some linkage / import / etc. fails during pyinstaller use?

Originally the script was longer with threading and other sort of shenanigans(to minimize the concurrent use of function calls), but I made a minimal version with just few for loops for sending the messages and it resulted with the same type of behavior.

Tried also to minimize namespace pollution, to no avail.

Running Python 3.13 (with venv in Windows 11) with PEAK's can adapter and trying to achieve the following:

  • initialize a connection to PEAK's adapter
  • send raw-can messages with cob-id 0x82 (data bytes are non-relevant)
  • wait for 1s
  • send few UDS requests, handle the response, exc.
  • uninitialize the connection
  • quit

Now, the pickle is that when i run the script from cmd it all works fine (I can tell the adapter is sending the messages from another adapter in the same bus), but when i pack the script with pyinstaller to an .exe it partly works; the first messages are not sent, but the uds requests and responses work like a charm. One thing to note is that the raw-can messages use functions from different class as the uds messages (in which the initialization function is belonging to).

I'm importing and using the manufacturer provided code for all the function calls handling the DLL-calls (PCAN_UDS_2013.py, PCAN_ISO_TP_2016.py, PCANBasic.py for those familiar) and all the dll imports seem to complete quite fine when using pyinstaller.

All in all there is only one visible "error"; the failing part of the code "write"-function is returning "Non-initialized"-state, which I could understand if it would function the same way when trying to run it from the command line.

Any pointers, where to look next/how to get more information if some linkage / import / etc. fails during pyinstaller use?

Originally the script was longer with threading and other sort of shenanigans(to minimize the concurrent use of function calls), but I made a minimal version with just few for loops for sending the messages and it resulted with the same type of behavior.

Tried also to minimize namespace pollution, to no avail.

本文标签: