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