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 bug in check for valid cemi frame #80

Closed
nanosonde opened this issue Jul 22, 2020 · 3 comments
Closed

Possible bug in check for valid cemi frame #80

nanosonde opened this issue Jul 22, 2020 · 3 comments

Comments

@nanosonde
Copy link
Contributor

While testing the coupler routing I got "invalid frame" messages in the console.

Inspecting this code:

uint8_t apduLen = _data[1 + _data[1] + NPDU_LPDU_DIFF];

If I remove the "+1" then everything works as expected. Why do we have the "+1" there?

@nanosonde
Copy link
Contributor Author

nanosonde commented Jul 22, 2020

_data[0] is the cemi message code.
_data[1] is the additional info length which was 0 during testing
NPDU_LPDU_DIFF is 8

Looking at the cemi frame format, it seems that the "+1" is simply wrong.

cEMI Frame Format

+--------+--------+--------+--------+---------+---------+--------+---------+
|  Msg   |Add.Info| Ctrl 1 | Ctrl 2 | Source  | Dest.   |  Data  |   APDU  |
| Code   | Length |        |        | Address | Address | Length |         |
+--------+--------+--------+--------+---------+---------+--------+---------+
   1 byte   1 byte   1 byte   1 byte   2 bytes   2 bytes   1 byte   2 bytes

@nanosonde
Copy link
Contributor Author

nanosonde commented Jul 22, 2020

The NPDU_LPDU_DIFF starts counting from 0 and includes the message code field.

@thelsing
Copy link
Owner

You should be right. This is already included in the coupler pull request. Closing.

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

2 participants