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

[AE-15] Commander.py script: cobs.cobs.DecodeError: not enough input bytes for length code #90

Open
aliphys opened this issue Apr 6, 2023 · 3 comments
Labels
type: imperfection Perceived defect in any part of project

Comments

@aliphys
Copy link
Contributor

aliphys commented Apr 6, 2023

Description of defect

Upon running the Commander.py script, the cobs.cobs.DecodeError: not enough input bytes for length code error is displayed.

PS D:\Github\aliphys\nicla-sense-me-fw\Arduino_BHY2\examples\DataHarvester\extras\Commander> & C:/Users/user/AppData/Local/Programs/Python/Python39/python.exe d:/Github/aliphys/nicla-sense-me-fw/Arduino_BHY2/examples/DataHarvester/extras/Commander/Commander.py COM23 test phys
Running...
> Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py", line 950, in _bootstrap_inner
    self.run()
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py", line 888, in run
    self._target(*self._args, **self._kwargs)
  File "d:\Github\aliphys\nicla-sense-me-fw\Arduino_BHY2\examples\DataHarvester\extras\Commander\Commander.py", line 88, in receiver       
    decoded = cobs.decode(data[0:(n - 1)])
cobs.cobs.DecodeError: not enough input bytes for length code

This may related to truncated data coming from the DataHarvester.ino file?

Target(s) affected by this defect ?

Nicla Sense ME

Toolchain(s) (name and version) displaying this defect ?

What version of Mbed-os are you using (tag or sha) ?

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

How is this defect reproduced ?

  • Ensure all required modules are installed via pip
  • Use arduino-cli to identify the COM port
  • In the terminal, run python [COMPORT] test phys
  • Press r then enter to start data aquisition

if cmd == 'R':
running = True
today = datetime.today()
iso = datetime.isoformat(today)
filename = f'{name}_{tag}_{iso}.csv'
f = open(filename, 'wt')
print(f'timestamp,accX,accY,accZ', file=f)
cmd = 'N'

@aliphys aliphys added the type: imperfection Perceived defect in any part of project label Apr 6, 2023
@sebromero
Copy link
Contributor

@manchoz Any idea what's going wrong here?

@manchoz
Copy link
Contributor

manchoz commented Apr 6, 2023

Something might be changed in the PacketSerial or Python COBS library. @aliphys can you try changing the n-1 index to n at line 88?

Is the same issue present on MacOS or GNU/Linux?

Also check for data being sent correctly from the Nicla Sense ME.

@aliphys
Copy link
Contributor Author

aliphys commented Apr 11, 2023

Something might be changed in the PacketSerial or Python COBS library. @aliphys can you try changing the n-1 index to n at line 88?

Changing the n-1 index to n at line 88 leads to a zero byte found in input error

PS D:\Github\aliphys\nicla-sense-me-fw> & C:/Users/user/AppData/Local/Programs/Python/Python39/python.exe d:/Github/aliphys/nicla-sense-me-fw/Arduino_BHY2/examples/DataHarvester/extras/Commander/Commander.py 
COM27 test Physics
> r
Running...
> Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py", line 950, in _bootstrap_inner
    self.run()
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py", line 888, in run        
    self._target(*self._args, **self._kwargs)
  File "d:\Github\aliphys\nicla-sense-me-fw\Arduino_BHY2\examples\DataHarvester\extras\Commander\Commander.py", line 88, in receiver
    decoded = cobs.decode(data[0:(n)]) #decoded = cobs.decode(data[0:(n - 1)])
cobs.cobs.DecodeError: zero byte found in input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants