RP1210 API ClientConnect

RP1210 Development Package and RP1210 Connectivity to PEAK CAN Interfaces
Post Reply
Rohinish
Posts: 7
Joined: Thu 19. Nov 2020, 06:33

RP1210 API ClientConnect

Post by Rohinish » Thu 19. Nov 2020, 06:39

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

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

Re: RP1210 API ClientConnect

Post by K.Wagner » Thu 19. Nov 2020, 09:15

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:
Successful call to ClientConnect
Successful call to ClientConnect
RP1210.PNG (20.95 KiB) Viewed 8738 times

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)
PEAK-Hardware control panel applet
PEAK-Hardware control panel applet
PeakCpl.PNG (38.53 KiB) Viewed 8738 times
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

Rohinish
Posts: 7
Joined: Thu 19. Nov 2020, 06:33

Re: RP1210 API ClientConnect

Post by Rohinish » Fri 20. Nov 2020, 01:33

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:
  1. 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. 
  2. 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.
Thank you
Rohinish
Last edited by K.Wagner on Mon 23. Nov 2020, 08:26, edited 1 time in total.
Reason: Code formatting for better reading

Rohinish
Posts: 7
Joined: Thu 19. Nov 2020, 06:33

Re: RP1210 API ClientConnect

Post by Rohinish » Fri 20. Nov 2020, 04:58

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

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

Re: RP1210 API ClientConnect

Post by K.Wagner » Mon 23. Nov 2020, 11:43

Hello,
Rohinish wrote:
Fri 20. Nov 2020, 01:33
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
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.
Rohinish wrote:
Fri 20. Nov 2020, 01:33
Can you please point me to any newer files for the RP1210 implementation?
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.
Rohinish wrote:
Fri 20. Nov 2020, 04:58
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.
Note that official RP1210 documentation can be acquired by TMC. PEAK doesn't provide this.
Best regards,
Keneth

jvollmer
Posts: 1
Joined: Thu 5. Jan 2023, 15:45

Re: RP1210 API ClientConnect

Post by jvollmer » Thu 5. Jan 2023, 16:00

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

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

Re: RP1210 API ClientConnect

Post by K.Wagner » Thu 5. Jan 2023, 16:30

Hello,
jvollmer wrote:
Thu 5. Jan 2023, 16:00
I am using RP1210 python package.
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.
jvollmer wrote:
Thu 5. Jan 2023, 16:00
Then it get translated to 0. Then every time clientID gets referenced it gives ERR_INVALID_CLIENT_ID
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

Post Reply