Hello,
I'm new to the Peak RP1210 API. I'm trying to use Python to call the API DLLs and using the following link as a reference:
https://github.com/bryan-hunt/rp1210.py
However, whenever I try to connect to a client, I get the error code 134 (ERR_INVALID_DEVICE).
Here is my code snippet:
CANTYPE=bytes("CAN:Baud=250",'ascii')
ClientId=NewCon.ClientConnect(2, CANTYPE,0, 0)
I have renamed my Device ID in PEAK-HARDWARE settings in the control panel to 2. (I've also tried a few other IDs, but looks like this is the wrong thing to do).
Can you please help me understand where I'm going wrong?
Thanks
RP1210 API ClientConnect
Re: RP1210 API ClientConnect
Hello,
please note first, that the file you are using for load the API is quate old and is not finished. I nevertheless got the file and gave it a try and I was able to initialize the channel. See picture:
Please make sure you have registered your hardware, and that this is attached to your PC, as specified in the documentation. This is done via PEAK-Hardware apple (control panel, under network section)
Note that the RP1210.py file is always selecting the first RP1210 implementation it finds, so if you have more than one RP1210 implementation in your PC, you may be trying to connect something inexistent.
please note first, that the file you are using for load the API is quate old and is not finished. I nevertheless got the file and gave it a try and I was able to initialize the channel. See picture:
Please make sure you have registered your hardware, and that this is attached to your PC, as specified in the documentation. This is done via PEAK-Hardware apple (control panel, under network section)
Note that the RP1210.py file is always selecting the first RP1210 implementation it finds, so if you have more than one RP1210 implementation in your PC, you may be trying to connect something inexistent.
Best regards,
Keneth
Keneth
Re: RP1210 API ClientConnect
Hello Keneth,
Thank you for the quick response. Using your suggestion, I fixed my Device Id and it started working. I have a couple of additional questions:
Rohinish
Thank you for the quick response. Using your suggestion, I fixed my Device Id and it started working. I have a couple of additional questions:
- I am now able to read the CAN data after making a small change in the RP1210 file. However, as I read it, looks like I'm reading the messages from the start of day, instead of just listening to the latest message. E.g., I sent a 100 messages with 1 ID, sent another 100 with another ID, and then I stop sending any messages. When I try to read the messages now, I get the first 100, then I get the next 100 and then I start getting empty buffer. I tried to flush the Rx/Tx queue after every read, but to no effect. Here is my code:
Code: Select all
[readMessage,messageLen]=NewCon.ReadMessage(ClientId, 1) output=NewCon.SendCommand(ClientId, RPCMD_FLUSH_TX_RX_BUFFERS, None, 0)[/i] The output value is NO_ERRORS.
- Can you please point me to any newer files for the RP1210 implementation? I started using these as a guide, and edited them based on the RP1210 documentation.
Rohinish
Last edited by K.Wagner on Mon 23. Nov 2020, 08:26, edited 1 time in total.
Reason: Code formatting for better reading
Reason: Code formatting for better reading
Re: RP1210 API ClientConnect
Hi,
I was able to resolve the issue by using the Set Message Receive Command.
However, I would like to understand why the Flush Tx/Rx buffer command didn't work the same way as the Set Message Receive Command. Just going by the documentation, both are being used to clear the queue.
Thank you
Rohinish
I was able to resolve the issue by using the Set Message Receive Command.
However, I would like to understand why the Flush Tx/Rx buffer command didn't work the same way as the Set Message Receive Command. Just going by the documentation, both are being used to clear the queue.
Thank you
Rohinish
Re: RP1210 API ClientConnect
Hello,
I think, you need to make a review about CAN. Remember the reception queue is a FIFO, so first in first out. If you has old messages that haven't been read yet, then you get first those.
Please note, we don't provide python headers / wrappers for our RP1210 API. Only a C++ header is part of our RP1210 package. You can try to port this from C++ to Python.
Note that official RP1210 documentation can be acquired by TMC. PEAK doesn't provide this.
Best regards,
Keneth
Keneth
Re: RP1210 API ClientConnect
Hello
I am also having a connection issue using python.
I am using RP1210 python package.
Looks like the client ID comes back as 0xFFFF. Then it get translated to 0. Then every time clientID gets referenced it gives ERR_INVALID_CLIENT_ID
Any help would be appreciated.
This is the command
My PCAN-USB Pro FD is ID: 2
But it also shows Device ID: 0h
DEVICE_ID = 2
api = RP1210.RP1210API(API_NAME)
clientID = api.ClientConnect(DEVICE_ID)
This is the result I get.
Available API names: ['PEAKRP32']
The connected adapter conforms to the RP1210C standard: True
Successfully connected and received code: 0 (NO_ERRORS)
ReadVersionDirect DLL Version: .
ReadVersionDirect API Version: 4.0
ReadDetailedVersionDirect DLL Version:
ReadDetailedVersionDirect API Version:
Hardware status bytes translate to: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
-------------- Reading message start ----------------
Command sent. Return code: 129 (ERR_INVALID_CLIENT_ID)
Command sent. Return code: 129 (ERR_INVALID_CLIENT_ID)
Command sent. Return code: 129 (ERR_INVALID_CLIENT_ID)
-------------- Reading message end ----------------
-------------- Sending message start ----------------
Failure. Message: b'\xff\xff\xff\xff\x8f\xff\xff\xff' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
Failure. Message: b'\x00\x00\xbe\xef\xca\xfe' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
Failure. Message: b'\x01\x00\xbe\x8f\xca\xfe' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
Failure. Message: b'`' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
Failure. Message: b'\x00' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
-------------- Sending message end ----------------
Adapter failed to disconnect: ERR_INVALID_CLIENT_ID
I am also having a connection issue using python.
I am using RP1210 python package.
Looks like the client ID comes back as 0xFFFF. Then it get translated to 0. Then every time clientID gets referenced it gives ERR_INVALID_CLIENT_ID
Any help would be appreciated.
This is the command
My PCAN-USB Pro FD is ID: 2
But it also shows Device ID: 0h
DEVICE_ID = 2
api = RP1210.RP1210API(API_NAME)
clientID = api.ClientConnect(DEVICE_ID)
This is the result I get.
Available API names: ['PEAKRP32']
The connected adapter conforms to the RP1210C standard: True
Successfully connected and received code: 0 (NO_ERRORS)
ReadVersionDirect DLL Version: .
ReadVersionDirect API Version: 4.0
ReadDetailedVersionDirect DLL Version:
ReadDetailedVersionDirect API Version:
Hardware status bytes translate to: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
-------------- Reading message start ----------------
Command sent. Return code: 129 (ERR_INVALID_CLIENT_ID)
Command sent. Return code: 129 (ERR_INVALID_CLIENT_ID)
Command sent. Return code: 129 (ERR_INVALID_CLIENT_ID)
-------------- Reading message end ----------------
-------------- Sending message start ----------------
Failure. Message: b'\xff\xff\xff\xff\x8f\xff\xff\xff' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
Failure. Message: b'\x00\x00\xbe\xef\xca\xfe' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
Failure. Message: b'\x01\x00\xbe\x8f\xca\xfe' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
Failure. Message: b'`' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
Failure. Message: b'\x00' , Message sending status: 129 , Error message: ERR_INVALID_CLIENT_ID
-------------- Sending message end ----------------
Adapter failed to disconnect: ERR_INVALID_CLIENT_ID
Re: RP1210 API ClientConnect
Hello,
Thanks for your understanding.
Please note that we do not offer any python unit to use with RP1210. We do not know that package and cannot say why it is not working.
RP1210_ClientConnect must return with a value between 0 and 127, otherwise you cannot use that value with other functions.
Thanks for your understanding.
Best regards,
Keneth
Keneth