I have a PLIN hardware use I want to use as a Master and a pcb used as Slave.
I'm trying to use the APIs to send a diagnostic frame and also receive the response from the slave.
I made the following steps:
Checking the HW available. [using LIN_GetAvailableHardware]
Client registration. [using LIN_RegisterClient]
Client connection. [using LIN_ConnectClient]
Check the LIN bus. (Active) [using LIN_GetStatus]
Schedule a SlaveResponse slot with FrameId = 0x3D [using LIN_SetSchedule]
Start the schedule slot. [using LIN_StartSchedule]
Write the message. -> Working, checked on the slave side. [using LIN_write]
But when I'm trying to read the response I never receive the correct response and usually I receive CC values.. [using LIN_read]
What I'm doing wrong?
Reason: Moved topic to appropiate sub-forum
please note that LIN_Read() will return the protected frame identifier, and not the LIN frame ID. See LIN spec. for more details on how to convert protected ID to LIN frame ID (Example: LIN_frame_id = RcvMessage.FrameId & 0x3F)
Please report back to me , if this was the issue at hand.
After I succesfully manage to Register->Connect->Configure a client and the bus is active..
What should I do next in order to be able to receive a diagnostic response?
What I did:
1. Schedule a Slave response Slot.
2. Start the Schedule Slot.
3. Send diagnostic frame.
4. Read the diagnostic frame. [the response is send by the Slave but I don't receive anything when using LIN_read]
How is the correct way to define a schedule slot used as Slave Response?
pSchedule.FrameId[0..7] set to 0?
a diagnostic request on LIN is initiate by a 0x3C master requests (publisher), followed by one or more 0x3D slave response frames (subscriber). So the first response will tell you if it is a single frame or a first frame for additional consecutive frames (ISO-TP or UDS on LIN). So the internal scheduler will make no sense for LIN Diagnostic frames, it will be better to use the LIN_Write command to send out the needed frames with the timing given by the ldf for diag frames. Example:
Code: Select all
// Send 0x3C publisher frame: RDBI for Node 0x02 DID 0x1077 myTXmsg.FrameId = 0x3C; //protected ID! myTXmsg.Length = 8; myTXmsg.Direction = Peak.Lin.TLINDirection.dirPublisher; myTXmsg.ChecksumType = Peak.Lin.TLINChecksumType.cstClassic; myTXmsg.Data = new byte; myTXmsg.Data = 0x02; myTXmsg.Data = 0x03; myTXmsg.Data = 0x22; myTXmsg.Data = 0x10; myTXmsg.Data = 0x77; myTXmsg.Data = 0xFF; myTXmsg.Data = 0xFF; myTXmsg.Data = 0xFF; if (my_hClient != 0) my_LINErr = Peak.Lin.PLinApi.Write(my_hClient, my_hHw1, ref myTXmsg);
Code: Select all
// Send 0x3D subscriber myTXmsg.FrameId = 0x7D; //protected ID! myTXmsg.Length = 8; myTXmsg.Direction = Peak.Lin.TLINDirection.dirSubscriber; myTXmsg.ChecksumType = Peak.Lin.TLINChecksumType.cstClassic; if (my_hClient != 0) my_LINErr = Peak.Lin.PLinApi.Write(my_hClient, my_hHw1, ref myTXmsg);