RP1210 API : How to get timestamp for the TX messages?

RP1210 Development Package and RP1210 Connectivity to PEAK CAN Interfaces
Post Reply
RajeshG
Posts: 2
Joined: Tue 6. Feb 2024, 14:42

RP1210 API : How to get timestamp for the TX messages?

Post by RajeshG » Tue 6. Feb 2024, 15:04

Hello,

I am able to send and receive J1939 messages using RP1210 API, and my goal is to capture the TX and Rx messages and make log out of it for analyzing. For the same I need timestamp of each message, I am able to get the time stamp of the Rx message, likewise, do we have any way to get the time stamp of the TX message as well? If yes, can you, please tell me how.

Device : PCAN-SUB

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

Re: How to get timestamp for the TX messages

Post by K.Wagner » Tue 6. Feb 2024, 15:29

Hello,

if you want to get the timestamp of transmitted messages, you need to activate the RP1210 command "Set Echo Transmitted Messages". This causes all sent messages from your application to be echoed, this is, sent messages are read again over the function RP1210_ReadMessage. Those echo messages have then a timestamp indicating when they appeared on the CAN bus.

Please check the PCAN-RP1210 documentation (functions RP1210_ReadMessages, RP1210_SendCommand) or the official RP1210 recommended practices for more information on ECHO messages.
Best regards,
Keneth

RajeshG
Posts: 2
Joined: Tue 6. Feb 2024, 14:42

Re: How to get timestamp for the TX messages

Post by RajeshG » Fri 9. Feb 2024, 07:56

Hello,

Thanks for the response and solution. I am able to get the time stamp now.


But I am getting the error code 142 i,e HARDWARE_NOT_RESPONDING while I am trying to transmit the message after successful connection.
I have tested it in two scenarios.

Scenario -1
1.Client connect - No error and got client ID -1
2.Client command to Set All Filter States to Pass - No errors
3.message transmit - error code -142 ERR_HARDWARE_NOT_RESPONDING
in the above scenario message transmission failed.

Scenario-2
1.Client connect - No error and got client ID -1
2.Client command to Set All Filter States to Pass - No errors
3.delay for 1 sec
3.message transmit - error code -0 No errors
in the above scenario message transmission is successful.

so, in the scenario where i tried to transmit the message immediately after connection command is failed. but the same is passed if i give the delay.

my question is like are we supposed to wait for some time after connecting or is it due to any other issue. please help me with this.

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

Re: How to get timestamp for the TX messages

Post by K.Wagner » Fri 9. Feb 2024, 09:22

Hello,

sorry, but we cannot reproduce the problem you describe. If we just make a connection and send, for instance a BAM, direct after it, it just works. This is the code we are using:

Code: Select all

int i = RP1210_ClientConnect(NULL, 1, "J1939", 0, 0, false);
if (i >= 1 && i <= 127)
{
    short ret = RP1210_SendCommand(RPCMD_SET_ALL_FILTERS_STATES_TO_PASS, i, NULL, 0);
    if (ret == NO_ERRORS)
    {
        char msg[10];
	USHORT ret;
			
	msg[0] = 0;
	msg[1] = 0;
	msg[2] = 0;
	msg[3] = 0x80;
	msg[4] = 239;
	msg[5] = 240;
	msg[6] = 1;
	msg[7] = 2;
	msg[8] = 3;
	msg[9] = 4;
	ret = RP1210_SendMessage(i, msg, 10, 0, 1);
	if (ret == NO_ERRORS)
	    MessageBox("All SEND", "OK");
    }
}
Using this code we got a "NO_ERRORS" as result of writing the message and we also get this transmitted:
Transmitted.JPG
Transmitted.JPG (47.37 KiB) Viewed 5792 times
Note that the code ERR_HARDWARE_NOT_RESPONDING should only be retrieved, when your device is somehow disconnected (its internal hardware handle becomes 0). Also note that you need to claim an address in order to send large J1939 messages. Without an address claimed you should only be able to send short messages (those that fix into a single CAN frame).
Best regards,
Keneth

Post Reply