EDIT: Looks like it's only a problem on FrameID 0..7. Other IDs seem to produce correct lengths. I also removed the TLNFrameEntry code.
I am having difficulty with the LIN API. Steps I am using to send a LIN message:
1) Initialize (register, connect)
2) Iterate TLINFrameEntry and initialize correct lengths:
frmData.frameId = i
LIN_GetFrameEntry
frmData.ChecksumType = cstClassic;
frmData.Direction = dirPublisher;
-- really don't know what I'm doing with flags...
frmData.Flags = FRAME_FLAG_RESPONSE_ENABLE | FRAME_FLAG_SINGLE_SHOT;
frmData.Length = xxx;
LIN_SetFrameEntry
3) Create a msg:
TLINMsg msg;
TLINRcvMsg msgrx;
memset(&msg,0,sizeof(msg));
msg.Checksum = 0;
msg.ChecksumType = cstClassic;
msg.Direction = dirPublisher;
msg.FrameId = i;
msg.Data[0] = 1;
msg.Data[1] = 2;
msg.Length = xxx;
...
msg->FrameId |= parity<<6;
LIN_Write (device->client,device->handle,msg);
The result when captured by scope is a message (3 bytes long) that contains:
1) Break (edit - correction: FRAME)
2) Sync
3) protected ID/frame ID (with parity)
NOTE: Data and checksum are missing.
All return values are checked and are OK.
I'm new to LIN so I pretty much have no idea what I'm doing so your support will be helpful.
Trouble with LIN API
Trouble with LIN API
Last edited by brfoster on Mon 4. Feb 2013, 22:49, edited 2 times in total.
Re: Trouble with LIN API
Oops - there's also a call to LIN_CalculateChecksum(msg) during the write process.
And the device is configured as a master.
rc = LIN_InitializeHardware (device->client, device->handle, modMaster, device->config.baud);
It doesn't seem to matter which flags I set too. I've tried a few combinations.
It appears that the frame data is redundant/not used when the LIN_Write API is used. This is my reading from the PLIN API docs.
Verified using HWStatus that it is configured as a Master.
PLIn View (sample app) does work as expected using the same config (as far as I can tell).
---
When configured for 8 bytes, write each value from 0 to 64 (as a test)...
Message ID 0 through 7 don't push the data. Is this some magic LIN stuff that I'm not aware of? I was trying to replicate signalling I captured from the 'good' case.
And the device is configured as a master.
rc = LIN_InitializeHardware (device->client, device->handle, modMaster, device->config.baud);
It doesn't seem to matter which flags I set too. I've tried a few combinations.
It appears that the frame data is redundant/not used when the LIN_Write API is used. This is my reading from the PLIN API docs.
Verified using HWStatus that it is configured as a Master.
PLIn View (sample app) does work as expected using the same config (as far as I can tell).
---
When configured for 8 bytes, write each value from 0 to 64 (as a test)...
Message ID 0 through 7 don't push the data. Is this some magic LIN stuff that I'm not aware of? I was trying to replicate signalling I captured from the 'good' case.
Re: Trouble with LIN API
Hello brfoster,
Please start reading the documentation. The file "PLIN API Documentation" (file: PLIN_enu.chm) contains a section dedicated to get familiarized with standard procedures within the PLIN API LIN as programming a LIN Master:
If you don't know what you are doing it will difficult for us to help you with it. The PLIN-API lets you communicate using the LIN protocol, but you have to get familiarized with the LIN protocol first.brfoster wrote:I'm new to LIN so I pretty much have no idea what I'm doing so your support will be helpful.
If I'm understanding well, you only want to program a LIN Master, for single messages writing from your application to the LIN network. The easy way is to use the LIN_Write function. The Frame entries are used to configure the LIN Table of a LIN Master/Slave. A LIN Table determines the way how the hardware behaves according to how it was initialized. For a Master, it represents the information used when its schedule is active, for the slave represents the behavior when a LIN Master sends a header to it.brfoster wrote:2) Iterate TLINFrameEntry and initialize correct lengths:
frmData.frameId = i
LIN_GetFrameEntry
frmData.ChecksumType = cstClassic;
frmData.Direction = dirPublisher;
-- really don't know what I'm doing with flags...
frmData.Flags = FRAME_FLAG_RESPONSE_ENABLE | FRAME_FLAG_SINGLE_SHOT;
frmData.Length = xxx;
LIN_SetFrameEntry
Use the function LIN_GetPID (Get parity ID) in order to determine the parity bits of the ID.brfoster wrote:msg->FrameId |= parity<<6;
LIN_Write (device->client,device->handle,msg);
brfoster wrote:It doesn't seem to matter which flags I set too. I've tried a few combinations.
there are flags that only works on slaves ... and you are programming a Master.brfoster wrote:frmData.Flags = FRAME_FLAG_RESPONSE_ENABLE | FRAME_FLAG_SINGLE_SHOT;
Please start reading the documentation. The file "PLIN API Documentation" (file: PLIN_enu.chm) contains a section dedicated to get familiarized with standard procedures within the PLIN API LIN as programming a LIN Master:
Best regards,
Keneth
Keneth