Remove extra null, only if length is one byte longer then message.#7
Remove extra null, only if length is one byte longer then message.#7
Conversation
| * is get from the SoftwareSerial on the "nano" | ||
| * posible message length are: | ||
| * FC1..6 : length = 8 (with extra null 9) | ||
| * FC15 : length = 11 (with extra null 12) |
There was a problem hiding this comment.
Ooo, this is very wrong ... will fix :-(
There was a problem hiding this comment.
will need to do crc after checking command and length ?
There was a problem hiding this comment.
I don't like hardcoding the length (as I also did in the first pull request).
If anybody will ever implement new messages that are part of the modbus standard, it will be a mess again.
I would prefer to isolate a function calculating the message length and trimming the nulls at the end.
Do you agree?
| * Get message address and length/status. | ||
| */ | ||
| address = word(bufIn[2], bufIn[3]); // first register. | ||
| length = word(bufIn[4], bufIn[5]); // number of registers to act apone. |
| length = word(bufIn[4], bufIn[5]); // number of registers to act apone. | ||
|
|
||
| /** | ||
| * this removes any trailing noise after message |
There was a problem hiding this comment.
sanity check and remove ...
|
@raffaeler can you check that this version works for you ? |
|
Yes, it works on my sketch, but I will also quickly check the code since my sketch does not use all the functions |
|
I am still working on it, sorry for the previous, deleted msg |
|
np :-) |
|
There could be a problem when calculating the length. |
Right, thanks ! |
|
@raffaeler Thanks, added the missing check. |
Remove extra null, only if length is one byte longer then message.
In #6 we remove the extra null when length is bigger then 8, this is a problem for valid messages of length 11 and 13.
In this pull request we look for specific length that can have an extra null.
@raffaeler please take a look