fossasia / pslab-desktop

PSLab Desktop Application https://pslab.io
GNU General Public License v3.0
1.77k stars 364 forks source link

Receiving malformed JSON on device reset #610

Closed orangecms closed 3 years ago

orangecms commented 4 years ago

When I click on the reset button in the app, it does say "device reset" and "device connected" in a snackbar at the bottom. In the terminal emulator from which I am running the app, I can see some errors.

20:02:57.457 › SyntaxError: Unexpected token / in JSON at position 0
    at JSON.parse (<anonymous>)
    at PythonShell.<anonymous> (file:///home/dan/Projects/fossasia/pslab-desktop/background_tasks/linker.html:28:30)
    at PythonShell.emit (events.js:182:13)
    at /home/dan/Projects/fossasia/pslab-desktop/node_modules/python-shell/index.js:324:22
    at Array.forEach (<anonymous>)
    at PythonShell.receiveInternal (/home/dan/Projects/fossasia/pslab-desktop/node_modules/python-shell/index.js:322:15)
    at PythonShell.receive (/home/dan/Projects/fossasia/pslab-desktop/node_modules/python-shell/index.js:296:21)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:260:13)
20:02:57.458 › SyntaxError: Unexpected token R in JSON at position 0
    at JSON.parse (<anonymous>)
    at PythonShell.<anonymous> (file:///home/dan/Projects/fossasia/pslab-desktop/background_tasks/linker.html:28:30)
    at PythonShell.emit (events.js:182:13)
    at /home/dan/Projects/fossasia/pslab-desktop/node_modules/python-shell/index.js:324:22
    at Array.forEach (<anonymous>)
    at PythonShell.receiveInternal (/home/dan/Projects/fossasia/pslab-desktop/node_modules/python-shell/index.js:322:15)
    at PythonShell.receive (/home/dan/Projects/fossasia/pslab-desktop/node_modules/python-shell/index.js:296:21)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:260:13)

no error :)

Arch Linux

I am using the PSlab Python library v1.0.1.

cynthi8 commented 3 years ago

The malformed string is 'Radio transceiver not installed/not found'.

The PSL library prints it when the device is connected and the NRF24L01 module is initialized. With this recent refactoring, it now uses logging and that should solve the issue because INFO level logs do not go to stdout (by default). I tested this change, and the bug was gone.

The next pslab python update should fix this bug.

cynthi8 commented 3 years ago

This malformed JSON is no longer received.

orangecms commented 3 years ago

Awesome, thanks for checking! So I'm closing this :)