Saturday, July 11, 2009

Command Line Extraction Tool

PRE-ALPHA: bmhack is a command line extraction tool which will extract and parse data from your (new model) BodyMedia ArmBand device into a variety of formats, including a tab-delimited spreadsheet-compatible file, raw packets in ASCII HEX, and a full Python cPickle binary dump.

THIS TOOL WILL NOT HELP YOU if you are looking for something to give you calorie counts or activity graphs. It is in a very early state, and is only useful for technical people who wish to attempt to experiment with and analyze the raw data or learn more about their BodyMedia device.

You must install Python 2.6, and the Python numpy libraries.
Windows: Python 2.6.2 from http://www.python.org/download/releases/
Windows: Numpy for 2.6.2 from http://sourceforge.net/projects/numpy/files/

Download bmhack VERSION z718b [June 18 update] from:
http://www.mediafire.com/?sharekey=26cf7e726ccc34f061d4646c62b381cbfe370e2ca4df676ac95965eaa7bc68bc

Windows: Launch bmhack with C:\python26\python.exe bmhack.py

There is also an example of several days of CSV output in that MediaFire directory, filename z705a.csv

It is verified to work under Linux, and should work under Windows (let me know?).

If you want to experiment with the less understood parts of the protocol, download the known_requests.pickle from the same site and move into your current directory when you run bmhack so you can use the --fromSerialFull command.

MISSING
-[DONE VERSION z713a] Timestamps - Pretty sure I know where time offsets live before each data table. I output them to CSV, but can't intepret them yet. I expect a global time field somewhere?

-"Register" data - user attributes like height, serial number, etc are probably stored outside of the main data memory area. I haven't really looked.

-Other

In addition to being a command line program, you can also import bmhack into a Python interpreter and manipulate the data or the device directly. There are an array of analysis and display python functions.

The bmhack.py code and comments also contain my (incomplete) documentation of the ArmBand data structures. Look at ReadAllStruct() to start.

Linux: How to force the ftdi_sci driver to recognize the BodyMedia Vendor/Product IDs:

sudo modprobe ftdi_sio vendor=0x11f8 product=0x0007

Verify that a new '/dev/ttyUSB*' device has been created.


./bmhack.py -h
THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
USAGE: ./bmhack.py [SOURCE] [TARGET] [TARGET] ...
Retrieve and convert data from a BodyMedia armband device
Convert from a packet source to one or more target formats
A packet source can be a live BodyMedia USB device, a cPickle
dump file of packets, or a capture file form a serial port sniffer.

SOURCES - specify only one
--fromSerial= Extract data by quering a live USB device on the specified serial port
--fromDump= Read packets from a cPickle dump file saved previously
--fromFSPM= Parse packets from a 'Free Serial Port Monitor' by HDD Software. is an export of the RequestView window.

TARGETS - specify one or more
--toDump= Write cPickle dump of all packet data
--toCsv= Write a Spreadsheet-compatible tab delimited file of most of the data
--toPackets= Write parsed packets in human-readable HEX format

NOTE: Specify '-' as a filename to toCsv and toPackets commands in order to write to stdout instead of a file

51 comments:

  1. This does work under windows vista. I'm running 64bit Vista, and had to use the 32bit python (and other dependencies), the 64bit versions failed miserably.

    here's what i did to install:

    download 32bit python 2.6 from www.python.org/download

    grabbed ez_setup.py manually from http://peak.telecommunity.com/dist/ez_setup.py

    ran python.exe ez_setup.py

    install pyserial egg:
    C:\python26\scripts\easy_install.exe pyserial

    download and install pywin32 from http://sourceforge.net/projects/pywin32

    download and install numpy superpack 1.3.0 from http://sourceforge.net/project/numpy/files

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Windows: Launch bmhack with C:\python26\python.exe bmhack.py

    I've downloaded everything and I'm at the above point. What do I do next? I have a command line but how do I communicate with it with my gowear device?

    ReplyDelete
  5. Thank you by the way for the great help on this so far. I really don't know how to manipulate these commands but once I learn I can post back my experience.

    So far installed Python 2.6, and the Python numpy libraries.
    Windows: Python 2.6.2 from http://www.python.org/download/releases/
    Windows: Numpy for 2.6.2 from http://sourceforge.net/projects/numpy/files/

    Downloaded bmhack VERSION z718b [June 18 update] from:
    http://www.mediafire.com/?sharekey=26cf7e726ccc34f061d4646c62b381cbfe370e2ca4df676ac95965eaa7bc68bc

    Windows: Launch bmhack with C:\python26\python.exe bmhack.py

    When I open bmhack with python it opens and closes right away.

    ReplyDelete
  6. Hello nursegnet,
    You need to type "C:\python26\python.exe bmhack.py" from the DOS command line.

    Open the DOS window by going to Start->Run and enter "cmd" in the dialog box.

    Then "cd" to the directory in which you downloaded bmhack.py, and run the python command.

    With no arguments, bmhack will show you help information on usage.

    The command to use will be something like:
    C:\python26\python.exe bmhack.py --fromSerial COM13: --clear

    The COM13 number will vary - it might be COM11 or COM12 or something else. You can use the Device Manager to find out.

    Note that you do need to have installed the BodyBugg drivers on the machine sometime in the past for this to work under Windows.

    ReplyDelete
  7. Hi finnerty,
    Thank you so much for your help in this. Tells me "cannot find specified path" when I enter on the dos. I can't install numphy files either. I'll keep trying on other computers and see how far I can get. I will try again. Thank you, Gnet

    ReplyDelete
  8. Hi there! I'm late to this party, but I'm so glad this utility exists (even if I haven't gotten it to work quite yet!).

    I've got python and the numpy libraries installed in a Win 32 system. I dropped bmhack into the python26 folder for ease of use. When I try to call it with python.exe bmhack-718b.py --fromSerial COM7: --clear I get the following error:

    File "bmhack-z718b.py", line 27, in <module>
    import serial
    ImportError: No module named serial

    I installed the gowearfit drivers some time back. Any clues?

    I'm using python 2.6.4 instead of 2.6.2, but I didn't think that would crash the program.

    Thanks :)

    ReplyDelete
  9. Just wondering if anyone get this script running under Mac OS... I have VMware but I'd rather get it working on the Mac side...

    ReplyDelete
  10. Serial issue:


    You have to go to
    http://pypi.python.org/pypi/pyserial
    download
    pyserial 2.5-rc2
    extract the compressed file to the
    python directory
    it will come out in its own directory called pyserial-2.5-rc2
    take all those files and dump them into your python directory
    C:\Python26

    then run
    "python setup.py install" from the command line

    This will install the serial communication

    ReplyDelete
  11. Can anyone help with this

    C:\Python26>python.exe bmhack-z718b.py --fromSerial COM4 --toCsv -
    PIL library not found. ToImage() func unavailable
    THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
    NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
    Traceback (most recent call last):
    File "bmhack-z718b.py", line 1179, in
    sys.exit(main())
    File "bmhack-z718b.py", line 1100, in main
    ser = OpenSerial(dopts["--fromSerial"])
    File "bmhack-z718b.py", line 88, in OpenSerial
    ser.open()
    File "build\bdist.win32\egg\serial\serialwin32.py", line 56, in open
    serial.serialutil.SerialException: could not open port COM4: [Error 5] Access is denied.

    ReplyDelete
  12. Solved my PIL issue but the com port seems to say access denied ska in use even though I closed ALL possible conflicting programs.
    Help!!!!

    Btw thank you for creating this method because the subscription buisness model for a 300+ dollar item is just wrong, greedy, and the type of technology crippling corperate mindset that is holding back our society.

    ReplyDelete
  13. I have the same error as Anonymous posted Jan 26.
    Here is the executed command:
    bmhack-z718b.py --fromSerial COM9 --toCsv test.csv
    Here is the error:
    THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
    NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
    Traceback (most recent call last):
    File "C:\Users\DadMom\Desktop\gowear fit hacks\bmhack-z718b.py", line 1179, in
    sys.exit(main())
    File "C:\Users\DadMom\Desktop\gowear fit hacks\bmhack-z718b.py", line 1100, in main
    ser = OpenSerial(dopts["--fromSerial"])
    File "C:\Users\DadMom\Desktop\gowear fit hacks\bmhack-z718b.py", line 88, in OpenSerial
    ser.open()
    File "build\bdist.win32\egg\serial\serialwin32.py", line 56, in open
    serial.serialutil.SerialException: could not open port COM9: [Error 5] Access is denied.

    ReplyDelete
  14. I am having the same problem as TL. Can anyone give some guidance as to how to fix this problem?

    ReplyDelete
  15. To fix the Access Denied problem:

    in the script, right before
    ser.open()

    add this:

    ser.close()

    The script will look like this:

    def OpenSerial(fname="/dev/ttyUSB0"):
    ser=serial.Serial(fname,baudrate=921600,timeout=.01)
    ser.close()
    ser.open()

    Works on Win7 64bit Ultimate just fine, drivers auto installed, this PC has never connected to bodybugg to download anything.

    ReplyDelete
  16. It worked! Thank you, Brian! I was able to run the clear command with no Access Denied problems!! Thank you for taking the time to explain the fix, Brian; I appreciate it!!

    ReplyDelete
  17. So after you've cleared the BB it displays to the watch?

    ReplyDelete
  18. Thank you Brian-- your fix worked on my win32 machine!!

    Unfortunately, I still can't get the armband to display to the watch; I keep getting an "armband not set up" error. I think I must have inadvertently cleared it at some point. My grasp of Python is weak... I haven't the slightest clue how to use the interpreter to write new data to the device, assuming I could figure out which data to change, and how.

    Anyone have a clue?

    ReplyDelete
  19. Anyone get the armband to talk to the display watch? Just wondering before I nuke my armband..

    ReplyDelete
  20. Thanks for the software. Had to use z717 instead of z718 because it kept giving a read serial exception when trying to clear my GoWear fit arm band. With the prior version i was able to safely clear the prior logged data and I have now synced with the watch. I suspect why persons may be having problems where all the data is wiped is because they allowed the armband device to lose all power and therefore all its settings. Only thing I can suggest is that they subscribe for a month and then use this software to clear after.

    ReplyDelete
  21. Hi,

    I'm trying to get raw data from SenseWear armband with the help from your Python code. I've installed Python and numpy library. I've also followed the debate at your forum so I managed to solve the serial inputerror problem and PIL library problem. When I call (under Windows):

    C:\Python26\python.exe bmhack.py --fromSerial COM5 --toCsv test.csv

    I get the following error:

    THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
    NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
    .Traceback (most recent call last):
    File "bmhack.py", line 1180, in
    sys.exit(main())
    File "bmhack.py", line 1121, in main
    SaveStructTabDelim3(packets, dopts['--toCsv'])
    File "bmhack.py", line 984, in SaveStructTabDelim3
    fields, records = RecordTable(packets)
    File "bmhack.py", line 951, in RecordTable
    recs=ReadAllRecords(mem)
    File "bmhack.py", line 853, in ReadAllRecords
    r = ReadRecord(mem[offset:], offset)
    File "bmhack.py", line 826, in ReadRecord
    assert RecPack.has_key(id), "Unknown record ID %i at offset %i" % (id, offset)
    AssertionError: Unknown record ID 0 at offset 675

    I am new at working with Python, so I read about assertion error. As far as I understand is the condition of RecPack.has_key(id) not satisfied. I've tried some things by printing out the length of id array which is 0 when an error occurs. I really don't know what to do.

    Thank you for the help and thank you for all the hard work you've done so far.

    ReplyDelete
  22. Wicked cool... Houston I think were a go. Cleared the device and the wife was able to put it on today and it seems to respond like it should (BodyBugg) The watch seems to sync up as well... As long as it starts showing calories then this is solid on a W32 XP machine.

    ReplyDelete
  23. Hey this is great! I've been getting an error similar to what the anonymous poster from October 6th is getting as well (Unknown record ID 0 at offset 453) Any pointers on what this means and how I can fix it? Thanks for all the hard work!!

    ReplyDelete
  24. Went through the whole process and got the following but now the watch just says "ARM BAND NOT SET UP". I think this thing just cleared EVERYTHING. How do I get the user data back on it like age/weight/sex/time...?

    C:\Python26>python bmhack-z718b.py --fromSerial=COM4 --clear
    PIL library not found. ToImage() func unavailable THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
    NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
    ...............................................................................................................................................................................................................................................Cleared logged sensor data from device

    ReplyDelete
  25. ok i am lost here and everyone's comments are running together. i have installed Python 2.7(the only version 2 on the website close to 2.6) nubby's for 2.6 the pyserial and the Bmhack.py

    my bodybugg location port is Port_#0002.Hub_#0003 via my device manager

    what is the command i use to clear the body bugg memory please someone help!

    thanks

    ReplyDelete
  26. i did the following command and got the results below. the special characters were followed by serval system beeps. now the bodybugg does not seem to sync did i do something wrong?

    C:\Python26>python.exe bmhack-z718b.py --fromSerial=COM3: --clear
    PIL library not found. ToImage() func unavailable
    THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
    NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
    ............................................................Traceback (most rece
    nt call last):
    File "bmhack-z718b.py", line 1181, in
    sys.exit(main())
    File "bmhack-z718b.py", line 1103, in main
    packets, mem = MemoryDump(ser)
    File "bmhack-z718b.py", line 148, in MemoryDump
    packets.append(WriteAndReadSerialPacket(ser, pp))
    File "bmhack-z718b.py", line 129, in WriteAndReadSerialPacket
    return ReadSerial(ser, minLen=n*66, maxLen=n*66)
    File "bmhack-z718b.py", line 117, in ReadSerial
    raise Exception("ReadSerial timeout after %f sec, expected %i bytes, got %i
    bytes: %s" % (time.time() - t0, minLen, len(s), s))
    Exception: ReadSerial timeout after 3.010000 sec, expected 13200 bytes, got 1319
    ♥eâ ♫☻ x∞ ,▀►£╟¥ò7lÿαp¬► ╖Σ<` ☼↕ ╣≡ ┐‼ ☺ σⁿ▌║½♦<
    ♥eâ ♫☻ $≥ ,☼↕ ε ƒ‼ ╧►₧╟∞ôw*£ ♣ @┐► ↨∙B► ¼║½♦< < <
    (Z?α ☼↕ 9ε ƒ‼ 6 ε »‼ ╧►₧╟╥ô╟+£0♣ @╕Θ║½♦< ♦<
    ♥eâ ♫☻ ≤ , ☺↨í3░♥¶☼↕ p P ☺╣ε ▀‼ └♣☻♠
    ♥eâ ♫☻ X≤ , `╕◄ ╪☼4á ↑☼↕ ëε ┐‼ ☺╢τóôW(£p¿║½♦<
    ♥eâ ♫☻ T° , ►₧'█ö╟Eÿ0 É╟◄►☺H§Lα ☼↕ y∩☺▼‼ ☻╢↓π║½♦< < Ç ║½♦<
    ♥eâ ♫☻ ╪° ,♥Éû♫/►₧'▐ög₧ÿp$☺░╕◄ ♦♠♦8)=@iU⌂↕♣ ↔☺► ♥ë∩☺┐‼╚║½♦<
    ♥V
    ♥eâ ♫☻ \∙ , ëε ƒ‼ å≈╠òτgÿ►♠ P╕◄ ♦♀ ╕♦7α ☼↕ ► ╜║½♦<
    ♥eâ ♫☻ ¶√ ,╜◄☼☺╫±2É☼1∩↕ └♥ ∙ε ∩‼ α☻☺╓☼▀►₧ÿLÆ╟⌐Ü╨w½♦< ♦< < <
    ♥eâ ♫☻ @√ ,♣└╛◄ Ç ♂xz ╤ïd∩↕‼0y♠@
    ╔ε♣»‼‼╨:
    ♥eâ ♫☻ ≡√ ,╕↓æù+ò≡<♣0º◄ @ ♣°',░┬]☼↕☼É:♦p ♠↓φ♥_‼ └▼♣E∙
    ♥eâ ♫☻ |² ,► ☻9ε☺▼‼☺☻û♦♠∩►¥τ⌠Éû≡Ö@ ☻╚*+ §:∩↕ └ ► ╟║½♦<
    ♥eâ ♫☻  ,½◄ ░ ☻╫£▼└4Å↕ ░☻ 0 ☺Θε☺☼‼ ╨♣☻ò²ƒ►₧hJôGtÖPW♠ e║½♦< <
    ♥eâ ♫☻ î  , ò≡┴♀αá◄☺α ↕↑G"☻ñm»↕(α╛Θφ♦ƒ‼♀ +♫5°
    Ç☺◄9φ
    ♥eâ ♫☻ Σ  ,(^ôτ╚öPº◄ ░ ☼╚r#▒│fO↕↑Çt@☺☼Θφ♠ ‼§►S
    ≡¿◄ Ç ◄ê !"jh▀↕"►╖
    ♥eâ ♫☻ < ,‼Å►£X{ö╫°Æα╕◄ @ ↑↨█.╥SdO↕►Ç╙♣Ç ►Θφo‼↓ å¶⌡≤♠║½♦<
    ♥eâ ♫☻ └ ,♂`/♫ò⌠↔⌂►¢Φàìù╔Æα¬◄ P ¶╚ç"Γ║g⌂↕↔á±╣ε/‼↨É3║½♦<
    4♂f ♫☻ p ,Ç ♀ëε♦┐‼♫▬♥¶Å►¢ÿdöτ┤Æ Q♦É╕◄ P HQ▲ßD`┐↕‼►k♣└ ░║½♦<
    ►ƒ►¢ù▄ùç┐æ≡↨☻Ç╕◄ ♥ê
    ♥eâ ♫☻ ,♂☻0 ♦╔ε☺⌂‼☻ ♥µ
    )ε♠⌂‼▬p^♀F ◄?►¢╚Mò↨öÆpyƒ‼☺≡♣♥û§  ►¢╖∞öG\ÆÉs►╬◄ p ♫G⌡*qù║½♦< ╪=Ç0Hë║½♦<
    ♥eâ ♫☻ ╤♣ , ╠║½♦<

    ♦☼‼
    ♥eâ ♫☻ ╨╤♣ ,?↕♥╨↨☺ ♣ ▀‼$0y♀Φ$← ►ù9 ÅX]ï0 ☻↕╒◄ 0 ☻╪HB≡IU½║½♦<
    !☺ƒ‼♥☻Φ'
     ►ù¿4è╢▌ïÇΩ
    ♥eâ ♫☻ ¼╥♣ ,☺p ◄╣♂▼♥Éx⌂↕40▐ ♥‼‼→Ç1☼↨▼►ù╕Uïτ↓ï┴/☼☻╡◄B║½♦<
    ♥eâ ♫☻ ╪╥♣ ,╬◄☺@ ¶I♫▲#┴{ ↕4±
    ♥eâ ♫☻ 0╙♣ ,☺╩↨▓▀◄☻P §ÿ▓↓♦-é▼↕:☺◄ Ç♥§z ↨?‼?└╪4↨┐►ùÿÅü▬ în║½♦<
    ♥eâ ♫☻ ê╙♣ ,ïτ>ï░T♦╥µ◄ @ ♂╕n!á√a ↕♀≡G♥ ♂z ♦⌂‼♂`3♂H82▬┐►ùÿ|▲║½♦<
    ♥eâ ♫☻ ♀╘♣ ,§▼►ùêÉâº♠îaÇ‼├#◄☺á §╕╜↑Ts|ƒ↕<1& ↕┐‼6`┴↕êî▓║½♦< <
    ♥eâ ♫☻ 8╘♣ ,↑u§Å►ùÿVæx↔îÉC'◄ É
    ╫α+üºnÅ↕▬át♦≡☺
    ♥eâ ♫☻ ≡╒♣ ,1ò_↕cR☻→α↔←@∩‼a◄É↨J▬6 ►ÿH!î&│ï─µD$╔◄♣@ ↑τ┘3VW║½♦< ‼τ║½♦<
    ♥eâ ♫☻ ∟╓♣ ,)☻╥à»↕&@φ‼¬▼‼/‼%áí►j♦<
    ♥eâ ♫☻ $╫♣ ,P─J◄ ☺g╧K ♥→☼↕ P☻ ☺Z▼ ┐‼ ►☺☺╣£♀»►Ü↑!ûXáÅ&║½♦<
    ♥eâ ♫☻ P╫♣ ,ñÅÇ+☻¶2◄ ♥â♠╚ 6≡eL»↕♦Ç$☺╨ ♣╩▼☻☼‼♦p∟♦∙ä
    ♥eâ ♫☻ |╫♣ ,ò'╦Åpú♠tI◄ P ♀ÿ~1aínO↕‼░¬♠` ♂
    ♥eâ ♫☻ ¿╫♣ ,↑Cò╫íÄ░L♦ä4◄ @ ♫(T-@▄Q▼↕♀╨U♥≡ ♫
    ▼♦Å‼
    ♥eâ ♫☻ ╘╫♣ ,Xö╟│ìα1☻╘L◄
    hà&╨oGO↕♣ #☺└
    ♥eâ ♫☻ ╪♣ ,
    ╖÷+",⌂┐↕% Ü P ☼z▼ ▀►Ö°fò↨┬ÄÇσ◄─{◄☺≡ ½♦<
    ♥eâ ♫☻ ä╪♣ ,☻⌐x (3:p0α♣0∩↕ P☺ Θφ ┐‼ ☺û♦
    ♥eâ ♫☻ , ♥⌐∞☺▀‼♦`☺Ñ▼►ù9Xéτ▌ÄP∟☺Ç£◄ ♥╟└0≡LM ↕♥᧠╨▓║½♦< ½♦< ∞ Åô║½♦<
    ♥eâ ♫☻ T ,◄ ☻╨ 7┴N ☼↕ ↓φ ⌂‼ ┐►ÿ6Uzù┤Æ@♦ á║╖║½♦<

    ReplyDelete
  27. Has anyone found a way to change user data yet?

    ReplyDelete
  28. Haha this is awesome. I work for a fitness company that sells the bodybugg V3 and the SP and it'll be interesting to give this a shot to see if it works. And if I nuke my bugg, meh, I never use it anymore anyways.

    ReplyDelete
  29. Thanks for this fix - I hope :)
    I got it to work seemingly in Windows XP (I followed all of the fixes in the comments as they applied to my case). Then I tried it and appeared to get success:

    C:\Python26>python bmhack-z718b.py --fromSerial=COM5 --clear
    PIL library not found. ToImage() func unavailable THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
    NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
    ...............................................................................................................................................................................................................................................Cleared logged sensor data from device

    But now I put the device back on my arm, and my digital display gives me exactly the same numbers for "TRIP" as it did before I cleared it (I did not wear the device yesterday, so I cannot tell the 'yesterday' display.

    I tried to do the whole memory clear thing again, got the same reply from python (but with only 1 dot instead of a lot before the "cleared log sensor"

    Will let you know in a few days if the memory was really cleared, or if it will fill up (as it should in a few days if not cleared...)
    Bye for now!

    Savayreon

    ReplyDelete
  30. I need some help. I am very new to all of this but would love to be able to use my BodyBugg again without the subscription. I have downloaded the 3 things it suggested and loaded them but when I type C:\python26\python.exe bmhack.py into the command line it tells me I have a syntax error with a little arrow point up at my : after the C. What am I doing wrong. Please help!!!

    ReplyDelete
  31. This comment has been removed by the author.

    ReplyDelete
  32. I put the ser.close() as directed above, and still no love, here is the output:

    C:\Python27>python.exe bmhack-z718b.py --fromSerial COM6 --clear
    THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
    NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
    Traceback (most recent call last):
    File "bmhack-z718b.py", line 1179, in
    sys.exit(main())
    File "bmhack-z718b.py", line 1100, in main
    ser = OpenSerial(dopts["--fromSerial"])
    File "bmhack-z718b.py", line 88, in OpenSerial
    ser.open()
    File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 56, in open
    raise SerialException("could not open port %s: %s" % (self.portstr, ctypes.W
    inError()))
    serial.serialutil.SerialException: could not open port COM6: [Error 5] Access is
    denied.


    any ideas?

    Dan

    ReplyDelete
  33. Thanks so MUCH for all of the posts. I have a Vista machine and I am able to clear and save data off my bodybugg. It's still synching with my watch display. I did have to follow all of the "extra" directions in the comments even though my errors were different.

    All in all it WORKS. Thanks so much. I'm not giving Body Media any more money than I already have with the armband/display.

    ReplyDelete
  34. Hi All,

    I managed to get the code working with Mac OS X but I am hitting the same problem as some people above:

    AssertionError: Unknown record ID 0 at offset 696

    The author did not respond to my email (yet) ... any ideas on the status of this project? It appears abandoned.

    ReplyDelete
    Replies
    1. This may be because you're using a slightly different device than the script was built for. I had the same issue with the BM Fit. I was able to fix this problem by changing this line:

      RecPack[19] = 9
      to
      RecPack[19] = 13

      which adjusts the data padding for records.

      Delete
  35. I was able to get this to work on Windows 7 Ultimate 64-bit. However, I would really like to know what all the spreadsheet columns refer to. EE refers to Energy Expenditure, but the entries need to be divided by a number (120, 128 have been suggested by some, which appears somewhat reasonable), but there is no solid evidence of what the number should be. The project appears to be dead in terms of program development. I am hoping to write a more intuitive windows program, but I am overworked as it is, so time is a big problem.
    Buying this device and then paying a subscription for it is like buying a car then leasing it at the same time. It's ridiculous. I refuse to cooperate!

    ReplyDelete
  36. To download this onto a mac, I was following the directions from Jan 25, 2010 03:55PM...


    I went to website below to download pyserial 2.5-rc2, but I don't see it on there to download.

    http://pypi.python.org/pypi/pyserial

    any help?

    ReplyDelete
  37. This has been an interesting exploration. I think this bears being summarized in one place, so here are the key factors that have enabled this to run for me:

    * I am using Windows 7.
    * I installed Python 2.6.2
    * I installed Numpy 1.3.0 (numpy-1.3.0-win32-superpack-python2.6).
    * I also had to download and install pyserial 2.5 (pyserial-2.5-rc2).
    * I took the advice above to add ser.close() above ser.open() in the bmhack.py file script.
    * I got the garbled nonsense output shown above, which seemed to have something to do with the script timing out, so I increased the timeout listed in this line from 3 to 10:
    >> def ReadSerial(ser, minLen, timeout=3.0, maxLen=2**15): <<
    * If you're downloading data from the BB via the USB, you need to include your port in the format:
    >> python bmhack.py --toCsv=bodybugg.csv --fromSerial=COM5 <<
    * I determined my port via:
    .. Devices and Printers
    .. BodyMedia Armband Mini USB (double-click)
    .. Select and click Properties
    .. Serial Port displayed next to the device name

    I was able to generate a cPickle file and a .csv.

    Now, to make sense of this data... ?????

    ReplyDelete
    Replies
    1. Thank you so much for your post. You helped me fix my problem by compiling all the changes needed.

      Delete
  38. Upon entering python bmhack.py --toCsv=bbdata.csv my output is this

    PIL library not found. ToImage() func unavailable
    THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
    NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
    Traceback (most recent call last):
    File "bmhack.py", line 1179, in
    sys.exit(main())
    File "bmhack.py", line 1100, in main
    ser = OpenSerial(dopts["--fromSerial"])
    File "bmhack.py", line 88, in OpenSerial
    ser.open()
    File "build\bdist.win32\egg\serial\serialwin32.py", line 39, in open
    serial.serialutil.SerialException: Port is already open.

    ReplyDelete
    Replies
    1. I have the same error... Cant figure out whats wrong

      Delete
  39. For "PIL library not found"

    i have downloaded it here

    http://www.pythonware.com/products/pil/

    but now i get
    "No sensor data is currently on the device (or dump)" assertion error, but im sure that data is on device. Did anyone had a same problem?

    ReplyDelete
  40. I got this to work on windows7 using active pyton 2.7. Installed the ser.close() into the z718b file and things work well.

    Does anyone have a dictionary as to the output colums meaning?

    ReplyDelete
  41. Is there any updated site where the process is streamlined for Vista users? Looks like people are able to extract the cs but have not made a correlation to the output columns and what they mean.

    I know that BoddyBug and BodyMedia are made by the same manufacturer, maybe you could cross refference.. I found this: http://bodybugghacks.blogspot.com/

    ReplyDelete
  42. can someone please tell me exactly what to do after i have done all the downloads and installs. nothing that i type is getting me any results.
    arblackm@yahoo.com

    ReplyDelete
  43. I should have noted that I am using Windows 7 32 bit. Good luck!

    ReplyDelete
  44. I'm suprised to find out this still works 9/28/2012 but I got the clear command and tocsv command working on my bodybuggv3 on windows 7x64.

    I used
    --python 2.7
    --latest version of Numpy.
    --bmhack Version z718b
    --pyserial
    --added ser.close() to the script

    the commands I used were

    cd C:\python27\

    python bmhack.py --toCsv=bodybugg.csv --fromSerial=COM9

    python.exe bmhack.py --fromSerial COM9: --clear


    everything you need to get this to work is in these comments.

    ReplyDelete
  45. could someone please put up a video of how to do this im having a hard time following. i cant afford the bodybugg subscription. i get to this spot.

    PIL library not found. ToImage() func unavailable
    THIS CODE IS DECLARED BY THE AUTHOR TO BE IN THE PUBLIC DOMAIN.
    NO WARRANTY EXPRESSED OR IMPLIED OF ANY KIND IS PROVIDED.
    ERROR: Must provide either --fromSerial or --fromDump or other --from* packet source
    for help use --help

    Traceback (most recent call last):
    File "C:\New Folder\Tools\Scripts\bmhack.py", line 1179, in
    sys.exit(main())
    SystemExit: -2

    ReplyDelete
  46. Just bought an older used bodybuggSP and after adding ser.close() to the script it works like a charm, thanks!

    ReplyDelete
  47. somebody know how to flash a bodymedia fit link (model ab185 or model MF) to work with sensewear software 7???

    ReplyDelete
  48. Don't add ser.close(), just delete ser.open(). The serial port is already open because recent versions of pyserial open it during initialization.

    ReplyDelete