nutki / spike-tools

Utilities for experimenting with Lego Spike Hub
53 stars 12 forks source link

Robot flashing red after uploading and launching #5

Closed chm46e closed 1 year ago

chm46e commented 3 years ago

HI! While uploading, everything works, but when I try to launch it, then it throws a error at me. Disabling the Modem Manager didn't help. When enabling debug mode I get: DEBUG:root:Cannot parse JSON: bytearray(b'10, 300, 323, 319]], [61, [4, 0, 21, 23, 25]], [49, [0, 3, -133, 0]], [49, [0, -4, -137, 0]], [458, -597, 637], [1, 2, 0], [-23, -36, -36], "", 0]}') This even happens when I try to upload a program with only 1 comment inside and with the program template. I have downloaded all the modules. I'm using Linux/pop os, python3.9.1(brew) and also tried python3.9.0(apt), llvm9.0.1(with brew), llvmlite0.34.0. Everything should be compatible.

chm46e commented 3 years ago

Input: sudo LLVM_CONFIG=/home/linuxbrew/.linuxbrew/Cellar/llvm@9.0.1_3/bin/llvm-config /usr/bin/python3.9 ./spikejsonrpc.py --debug upload hub/program_template.py 1 Output: DEBUG:root:sending: {"m": "start_write_program", "p": {"slotid": 1, "size": 306, "meta": {"created": 1609330728685, "modified": 1609330728685, "name": "hub/program_template.py"}}, "i": "zaDu"} DEBUG:root:Cannot parse JSON: bytearray(b' [0, 0, 0], "", 0]}') DEBUG:root:while waiting for response: {'m': 0, 'p': [[48, [0, 0, -176, 0]], [48, [0, 0, 141, 0]], [61, [100, 10, 570, 538, 531]], [61, [71, 10, 357, 320, 323]], [49, [0, 0, 73, 0]], [49, [0, 0, -38, 0]], [-5, 107, 998], [1, -1, 0], [0, 0, 0], '', 0]} DEBUG:root:while waiting for response: {'m': 0, 'p': [[48, [0, 0, -176, 0]], [48, [0, 0, 141, 0]], [61, [100, 10, 570, 538, 531]], [61, [71, 10, 359, 321, 327]], [49, [0, 0, 73, 0]], [49, [0, 0, -38, 0]], [-3, 111, 998], [1, -1, 0], [0, 0, 0], '', 0]} DEBUG:root:while waiting for response: {'m': 0, 'p': [[48, [0, 0, -176, 0]], [48, [0, 0, 141, 0]], [61, [100, 10, 571, 540, 533]], [61, [71, 10, 358, 321, 325]], [49, [0, 0, 73, 0]], [49, [0, 0, -38, 0]], [-6, 109, 1000], [0, -1, 0], [0, 0, 0], '', 0]} DEBUG:root:while waiting for response: {'m': 0, 'p': [[48, [0, 0, -176, 0]], [48, [0, 0, 141, 0]], [61, [100, 10, 571, 540, 533]], [61, [71, 10, 358, 321, 325]], [49, [0, 0, 73, 0]], [49, [0, 0, -38, 0]], [-6, 109, 1000], [0, -1, 0], [0, 0, 0], '', 0]} DEBUG:root:response: {'i': 'zaDu', 'r': {'blocksize': 512, 'transferid': '2054'}} 0%| | 0.00/306 [00:00<?, ?B/s]DEBUG:root:sending: {"m": "write_package", "p": {"data": "aW1wb3J0IGh1Ygpmcm9tIHJ1bnRpbWUgaW1wb3J0IFZpcnR1YWxNYWNoaW5lCgojIFdoZW4gcHJvZ3JhbSBzdGFydHMKYXN5bmMgZGVmIG9uX3N0YXJ0KHZtLCBzdGFjayk6CiAgZm9yIGkgaW4gcmFuZ2UoMTEpOgogICAgIyBTZXQgTEVEIGNvbG9yCiAgICBodWIubGVkKGkpCiAgICAjIFNsZWVwIDEgc2Vjb25kCiAgICB5aWVsZCAxMDAwCgpkZWYgc2V0dXAocnBjLCBzeXN0ZW0pOgogIHZtID0gVmlydHVhbE1hY2hpbmUocnBjLCBzeXN0ZW0sICIiKQogIHZtLnJlZ2lzdGVyX29uX3N0YXJ0KCIiLCBvbl9zdGFydCkKICByZXR1cm4gdm0K", "transferid": "2054"}, "i": "uIPl"} DEBUG:root:while waiting for response: {'m': 0, 'p': [[48, [0, 0, -176, 0]], [48, [0, 0, 141, 0]], [61, [100, 10, 570, 538, 531]], [61, [71, 10, 357, 320, 323]], [49, [0, 0, 73, 0]], [49, [0, 0, -38, 0]], [-7, 110, 997], [0, -1, 0], [0, 0, 0], '', 0]} DEBUG:root:while waiting for response: {'m': 1, 'p': {'storage': {'available': 30976, 'total': 31744, 'pct': 3.41935, 'unit': 'kb', 'free': 30976}, 'slots': {'1': {'created': 1609330728685, 'id': 22622, 'size': 306, 'modified': 1609330728685, 'name': 'hub/program_template.py'}, '0': {'name': 'UHJvamVjdCAx', 'id': 41460, 'project_id': 'zSuC3umG_2vx', 'modified': 1608386667909, 'type': 'scratch', 'created': 1607800914150, 'size': 811}, '2': {'name': 'TW90b3JzIGFuZCBTZW5zb3Jz', 'id': 54911, 'project_id': '4flRduBceIXa', 'modified': 1604651601709, 'type': 'scratch', 'created': 1604651475349, 'size': 133}}}} DEBUG:root:response: {'i': 'uIPl', 'r': {'next_ptr': 368}} 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 306/306 [00:00<00:00, 900B/s]

chm46e commented 3 years ago

I have tried different Python versions(3.7.5, 3.8.6, 3.9.0, 3.9.1). Here's 3.9.0 pip list: Input: sudo LLVM_CONFIG=/home/linuxbrew/.linuxbrew/Cellar/llvm@9.0.1_3/bin/llvm-config /usr/bin/python3.9 -m pip list Output: Package Version


appdirs 1.4.4 audioread 2.1.9 binwalk 2.2.0 blinker 1.4 Brlapi 0.7.0 certifi 2020.4.5.1 cffi 1.14.4 chardet 3.0.4 chrome-gnome-shell 0.0.0 click 7.1.2 colorama 0.4.3 command-not-found 0.3 cryptography 3.0 cupshelpers 1.0 cycler 0.10.0 dbus-python 1.2.16 decorator 4.4.2 defer 1.0.6 distlib 0.3.1 distro 1.5.0 distro-info 0.23ubuntu1 filelock 3.0.12 hidpidaemon 18.4.6 httplib2 0.18.1 idna 2.10 importlib-metadata 1.6.0 jeepney 0.4.3 joblib 1.0.0 kernelstub 3.1.4 keyring 21.3.0 kiwisolver 1.2.0 language-selector 0.1 launchpadlib 1.10.13 lazr.restfulclient 0.14.2 lazr.uri 1.0.5 libvirt-python 6.1.0 llvmlite 0.34.0 louis 3.14.0 macaroonbakery 1.3.1 matplotlib 3.3.0 more-itertools 4.2.0 netifaces 0.10.4 numpy 1.18.4 oauthlib 3.1.0 olefile 0.46 packaging 20.8 Pillow 7.2.0 pip 20.1.1 pipenv 11.9.0 pooch 1.3.0 pop-transition 1.0.1 protobuf 3.12.3 pycairo 1.16.2 pycparser 2.20 pycups 2.0.1 pydbus 0.6.0 Pygments 2.3.1 PyGObject 3.38.0 PyJWT 1.7.1 pymacaroons 0.13.0 PyNaCl 1.4.0 PyOpenGL 3.1.5 pyparsing 2.4.7 PyQt5 5.15.0 pyqtgraph 0.11.0 pyRFC3339 1.1 pyserial 3.5 python-apt 2.1.3+ubuntu1.2 python-dateutil 2.8.1 python-debian 0.1.37 python-xlib 0.27 pytz 2020.1 pyxdg 0.26 PyYAML 5.3.1 repolib 1.5.2 repoman 1.4.0 requests 2.23.0 requests-unixsocket 0.2.0 scikit-learn 0.24.0 scipy 1.5.2 SecretStorage 3.1.2 sessioninstaller 0.0.0 setuptools 49.3.1 simplejson 3.17.0 sip 4.19.24 six 1.15.0 SoundFile 0.10.3.post1 systemd-python 234 threadpoolctl 2.1.0 tqdm 4.55.0 ubuntu-advantage-tools 24.4 ubuntu-drivers-common 0.0.0 ufw 0.36 urllib3 1.25.9 virtualenv 20.0.29+ds virtualenv-clone 0.3.0 wadllib 1.3.4 wheel 0.34.2 xkit 0.0.0 zipp 1.0.0

chm46e commented 3 years ago

I have also tried different Hub's if you're wondering. I'm competing in FLL Replay season. If there's nothing I can do, I'll prb dual-boot Windows(I have a cpu bottleneck when I try to launch Windows alongside Linux in a virtual machine(even when I allocated 75% of my cpu to it))and have to rewrite like 1 and a half weeks of code in the Spike Prime app... I don't know even know if I remember how to use Windows lol (=.

nutki commented 3 years ago

Hi @x3F-x3F, thanks for the report. The JSON parse error in the debug is expected, and is a result of the fact that the hub continuously sends sensor data even if session is not open so the first read will most likely contain a partial JSON sensor report. I suspect that the problem is with the code you are trying to upload. It is even possible that my examples do not work anymore as the firmware was updated since I wrote this tool (including the native ability to use Python code).

chm46e commented 1 year ago

Almost 2 years later, being waay more knowledgeable, I realize my stupidity:D It's so dumb, i don't even want to talk about it.. Yes, it had to do with my program. It works now hehe. sowwy