Page 1 of 1

Erreur Code

Posted: Thu 16. Jul 2020, 01:45
by MOUHOUBI
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

Re: Erreur Code

Posted: Thu 16. Jul 2020, 08:54
by K.Wagner
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.

Re: Erreur Code

Posted: Thu 16. Jul 2020, 09:55
by MOUHOUBI
i did everything you told me but i still have the same problem !!

Re: Erreur Code

Posted: Thu 16. Jul 2020, 10:44
by PEAK-Support
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!