Error running brytongps.py
Closed this issue · 5 comments
Hi - I'm trying to run your code with a Bryton Rider 35 - I'm afraid I'm clueless about python so this could be me doing something silly. When I run python brytongps.py --list-history I get the following.
File "brytongps.py", line 291, in
sys.exit(main())
File "brytongps.py", line 252, in main
module, device = get_device(dev_access)
File "brytongps.py", line 54, in get_device
data = dev.read_addr(6, 1, 0x10).tostring()
File "/home/chris/python/bryton-gps-linux-master/code/common.py", line 191, in read_addr
cdb = _scsi_read10(addr, block_count, reserved_byte=read_type)
File "/home/chris/python/bryton-gps-linux-master/code/common.py", line 157, in _scsi_read10
return _scsi_pack_cdb(cdb)
File "/home/chris/python/bryton-gps-linux-master/code/common.py", line 137, in _scsi_pack_cdb
return struct.pack('{}B'.format(len(cmd)), *cmd)
ValueError: zero length field name in format
I'm running CentOS 6.3.
Have you any ideas on what the problem is?
Thanks and regards
I think the problem is that your python version is too old. I have only tested the code with python 2.7.x.
But the problem is easy to fix. This line:
return struct.pack('{}B'.format(len(cmd)), *cmd)
need to be changed to: (add 0 between {})
return struct.pack('{0}B'.format(len(cmd)), *cmd)
There is also other parts of the code that need the same change. It's very simple so i will try to fix this soon.
If you want to try the code immediately the easiest way is to install python version 2.7.3. You can do this manually or try using https://github.com/utahta/pythonbrew
Thanks for the prompt reply - I could only find that line in dump.py and common.py so changed it and tried again. Different errors now:
brytongps.py:63: RuntimeWarning: Unknown device model.
warnings.warn('Unknown device model.', RuntimeWarning)
Traceback (most recent call last):
File "brytongps.py", line 291, in
sys.exit(main())
File "brytongps.py", line 255, in main
history = list(reversed(module.read_history(device)))
File "/home/chris/python/bryton-gps-linux-master/code/rider40.py", line 267, in read_history
timestamp = buf.uint32_from(0x00)
File "/home/chris/python/bryton-gps-linux-master/code/common.py", line 116, in uint32_from
return struct.unpack('I', self.read_from(offset, 4))[0]
File "/home/chris/python/bryton-gps-linux-master/code/common.py", line 106, in read_from
self.data.extend(self.device.read_block(block_addr))
File "/home/chris/python/bryton-gps-linux-master/code/rider40.py", line 64, in read_block
raise IOError('Reading past end of device.')
IOError: Reading past end of device.
Maybe the format is different from Rider 35 is different as the file produced by dump.py seems to be unprintable characters.
The file from dump.py should be mostly unprintable characters, but the data is hidden in there.
If you can send me the file from dump.py, i can have a look at it and try to make it work with Rider 35.
It is best if you record at least one track before using dump.py
You can send me the file to: progrper @ gmail.com
I have updated the code for rider35 now, you can find it in the rider35 branch. You checkout the branch like this:
git clone https://github.com/Pitmairen/bryton-gps-linux.git
cd bryton-gps-linux
git checkout -t -b rider35 origin/rider35
I think the code should be working, but i haven't tested it much.
It will probably break sooner or later with an error about unknown trackpoint or logpoint format, this is usually easy to fix. If this happens just send me the output from dump.py and also include the BDX files exported using brytonbridge.
The latest update for the Rider 35 has worked beautifully. I've been able to create tcx and gpx files from the history and also upload straight into Strava. Good work!