CAN BUS vNet driver

47 views
Skip to first unread message

Darren Tastic

unread,
Mar 7, 2016, 1:51:50 AM3/7/16
to souliss
Hi all

I am in the process of writing a CAN BUS vNet driver, and could use some advice on how to do so.

CAN has some limitations - the maximum payload length is only 8 bytes. Is an 8-byte payload going to be OK, or will I need to write a layer over the bus to split and re-assemble longer frames?  I can't get a sense of how large frames are from the source code.  (If I need to, any pointers to an easy way to do this?)

It is a broadcast medium, so has no inbuilt notion of addresses.  Each CAN frame contains either an 11-bit or 29-bit "message ID", this is supposed to be used to indicate message priority but we can use it for addressing.

uint8_t vNet_Send_M6(uint16_t addr, oFrame *frame, uint8_t len)

I'm wondering, what is the intention of the 'len' argument?  Since there is already frame.payload_len and frame.header_len inside the oFrame struct.

uint8_t vNet_RetrieveData_M6(uint8_t *data)

Again, I got a bit lost following *data up the call stack; is the intention that this contains the whole vNet frame as per the docs, as a char array?
https://github.com/souliss/souliss/wiki/vNet%20Details#frame-structure

I'm reasonably new to C and C++, but am a professional programmer in other languages.

Thanks for any and all advice.

--

Darren

Di Maio, Dario

unread,
Mar 7, 2016, 2:11:06 AM3/7/16
to sou...@googlegroups.com

Hi Darren,

I'm shocked, only 8 bytes! Looks a very low value.

If you look at the vNet configuration file you will found the maximum payload value, that is near to 50 bytes if I remember correctly.
So yes, you need to reassemble frames that is a not nice option.

The whole structure of Souliss assume that you can do your job (sending or receiving) in one shot, is possible to have something different and I did it for the software based TCP/IP stack, but performances was really low.

The most similar bus to CAN is RS485, that we support and works well. I think that may be an option for you.

Replying to your question

1) The RS485 is a broadcast as well and the addressing is in vNet.
2) The len was introduced before oFrame, but there is no really sense at this time.
3) The *data is a pointer to the array that is used to collect the raw data to be parsed.

Dario.

From Mobile.

--
You received this message because you are subscribed to the Google Groups "souliss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to souliss+u...@googlegroups.com.
To post to this group, send email to sou...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/souliss/7d6f515b-5160-4e84-a652-0c186a1a58f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages