Trouble with LIN API

The free LIN software API (Application Programming Interface) for Windows® (only for usage with the PCAN-USB Pro CAN/LIN interface)
Post Reply
brfoster
Posts: 2
Joined: Mon 4. Feb 2013, 18:51

Trouble with LIN API

Post by brfoster » Mon 4. Feb 2013, 19:01

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.
Last edited by brfoster on Mon 4. Feb 2013, 22:49, edited 2 times in total.

brfoster
Posts: 2
Joined: Mon 4. Feb 2013, 18:51

Re: Trouble with LIN API

Post by brfoster » Mon 4. Feb 2013, 19:04

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.

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

Re: Trouble with LIN API

Post by K.Wagner » Tue 5. Feb 2013, 09:07

Hello brfoster,
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 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: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
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:msg->FrameId |= parity<<6;
LIN_Write (device->client,device->handle,msg);
Use the function LIN_GetPID (Get parity ID) in order to determine the parity bits of the ID.
brfoster wrote:It doesn't seem to matter which flags I set too. I've tried a few combinations.
brfoster wrote:frmData.Flags = FRAME_FLAG_RESPONSE_ENABLE | FRAME_FLAG_SINGLE_SHOT;
there are flags that only works on slaves ... and you are programming a Master.

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:
Getting Started - PLIN API Documentation
Getting Started - PLIN API Documentation
Lin Help.jpg (224.27 KiB) Viewed 5622 times
Best regards,
Keneth

Post Reply