RP1210 API ClientConnect

RP1210 Development Package and RP1210 Connectivity to PEAK CAN Interfaces
Post Reply
Rohinish
Posts: 3
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: 767
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 331 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 331 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: 3
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: 3
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: 767
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

Post Reply