bang-olufsen / yahdlc

yahdlc - Yet Another HDLC implementation
MIT License
83 stars 27 forks source link

Few questions about the way to intagrate your library #4

Closed SkypLabs closed 8 years ago

SkypLabs commented 8 years ago

Hi,

First of all, thank you for your work. Your library is all I needed.

However, since the reception is done by a single pass operation, when should we use the 'yahdlc_get_data()' function on our receiving buffer knowing that the payload of an HDLC frame has a variable length ? In my case, I use an UART interruption which adds each single byte received in a buffer.

In addition, it could be nice if you find the time to add an example of use in your README file.

Many thanks in advance.

Kind Regards, Skyper

jeppefrandsen commented 8 years ago

Hi,

Thank you for your request.

I will try to find some time in the nearest future for updating the README. But the idea is to call yahdlc_get_data() whenever you have received one or more bytes on the UART (some UARTs have e.g. a 16 bytes FIFO). The function will return how many bytes should be discarded from the source buffer and start to disassemble the HDLC frame into the destination buffer.

Whenever a complete frame has been received (which can be of variable length since the buffer size is not specified by yahdlc) the yahdlc_get_data() function will return a positive size like the read() function.

If you have more questions just let me know but will try to get the README updated soon. Thanks.

Kind Regards, Jeppe

jeppefrandsen commented 8 years ago

Hi again,

You can try to have a look at the yahdlcTestGetDataFromMultipleBuffers test case until I get the README updated.

Kind Regards, Jeppe

SkypLabs commented 8 years ago

Hi Jeppe,

Thank you for your explanations. I had the time to read your library's code and to test it and it works well.

Kind Regards, Skyper

jeppefrandsen commented 8 years ago

Hi Skyper,

Sounds good. I will work on the README file.

Kind Regards, Jeppe