raspishake / rsudp

Continuous visual display, sudden motion monitoring, and historical replay of Raspberry Shake data
https://raspishake.github.io/rsudp/
GNU General Public License v3.0
52 stars 30 forks source link

Sudden malformed UDP packets? #20

Closed Thorinair closed 3 years ago

Thorinair commented 3 years ago

Hello, I've been using rsudp a few times and it worked just fine. I didn't make any change to the Raspberry Shake itself, other than adding another address to transmit the data to. When I tried to run rsudp today, I was greeted with the following error upon receiving a packet:

2021-02-23 23:17:07 [Init] Waiting for UDP data on port 8888...
Traceback (most recent call last):
  File "c:\users\thorinair\miniconda3\envs\rsudp\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\thorinair\miniconda3\envs\rsudp\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Thorinair\miniconda3\envs\rsudp\Scripts\rs-client.exe\__main__.py", line 7, in <module>
  File "c:\users\thorinair\miniconda3\envs\rsudp\lib\site-packages\rsudp\client.py", line 475, in main
    run(settings, debug=debug)
  File "c:\users\thorinair\miniconda3\envs\rsudp\lib\site-packages\rsudp\client.py", line 158, in run
    rsstn=settings['settings']['station'])
  File "c:\users\thorinair\miniconda3\envs\rsudp\lib\site-packages\rsudp\raspberryshake.py", line 173, in initRSlib
    set_params()                                # get data and set parameters
  File "c:\users\thorinair\miniconda3\envs\rsudp\lib\site-packages\rsudp\raspberryshake.py", line 225, in set_params
    getTR(getCHNS()[0])
  File "c:\users\thorinair\miniconda3\envs\rsudp\lib\site-packages\rsudp\raspberryshake.py", line 438, in getCHNS
    nextCHN = getCHN(DP)
  File "c:\users\thorinair\miniconda3\envs\rsudp\lib\site-packages\rsudp\raspberryshake.py", line 284, in getCHN
    return str(DP.decode('utf-8').split(",")[0][1:]).strip("\'")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf2 in position 0: invalid continuation byte

It is almost as if the Raspberry Shake is sending malformed packets? I went further to investigate. Since I am also streaming the data to my Discord bot system, I added a command which dumps the latest packet so I can see how exactly it looks like, and I couldn't notice any issue. Here is a packet:

{"type":"Buffer","data":[242,3,0,0,97,30,0,0,13,68,119,101,101,98,39,115,32,67,114,101,101,107,9,99,104,114,121,115,97,108,105,115,104,16,1,0,0,0,0,16,0,0]}

Any idea what this could be about and how can I fix it?

I have also noticed an additional issue, but this one is more of a Raspberry Shake related one. Since I was debugging, I tried to remove the data streams, but removing them didn't actually do anything. Even if there were no data streams, the device kept streaming both to my desktop and my Discord bot. Let me know where I can post about THAT issue as well, because I feel that it is quite a big one.

Thorinair commented 3 years ago

The first issue appears to be... Terraria server related, as weird as that may sound. It seems to broadcast on port 8888, maybe for announcing its presence? Killing the server allowed me to connect just fine.

Second issue is also related to it, because the server was again, pushing data to all the IPs to announce its presence.

This is one of the dumbest things I have ever encountered, sorry for wasting anyone's time.