Pitmairen / bryton-gps-linux

An attempt to read Bryton GPS devices on Linux
GNU General Public License v3.0
29 stars 14 forks source link

Rider20+ #9

Closed boltronics closed 11 years ago

boltronics commented 11 years ago

Output of lsusb:

$ lsusb -v -d 0483:5720

Bus 006 Device 010: ID 0483:5720 SGS Thomson Microelectronics 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0483 SGS Thomson Microelectronics
  idProduct          0x5720 
  bcdDevice            1.00
  iManufacturer           1 STMicroelectronics
  iProduct                2 STM32 Mass Storage
  iSerial                 3 000000000001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              4 ST Mass
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0001
  Self Powered

dump: https://systemsaviour.com/downloads/bryton-rider20+/

Thanks!!

Pitmairen commented 11 years ago

Unfortunately it looks like this device is completely different than the other devices.

It looks like the dump file is a FAT12 file system. I was able to mount it using "mount file.dump dir", but it seems incomplete. Maybe you can try to increase the number of bytes to read in the dump.py file and see if anything changes. You can do this at this line: https://github.com/Pitmairen/bryton-gps-linux/blob/master/dump.py#L113

boltronics commented 11 years ago

Sorry - I'm confused. I'm not really sure what dump.py is trying to do. The Rider20+ is just a mass storage device with a normal FAT12 file system (as you pointed out), so not really sure why it needs something special to capture it.

I just uploaded the output of the dd if=/dev/sdk of=rider-20+-201305250912.img command to the same URL as above. I can mount this just fine as a normal FAT12 file system and seem to be able to read any file without issue. The file names and everything look normal.

In case I'm missing something, I also followed your instructions of increasing the number of bytes significantly in dump.py and created a new dump file. This was also uploaded, however mounting that looks just as corrupted as the first one you looked at.

Pitmairen commented 11 years ago

Ok, i understand why you are confused. The older Bryton devices uses an unknown filesystem, so they can't be mounted and read with a normal file manager. That's why i created this software to be able to read the data from the device.

I didn't know the newer devices had changed to a FAT filesystem. This should make some things a little easier on newer devices. But the format of the data seems to be completely different also, so most of the old code will not be very useful.

If you can send me all the .bdx files exported using BrytonBridge on windows/mac i can try to see if i can figure out the new data format. If you have recoded any new tracks since the last dd-image you sent i need a new dd-image of the filesystem also. The content of the bdx files and filesystem image needs to match.

boltronics commented 11 years ago

Ahh... got it. Thanks for the explanation. :)

I've never actually tried to use the Windows software before. I was hoping to avoid touching it, but will do what I can to help. I'll post a new comment when I've got something uploaded.

I haven't recorded any new tracks. I can't - the device is full and I don't want to delete anything unnecessarily.

boltronics commented 11 years ago

Two more files have now been uploaded:

  1. bdx.zip - zip file of all bdx files exported from BrytonBridge in Windows. As previously noted, no new tracks have been recorded.
  2. bbexport.zip - a zip file created by the BrytonBridge software that contains some logs with version information and what not. These also indicate that a firmware update is available, but I have not chosen to do that yet in order to keep things simple. Thanks again.
Pitmairen commented 11 years ago

I have added a new branch for rider20+ (https://github.com/Pitmairen/bryton-gps-linux/tree/rider20plus)

The data format was similar to the other devices so it wasn't too hard to figure out. I haven't tested it very much but it seems to be working. The device filesystem will need to be mounted somewhere for it to work.

boltronics commented 11 years ago

That's amazing! I just signed up for a strava.com account and tried pretty much all the functionality, and everything appears to be working fine. Thanks so much!!

There is one very minor issue I noticed. I wasn't clear on how the --strava option worked at first. The --fake-garmin help mentioned the option was to help strava.com trust the elevation data, but "only used when exporting tcx files". This made me think that I needed to run something like:

python brytongps.py --tracks {0..189} --strava --strava-email 'me@my_email.com' --strava-password 'my_password' --fake-garmin --tcx

After perhaps one billion lines of stdout, I ended up with:

Authenticating to strava.com
Uploading track: 2013/05/22 21:15
Traceback (most recent call last):
  File "brytongps.py", line 422, in <module>
    sys.exit(main())
  File "brytongps.py", line 377, in main
    fake_garmin_device=device.has_altimeter)
  File "brytongps.py", line 246, in upload_strava
    upload = uploader.upload(t)
  File "/home/abolte/Downloads/drivers/bryton-gps-linux/git/code/strava.py", line 77, in upload
    self.fake_garmin_device),
  File "/home/abolte/Downloads/drivers/bryton-gps-linux/git/code/tcx.py", line 226, in track_to_tcx
    create_laps(track, activity, ns)
  File "/home/abolte/Downloads/drivers/bryton-gps-linux/git/code/tcx.py", line 156, in create_laps
    for sum, segments in _get_lap_trackpoints(track):
  File "/home/abolte/Downloads/drivers/bryton-gps-linux/git/code/tcx.py", line 250, in _get_lap_trackpoints
    lap = (summaries.pop(0), [[]])
IndexError: pop from empty list

This was just n00b stupidity on my behalf, but perhaps --tcx and --strava should be mutually exclusive, or the upload should fail after the tcx files were exported to stdout. Also not sure if this is specific to this branch, or it's always been a problem. I can open a new issue report if you like.

Anyway, thanks again. Post your wallet id if you accept bitcoin or something. Cheers.

Pitmairen commented 11 years ago

The --tcx option will export the specified tracks in the tcx format and print it to stdout. Its the same with the --gpx and --gpxx. This is only useful with a single track, if you're gonna export multiple tracks it should be combined with the --save-to option. This will save each track as individual files into the specified directory. You can combine --tcx --gpx and --gpxx with --save-to in a single command and all the tracks will be exported to each format.

This can also be combined with the --strava option so you can upload to strava and export to a local directory in a single command. If you only gonna upload to strava you only need the --strava options, you don't have to specify the format, tcx is always used.

The reason why you command failed is because i see now that there is a bug in the tcx generator code that modifies a list without copying it. So when it is run twice it fails the second time. I will fix this later today.

I'm also gonna modify the --fake-garmin option to make also work together with the --strava options. Currently when uploading to strava it will automatically fake it depending on whether you device has a barometric altimeter or not.

Pitmairen commented 11 years ago

I have fixed the error in the tcx code and also the --fake-garmin is now used when uploading to strava.

boltronics commented 11 years ago

Terrific!! Thanks so much for your time and efforts. They have been extremely helpful and very much appreciated.