Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible wrong size of data (message) array? #44

Open
cpm64 opened this issue Apr 19, 2024 · 2 comments
Open

Possible wrong size of data (message) array? #44

cpm64 opened this issue Apr 19, 2024 · 2 comments

Comments

@cpm64
Copy link

cpm64 commented Apr 19, 2024

Hello,

Checking the declaration of the LnMsg.data[16] . If I got it right this is the max length of a message. Searching the internet I found various answers about what is the max size of a variable length message: 16, 20. However is not clear if that size includes the OPC [0], the msg size [1] and the checksum bytes: <OPC>,<COUNT>,<ARG1>....,<CKSUM>.

I discovered that my CS is sometimes issue an '0xe6' OPC of 21 bytes which cannot be handled by LnMsg.data[16].

As a suggestion, a possible enhancement could be to make it configurable via #define LN_MAX_MSG_LEN (n) and allow the users to define their own max limit.

This is applicable to both LocoNet and LocoNet2-development branch

@devel-bobm
Copy link
Contributor

  1. LocoNet "Message" is the correct term, not "package".

  2. LocoNet message "length", for MRRwA library purposes, includes the Opcode, any data bytes, and the checksum. This means that a valid LocoNet message can be as little as 2 bytes, or as many as 127 (or maybe 128, depending on what Digitrax says in their private LocoNet specs!) bytes.

  3. A 25 year old public LocoNet "spec" has been available at the Digitrax web site. But I did not find it this morning. Digitrax has seemed to have been reducing the amount of useful information available on their web presence over recent years. Perhaps they have gotten rid of it...

Be aware that the document has NOT been publicly updated since its release, and quite a large number of newer messages have been included but not publicly disclosed, including longer messages than are currently documented there.

  1. There are known messages with greater lengths than 16. Depending on which LocoNet devices one uses, and if one must "allow for any LocoNet message, rather than "just the ones seen on typical Digitrax hardware", or only "old-stlye Digitrax hardware", the "longest" message does change a bit.

The question about "What is the longest LocoNet message length" was recently discussed at some detail at https://groups.io/g/LocoNet-Hackers/message/11204 . I suggest that you should refer to that LocoNet hackers thread.

(The LocoNet-Hackers group tends to be a better place to discuss LocoNet technical issues than the MRRWA group...)

  1. Some "hackers" have done some things that are "not really correct", from the Digitrax perspective. In some cases, those developments may not work "correctly" with other Digitrax hardware and/or Digitrax-licensed 3rd-party hardware/softwrae, or even other do-it-yourself hardware/software. Be aware, because there is no way to avoid this situation except to work with hardware and software that Digitrax approves.

In general, WRRwA code should probably allocate 128 bytes per message, and guarantee that no incoming message "overflows" the buffer, whatever "guarantees" means. Such a library change could make a newer library version "not compatible" with certain hardware/software platforms if the new library is not compatible with the old code's memory usage and/or "timings", though.

@kiwi64ajs
Copy link
Contributor

kiwi64ajs commented Apr 19, 2024 via email

@cpm64 cpm64 changed the title Possible wrong size of data (packet) array? Possible wrong size of data (message) array? Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants