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

Shouldn't we read last 4 bytes from the UDP messages? #6

Open
wortelus opened this issue Feb 25, 2023 · 2 comments
Open

Shouldn't we read last 4 bytes from the UDP messages? #6

wortelus opened this issue Feb 25, 2023 · 2 comments

Comments

@wortelus
Copy link
Contributor

wortelus commented Feb 25, 2023

Hi, wortelus here again

I ended up in a situation, where this line of code incorrectly read '0,0' on line 545 of
value = unpack('<f', rrefdata[9:13])[0]
the line is not always 13 bytes long.

The messages are either 13, 21 or 29 bytes long as far as I have seen. Is there something in the protocol I am missing?

Sometimes, the udp communication starts and receives only 13 byte messages, but I am seeing sometimes the 21/29 byte ones
and it breaks the program. Restarting it usually solves the problem, but sometimes it appears again.

Example:
The received message is here 21 bytes long. And as you can see in the watches, the solution of
unpack('<f', rrefdata[-4:])[0] displays the correct position of the knob (5.0) in the sim

obrazek

obrazek

Using X-Plane 11.51

@wortelus
Copy link
Contributor Author

It seems to happen and then never stop until relaunch. For some reason during normal operation it doesn't happen that much, but if I actually run this using debugger it seems to increase its chances to switch to the 21/29 messages. Maybe some kind of buffer overloading?

It could almost seem like the messages send more datarefs per message, although the [-4:] fix magically reads the correct values, even though it is most probably a coincidence.

@wortelus
Copy link
Contributor Author

wortelus commented Dec 6, 2024

This behaviour is caused by X-Plane's choice of sending multiple datarefs in the same packet: https://xppython3.readthedocs.io/en/latest/development/udp/rref.html#multiple-results-in-same-packet

I shall get to fix this in the upcoming times. Until then, I at least link the cause from the xppython3 docs.

wortelus

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

1 participant