mchr3k / arduino-libs-manchester

172 stars 113 forks source link

Update Manchester.cpp #46

Closed jcmk closed 6 years ago

jcmk commented 6 years ago

Fix transmit / getMessage issue.

mchr3k commented 6 years ago

Why do you want to change an interface for sending 16 bit messages to one which only sends 8 bit messages? AFAIK other people have been using it fine with 16 bit messages. It worked fine for me with 16 bit messages.

jcmk commented 6 years ago

The fix isn't so much about how many bits the message is, it's that the function transmit doesn't work. I could have made it 16, or whatever, but it made more sense to make it 8, since the code is working with it in 8 bit chunks and if you wanted anything longer then you should be using transmitArray anyway.

So here's what the problem was. transmit takes the parameter data and plugs it in to transmitArray, but it does it wrong. The implementation of transmitArray is wierd, it takes a byte describing the length of the data, and then a byte array, in which the first value is ALSO describing the length of the data. I changed the transmit code to properly format data for transmitArray to use. Now it works.

That being said, the transmitArray code should be changed. I'll probably get around to it, even though I only need to send 8 bit messages for my project. You should be able to feed a byte array into it, and let it determine the length. Rather than rewrite a bunch of stuff, I think the easiest option will be to make transmitArray private and then write a new wrapper function. I'd like to make it only one function, but I feel like that would cause confusion when coding the receiving end, and I'm not ready to take that on.

Forgive me if my lingo is all messed up, I'm only a hobby programmer. Regardless, transmit didn't work before, and it works now.

Technically,

J.C. Maximilian Krob

On Sat, Feb 3, 2018 at 6:30 AM, mchr3k notifications@github.com wrote:

Why do you want to change an interface for sending 16 bit messages to one which only sends 8 bit messages? AFAIK other people have been using it fine with 16 bit messages. It worked fine for me with 16 bit messages.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mchr3k/arduino-libs-manchester/pull/46#issuecomment-362799510, or mute the thread https://github.com/notifications/unsubscribe-auth/AWflQ8boPbo0YG3Tcu3iOJfGrPt2qtyCks5tRENUgaJpZM4R4CZG .

mchr3k commented 6 years ago

Your explanation makes sense. Thanks for taking the time to contribute this fix!