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

struct.error: unpack requires a bytes object of length 3 #32

Open
hassanyousufx opened this issue Aug 30, 2018 · 4 comments
Open

struct.error: unpack requires a bytes object of length 3 #32

hassanyousufx opened this issue Aug 30, 2018 · 4 comments

Comments

@hassanyousufx
Copy link

I get a struct.error when I run myo-raw.py or myo.py.

hassan@finroc:~/myo-raw-master$ python myo.py 
using device: /dev/ttyACM0
scanning...
scan response: Packet(80, 06, 00, [C8 00 D4 D1 52 C7 46 DC 00 FF 1F 09 08 4D 79 6F 00 00 00 00 00 02 01 06 11 06 42 48 12 4A 7F 2C 48 47 B9 DE 04 A9 01 00 06 D5])
firmware version: 1.5.1970.2
device name: b'\x00\x03\x00\x00\x03Myo'
0
Traceback (most recent call last):
  File "myo.py", line 115, in <module>
    m.run()
  File "/home/hassan/myo-raw-master/myo_raw.py", line 195, in run
    self.bt.recv_packet(timeout)
  File "/home/hassan/myo-raw-master/myo_raw.py", line 80, in recv_packet
    self.handle_event(ret)
  File "/home/hassan/myo-raw-master/myo_raw.py", line 112, in handle_event
    h(p)
  File "/home/hassan/myo-raw-master/myo_raw.py", line 291, in handle_data
    typ, val, xdir = unpack('3B', pay)
  File "/home/hassan/myo-raw-master/common.py", line 7, in unpack
    return struct.unpack('<' + fmt, *args)
struct.error: unpack requires a bytes object of length 3

I am running this in Ubuntu 16.04.5 LTS. What could be the reason? I want to run Myo in Linux environment.

@ssravali
Copy link

I got the same error while running on a windows 8 OS with python 3.5!! What to do?

@ghost
Copy link

ghost commented Oct 4, 2018

I got the same error while running on a windows 8 OS with python 3.5!! What to do?

Someone has updated this library to run on 3.5 and possibly higher.
Myo Raw Python3

@HIFIKIKI
Copy link

Anyone can solve this problem?

@MiraWelner
Copy link

MiraWelner commented Aug 20, 2020

Use loxxy's solution! They made a pull request that was not merged, but it's a simple fix: Just switch
elif attr == 0x23
typ, val, xdir = unpack('3B', pay)

to:
elif attr == 0x23
## 6 Bytes instead of 3
typ, val, xdir,,,_ = unpack('6B', pay)

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

4 participants