Erreur Code

High-speed USB 2.0 to CAN/LIN Interface
Post Reply
MOUHOUBI
Posts: 11
Joined: Wed 15. Jul 2020, 16:58

Erreur Code

Post by MOUHOUBI » Thu 16. Jul 2020, 01:45

Hello,

I tried this python code to read a message, this example I found it on this forum but I have this error message:

Code: Select all

# The Plug & Play Channel (PCAN-USB) is initialized
#
objPCAN = PCANBasic()
result = objPCAN.Initialize(PCAN_USBBUS1, PCAN_BAUD_500K)
if result != PCAN_ERROR_OK:
    # An error occurred, get a text describing the error and show it
    #
    result = objPCAN.GetErrorText(result)
    print (result[1])
else:
    print ("PCAN-USB (Ch-1) was initialized")

readResult = PCAN_ERROR_OK,
while (readResult[0] & PCAN_ERROR_QRCVEMPTY) != PCAN_ERROR_QRCVEMPTY:
    # Check the receive queue for new messages
    #
    readResult = objPCAN.Read(PCAN_USBBUS1)
    if readResult[0] != PCAN_ERROR_QRCVEMPTY:
        # Process the received message
        #
        print ("A message was received")
        ProcessMessage(result[1],result[2]) # Possible processing function, ProcessMessage(msg,timestamp)
    else:
        # An error occurred, get a text describing the error and show it
        #
        result = objPCAN.GetErrorText(readResult[0])
        print (result[1])
        HandleReadError(readResult[0]) # Possible errors handling function, HandleError(function_result)

# The USB Channel is released
#
result = objPCAN.Uninitialize(PCAN_USBBUS1)
if result != PCAN_ERROR_OK:
    # An error occurred, get a text describing the error and show it
    #
    result = objPCAN.GetErrorText(result)
    print (result[1])
else:
    print ("PCAN-USB (Ch-1) was released")

Code: Select all

Traceback (most recent call last):
  File "D:/Temp/pcan-basic/PCAN-Basic API/Samples/Python/essai2.py", line 71, in <module>
    objPCAN = PCANBasic()
  File "D:/Temp/pcan-basic/PCAN-Basic API/Samples/Python\PCANBasic.py", line 375, in __init__
    self.__m_dllBasic = windll.LoadLibrary("PCANBasic")
  File "D:\Softs\lib\ctypes\__init__.py", line 451, in LoadLibrary
    return self._dlltype(name)
  File "D:\Softs\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'PCANBasic' (or one of its dependencies). Try using the full path with constructor syntax.


from what I understand he did not find the path to the PCANBasic library while I even added his path to PATH, how to do ?

thank you
Last edited by K.Wagner on Thu 16. Jul 2020, 08:23, edited 2 times in total.
Reason: Code formatting for better reading

K.Wagner
Software Development
Software Development
Posts: 832
Joined: Wed 22. Sep 2010, 13:36

Re: Erreur Code

Post by K.Wagner » Thu 16. Jul 2020, 08:54

Hello,

Python cannot find the library (PCANBasic.dll). Please make sure that you have the PCAN-Basic libraries in a place where python can find them. Normally (and best for beginners) is to use our PEAK-Drivers Setup to install the DLLs. Start the setup and install the feature "PCAN-Basic API"

Note that you already was instructed to do so in the other post from you, send and receive frame pyhton.
Best regards,
Keneth

MOUHOUBI
Posts: 11
Joined: Wed 15. Jul 2020, 16:58

Re: Erreur Code

Post by MOUHOUBI » Thu 16. Jul 2020, 09:55

i did everything you told me but i still have the same problem !!

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1316
Joined: Fri 10. Sep 2010, 19:34

Re: Erreur Code

Post by U.Wilhelm » Thu 16. Jul 2020, 10:44

That does not give us any information that we could use to help you
i did everything you told me but i still have the same problem !!
post what exact is the problem - also do not start double post or we will remove all of them.
Also be sure that you have follow the instruction Keneth told you - it looks you did not. Check if you have any old DLLs anywhere on the PC - keep it clean!
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

Post Reply