ElectricMotorcycleForum.com

Makes And Models => Zero Motorcycles Forum | 2013+ => Topic started by: PhreaK on September 17, 2015, 08:32:58 PM

Title: Log file parser utility
Post by: PhreaK on September 17, 2015, 08:32:58 PM
After a few cursory looks at the support logs that you can extract from the bikes with the Zero app + bluetooth connection, I thought I'd pop together a little utility to provide a nicer option than just viewing through a hex editor. It's still early days, however I've started to build out a map of the file and log entry format (https://github.com/KimBurgess/zero-log-parser/blob/master/log_structure.md) based on the logs from my bike, and those I've been able to pull from the forums so far.

I'll keep pushing updates to a GitHub repo (https://github.com/KimBurgess/zero-log-parser), with the goal of building out some tooling to translate the *.bin files from the app into a nice, human readable form to assist your own diagnostics and curiosity. If I get the time, I may even end up rolling this into a free service you can email your logs to directly from the app and it will shoot you back readable versions... maybe.

If you have any suggestions or improvements, feel free to fork the repo and submit pull requests, or if you're not a coder, log an issue.

For those looking to help out, I'd love to get my hands on some more logs so I can figure out how the file structure clicks together. Feel free to drop me a PM or shoot them to contact@kimburgess.info. Also, if anyone has already dived into this in any detail, it'd be great to hear from you too.

P.S. I know there's some awesome tools (https://hollywoodelectrics.com/product/diginow-data-reaper-dongle/) out there already and you can hook into the TTL / RS-232 line on the OBD port (which btw, if anyone has concrete info on what it is so I don't need to chase down a meter / scope to test, I'd love to know (http://electricmotorcycleforum.com/boards/index.php?topic=4940.msg33719#msg33719)). This is simply a way to get at least a little bit of info, without the need for any external hardware in lieu of official tools from Zero. Plus, it a fun nerd puzzle to put together.
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on September 17, 2015, 09:29:13 PM
Nice, thank you; especially for writing out the reverse-engineered format rules. If I find a reason to use it, I'll probably contribute.
Title: Re: Log file parser utility
Post by: Patrick Truchon on September 18, 2015, 06:35:44 AM
Cool tool!  I just emailed you a copy of my bin file along with the output that your script generated.  Hope that helps a bit...

Cheers!
Title: Re: Log file parser utility
Post by: PhreaK on September 18, 2015, 04:38:36 PM
To everyone that's been sending me logs so far - thank you, you're awesome. After having a little ah-ha moment and realising all the numeric values are little endian and the timestamps are local rather than UTC, I've got the log entry message format (https://github.com/KimBurgess/zero-log-parser/blob/master/log_structure.md#log-entry-format-shared-by-mbb-and-bms) sussed. In addition to the standard string messages, there's a whole array of entry types to now start decoding. This is going to be one huge, entertaining rabbit hole...
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on September 18, 2015, 11:21:35 PM
That's great! Yes, more data samples always challenge in a good way.
Title: Re: Log file parser utility
Post by: Justin Andrews on September 19, 2015, 01:41:39 AM
What if I was to pull logs off my bike using my Data Reaper, and via the app at the same time?
Would that be useful?
Title: Re: Log file parser utility
Post by: PhreaK on September 19, 2015, 04:53:14 AM
Yes, that would be incredible. Then I can line up some more of those message types.


Sent from my iPhone using Tapatalk
Title: Re: Log file parser utility
Post by: Christian J on September 19, 2015, 11:07:38 AM
Hi Kim,

I added some of my logs to this post.

I was unable to parse them (used python 3.5). Maybe you can look into this.

Quote
>python zero_log_parser.py 538SM5Z36ECG03915_MBB_2014-10-13.bin
Traceback (most recent call last):
  File "zero_log_parser.py", line 81, in <module>
    parse_log(log_file, output_file)
  File "zero_log_parser.py", line 63, in parse_log
    if ord(b) == ENTRY_DELIMITER:
TypeError: ord() expected string of length 1, but int found

Thanks for your effort. Hopefully one day we can set this up as a web service - that would be perfect.
Title: Re: Log file parser utility
Post by: PhreaK on September 19, 2015, 08:43:41 PM
Thanks Christian! Ignore that python script for the moment. That version was just a quick stub and some straight bin -> ascii / utf-8 translation to make seeing what was there simpler. I'm focussing on documenting as much of the file structure as possible first, then I'll roll that into tooling.
Title: Re: Log file parser utility
Post by: Justin Andrews on September 20, 2015, 09:49:08 PM
Phreak, here are my logs and the Data Reaper log (in two parts)
Title: Re: Log file parser utility
Post by: Justin Andrews on September 20, 2015, 09:49:40 PM
Part 2 of the Data Reaper log from the MBB
Title: Re: Log file parser utility
Post by: PhreaK on October 03, 2015, 06:59:01 PM
For those that have run this already - should be a little more useful info in those decoded logs for you now. The script is probably still buggy as hell, and may break a lot, but I'll keep chipping away as I get time.

I was running through some ideas as to how this could be rolled into a web service, mainly for my own entertainment (I'm not a web dev, but sort of interested in learning a little bit of that world). Out of interest, what would be peoples reaction to the following:
Title: Re: Log file parser utility
Post by: Patrick Truchon on October 03, 2015, 11:12:58 PM
Very nice work!  I've been parsing the same file with your different versions since September 17th, and every time, more gets revealed.  Pretty cool!

As for the web service, I don't think I would personally use it but others might.  I know I'll be keeping your script in my collection very preciously...

Looking forward to more updates.  Keep up the excellent work!
Title: Re: Log file parser utility
Post by: pablogomez on October 12, 2015, 06:52:00 PM
Hi I send to you the logs, Another question is how can I know the version I'm in?
Title: Re: Log file parser utility
Post by: Patrick Truchon on October 13, 2015, 08:00:15 AM
Hi I send to you the logs, Another question is how can I know the version I'm in?

Hello pablogomez, if you download his script (https://github.com/KimBurgess/zero-log-parser) and run it on your file, you'll get a text file with more than a thousand lines.  Yours starts with this:

Code: [Select]
Serial number      2014_mbb_0386e1_00235
VIN                538SD5Z28ECB03553
Firmware rev.      36
Board rev.         1

Hope this helps.

I'm not sure if Kim needs anymore stand alone bin files.  I think what he's after now is files from people that have the Diginow Data Reaper Dongle (https://hollywoodelectrics.com/product/diginow-data-reaper-dongle/) so he can compare the input and the output.
Title: Re: Log file parser utility
Post by: Burton on October 13, 2015, 08:41:02 AM
I'm not sure if Kim needs anymore stand alone bin files.  I think what he's after now is files from people that have the Diginow Data Reaper Dongle (https://hollywoodelectrics.com/product/diginow-data-reaper-dongle/) so he can compare the input and the output.

Something tells me he doesn't even need that anymore ;)

But if he does I own a Diginow Dongle if you need more PK
Title: Re: Log file parser utility
Post by: pablogomez on October 13, 2015, 10:21:25 PM
Should I go to my dealer and update ???
Title: Re: Log file parser utility
Post by: Patrick Truchon on October 14, 2015, 12:03:33 AM
Should I go to my dealer and update ???

Have a look at this thread (http://electricmotorcycleforum.com/boards/index.php?topic=5068.0).
Title: Re: Log file parser utility
Post by: NoiseBoy on October 14, 2015, 03:13:33 AM
Took me a while but I figured out how to run the script.  Funny Story.  I downloaded the script from GitHub and sent the logs to my Fedora laptop because I don't have Python on my PC.  Ran it and kept getting an error about HTML.  I was like "What is this POS script Kim is peddling and why is it outputting to HTML".  After a while I spotted it said Line 4 so I opened the script to have a look.  I had only downloaded the script of the actual GitHub page rather than the parser script  ;D ;D  It worked fine after I downloaded the right thing. lol

Only comment is that the txt file looks great in GEdit but when I sent it to my Windoze PC it lost all the formatting.  Maybe its just a notepad thing.

The bad news is that my bike is limiting battery current quite heavily below 65% SOC.
Title: Re: Log file parser utility
Post by: PhreaK on October 14, 2015, 03:33:44 PM
It's nothing you're doing wrong, welcome to the wonderful world of cross-platform line termination incompatibility (https://en.wikipedia.org/wiki/Newline#Common_problems). That script will dump it out in the correct format for the platform your run it on. If you shift to to another one, you'll need a text editor that handles all this messyness. I highly recommend Sublime (https://www.sublimetext.com/).
Title: Re: Log file parser utility
Post by: MostlyBonkers on March 18, 2016, 03:19:08 AM
Hi Kim,

Firstly, thank you for creating this utility. I've been using it a fair bit recently and have even managed to help out a couple of other folks on the forum with it too.

One thing I've noticed is that I don't seem to get the latest entries in the log file output. They seem to be a few days old at least. Have you noticed this behavior? Is it a problem with the export from the bike?
Title: Re: Log file parser utility
Post by: LeftieBiker on March 18, 2016, 05:14:31 AM
   I have to have my logs translated into something more readable rather urgently, and Zero hasn't responded to my requests for info (see the thread '2015 Sr Demo with Multiple Errors). Can I email them to someone here for conversion?
Title: Re: Log file parser utility
Post by: MostlyBonkers on March 18, 2016, 08:14:44 AM
By all means send them to me again Leftie. Somehow I missed your other topic!
Title: Re: Log file parser utility
Post by: MostlyBonkers on March 18, 2016, 11:22:29 AM
By the way, I got in touch with Zero to see if they would release their own tool. Worth a shot, I thought. Here is the response:

Dear Tom,
 
The Zero Mobile App Log Decoder is a proprietary tool that we only make available to authorized dealers and distributors. We appreciate the input about creating a web service for decoding these logs, but at the present time we encourage our owners to work with our dealers to review the details of such logs.  Our dealers and distributors are in the best position to provide support for any questions and make any necessary repairs that might come from a log review.
 
With kind regards,
 
Danny van der Horst
Logistics & After Sales Manager Europe

****************

That's the wrong attitude, IMHO. What's the harm in making it public? Are they afraid of a flood of complaints about every single error? Surely only the most obsessive people would gripe...
Title: Re: Log file parser utility
Post by: LeftieBiker on March 18, 2016, 12:20:46 PM
   As a counter-argument, when I emailed the first log download to Zero, I got a response saying that the info had also been sent to the dealer from whom I bought the bike. They were subsequently of very little help, with the tech there saying that the dealership just installs accessories and adjusts belts and tire pressures. (This dealership is just a very short distance from the Zero factory, BTW!) I haven't heard anything from them since the tech said the bike should be brought in, nor have I heard back from Zero about the latest logs, aside from the automated email they generate. I was also steered to a much better dealer by a member here, and while that dealer's initial email response was helpful, he ended up saying that the bike needed to be looked at, and didn't respond at all when I sent the BMS log. So while Zero's argument may work in theory, in practice it really hurts those of us who don't live near a competent dealer. If they want to keep the software proprietary, then they need to be much more responsive themselves.
Title: Re: Log file parser utility
Post by: MrDude_1 on March 18, 2016, 08:32:16 PM
It's nothing you're doing wrong, welcome to the wonderful world of cross-platform line termination incompatibility (https://en.wikipedia.org/wiki/Newline#Common_problems). That script will dump it out in the correct format for the platform your run it on. If you shift to to another one, you'll need a text editor that handles all this messyness. I highly recommend Sublime (https://www.sublimetext.com/).
lol, yeah.

Might be worth it to add a line to change all the line breaks to CR-LF... Then it will work on any PC, Android, Linux, etc... 
Title: Re: Log file parser utility
Post by: Kocho on April 25, 2016, 06:57:12 AM
When I email and parse the log file it appears it is truncated. Last entry is from half a year ago... Any ideas?
Title: Re: Log file parser utility
Post by: MostlyBonkers on April 25, 2016, 05:37:45 PM
Just keep trying. I've had odd results like that. The last couple of times I tried I got some up to date entries.
Title: Re: Log file parser utility
Post by: Kocho on April 25, 2016, 05:39:59 PM
Do you mean email myself the logs again first or just parse them again?
Title: Re: Log file parser utility
Post by: MostlyBonkers on April 25, 2016, 05:42:36 PM
Oh, sorry, just keep exporting and emailing. I have a suspicion that the bike continues from the last time the logs were exported up to 128k of data. Worth trying and do please let us know if you get more recent entries next time.
Title: Re: Log file parser utility
Post by: Kocho on May 05, 2016, 07:17:46 PM
It does not seem to work this way. Just downloaded the "bike" logs 3 times in a row and each time I get the same 269KB or so file with the same contents each time. Each time the same 3 months of data are covered - 10/2015 - 12/2015. It is hard to make heads or tails from the decoded logs too - looks like at some point some external chargers were connected to the bike, that at some point the battery hi-temp protection kicked-in, that it has been ridden hard to a point where the overheat protection had kicked-in, etc. And "PL536 Read Attempts Failed" occurs multiple times, suggesting some issue with the TI BMS unit (or what it is measuring).

I got an appointment to get the bike over to the dealer, probably next week, just curious to learn more myself and possibly give them hints on what to look at/for.

Oh, and the log parser seems to get confused by the heading info (model and firmware revision section at the top of the log) for the BMS logs but is fine for the Bike logs.

The parser gives me some errors in part-way through parsing the BMS logs too, so something is possibly not right with the parser too. But I am looking at the .bin files directly for the above-mentioned dates.

Oh, sorry, just keep exporting and emailing. I have a suspicion that the bike continues from the last time the logs were exported up to 128k of data. Worth trying and do please let us know if you get more recent entries next time.
Title: Re: Log file parser utility
Post by: Kocho on May 05, 2016, 07:19:40 PM
Oh, and whether I choose to download the "Bike log" only or the "Bike and BMS" logs from the Zero app, in both cases I get the same size file, even though it takes 10 times longer to download from the bike to the phone the version with the BMS...
Title: Re: Log file parser utility
Post by: MostlyBonkers on May 06, 2016, 03:36:22 AM
It's not perfect. Phreak mentioned an issue with the parser that sometimes results in just receiving the header in the output and no log entries. I wonder, how big are the output files? It makes me think that the utility is exiting prematurely for some reason. The data might be exported, but not all of it is being converted.

Try sending the logs to Zero and ask your dealer to send you the output. Zero should send the results to the dealer. They might say no, but it's worth asking. Don't ask zero for the output directly because they'll definitely say no.  Make sure you email yourself at the same time and keep the bin files. Just in case you do get the output, post the bin files and Zero's output here. At some stage in the future, either Phreak or someone else with coding skills might be able to make use of them to spot and fix some bugs.  Time is the big issue. I'm amazed that Phreak got so far with his utility.

Otherwise, just don't bother and leave it to the dealer. :-)
Title: Re: Log file parser utility
Post by: ges on May 14, 2016, 02:13:39 AM
I've tried the parser, but unfortunately I only get the header with Serial number, VIN, Firmware rev., Board rev. and Model. The parser is failing with the following information:

4172 entries found
Traceback (most recent call last):
  File "zero_log_parser.py", line 257, in <module>
    parse_log(log_file, output_file)
  File "zero_log_parser.py", line 229, in parse_log
    (length, entry) = parse_entry(log, read_pos)
  File "zero_log_parser.py", line 78, in parse_entry
    raise ValueError('Invalid entry header byte')
ValueError: Invalid entry header byte
Title: Re: Log file parser utility
Post by: MostlyBonkers on May 15, 2016, 02:00:39 AM
I've seen that a couple of times ges. Just try extracting the logs again, possibly after some more activity.
Title: Re: Log file parser utility
Post by: ges on June 04, 2016, 12:12:41 AM
Tried the parsing again today but still struggle with "ValueError: Invalid entry header byte" from the BMS file.
Title: Log file parser utility
Post by: PhreaK on July 12, 2016, 10:25:35 PM
Hi guys, haven't had a chance to post here / have a look at this for a while. It was summer so most spare time was spent out on a bike. That being said it's now back to crappy, cold, wet winter in my part of the world... so updates, yay!

Thanks to an awesome pull request from rDacted (http://electricmotorcycleforum.com/boards/index.php?action=profile;u=7629) (who cracked an encoding used on the event entries) there's an updated parser that provides a bunch more useful info. It now also handles situations where you're log file wraps around the maximum log length and starts overwriting itself.

This is successfully decoding most of the sample logs I have on hand. I do have two that are breaking it though. Not sure if this is corruption of the logs themselves or something still missing in the log file format. If you happen try your decoding your log file and it does't work with the current version it'd be awesome if you can drop me a copy of the *.bin and when I have a few I'll see what I can do to unbreak it.

Oh also, I know a few people have been trying this on the BMS logs too. Currently this is untested and will likely (/almost certainly) not work.
Title: Re: Log file parser utility
Post by: giacomo on July 13, 2016, 04:56:10 AM
Hello,  I  tried the latest code on my old logs but I get the following error =  type error: type str doesn't support the buffer API. I am using python 3.3. It looks like the data.find() search for string instead of bytes...
Any idea? thanks

Sent from my A0001 using Tapatalk

Title: Re: Log file parser utility
Post by: PhreaK on July 13, 2016, 11:33:23 AM
Try that now. I was doing something stupid that python 2 let me get away with when it shouldn't have.
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on July 13, 2016, 11:35:40 AM
Thanks for keeping at this!
Title: Re: Log file parser utility
Post by: MostlyBonkers on July 13, 2016, 11:44:48 AM
Thanks from me too. I've found it very useful on a number of occasions.  It puts power in the hands of the customer and helps keep everyone honest. It has also taught me a few things about my bike. :-)
Title: Re: Log file parser utility
Post by: giacomo on July 19, 2016, 09:14:54 PM
Try that now. I was doing something stupid that python 2 let me get away with when it shouldn't have.
it works like a champ now, thanks

Sent from my A0001 using Tapatalk

Title: Re: Log file parser utility
Post by: Swiebo on August 25, 2016, 11:01:59 PM
Tried to decode the log file of my DS, but got this error:

Code: [Select]
3371 entries found
Traceback (most recent call last):
  File "zero_log_parser.py", line 569, in <module>
    parse_log(log_file, output_file)
  File "zero_log_parser.py", line 531, in parse_log
    f.write('{0:18} {1}\n'.format(k, v))
  File "/usr/lib/python2.7/codecs.py", line 706, in write
    return self.writer.write(data)
  File "/usr/lib/python2.7/codecs.py", line 369, in write
    data, consumed = self.encode(object, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xbd in position 19: ordinal not in range(128)

Title: Re: Log file parser utility
Post by: PhreaK on August 30, 2016, 05:44:10 PM
Hey Swiebo, can you drop me that log file in a PM?
Title: Re: Log file parser utility
Post by: kashography on October 08, 2016, 03:39:44 AM
Thanks a lot for this tool! With my first export it worked perfectly. for the second i get also this:
Code: [Select]
8483 entries found
Traceback (most recent call last):
  File "zero_log_parser.py", line 569, in <module>
    parse_log(log_file, output_file)
  File "zero_log_parser.py", line 541, in parse_log
    (length, entry) = parse_entry(event_log, read_pos)
  File "zero_log_parser.py", line 101, in parse_entry
    raise ValueError('Invalid entry header byte')
ValueError: Invalid entry header byte

i will try with the next export another time. If you need the file to debug: https://www.dropbox.com/s/0wvjtc1pnp0izxj/kw2.bin?dl=0 (https://www.dropbox.com/s/0wvjtc1pnp0izxj/kw2.bin?dl=0)
Title: Re: Log file parser utility
Post by: SM on October 08, 2016, 11:19:33 AM
Could you share the log "decoder"?  and any instruction on how to use. Thanks.
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on October 08, 2016, 11:52:23 AM
Could you share the log "decoder"?  and any instruction on how to use. Thanks.

That's literally what the first post on the thread is about:
http://electricmotorcycleforum.com/boards/index.php?topic=5020.msg34350#msg34350 (http://electricmotorcycleforum.com/boards/index.php?topic=5020.msg34350#msg34350)

It's a free / open source Python script to run on the binary log file to produce a text log version.
Title: Re: Log file parser utility
Post by: GdB on October 08, 2016, 03:28:19 PM
Would it help for decoding to get the log from a  :o rider (me) that always hits the speed limiter and runs in thermal protection mode everyday on my commute?
Title: Re: Log file parser utility
Post by: ctrlburn on October 09, 2016, 06:05:46 AM
If you open "zero_log_parser.py" in notepad (or your favorite editor) it should look like this:
#!/usr/bin/python
'''
Little decoder utility to parse Zero Motorcycle main bike board (MBB) and
battery management system (BMS) logs. These may be extracted from the bike
using the Zero mobile app. Once paired over bluetooth, select 'Support' >
'Email bike logs' and send the logs to yourself rather than / in addition to
zero support.
Usage:
   $ python zero_log_parser.py <*.bin file> [-o output_file]
'''
....

If it looks like this:

<!DOCTYPE html>
<html lang="en" class=" is-copy-enabled is-u2f-enabled">
  <head prefix="og: http://ogp.me/ns# (http://ogp.me/ns#) fb: http://ogp.me/ns/fb# (http://ogp.me/ns/fb#) object: http://ogp.me/ns/object# (http://ogp.me/ns/object#) article: http://ogp.me/ns/article# (http://ogp.me/ns/article#) profile: http://ogp.me/ns/profile# (http://ogp.me/ns/profile#)">
    <meta charset='utf-8'>
   
....

THEN 
Instead of right clicking on the https://github.com/KimBurgess/zero-log-parser (https://github.com/KimBurgess/zero-log-parser) github link to the file, left click and open the file - select the contents COPY and PASTE over the contents of your "zero_log_parser.py" file and save.
Title: Re: Log file parser utility
Post by: steveg on November 19, 2016, 06:23:34 AM
I've seen that a couple of times ges. Just try extracting the logs again, possibly after some more activity.

I have a log file that is exhibiting this behavior. To fix it I added code before the parse_entry loop that checks to be sure the byte at read_pos is actually an entry header byte. If it's not I just keep reading bytes until I find the entry header and return whatever the read byte count is as a new read_pos. From there the parse_entry loop works as expected, although in throwing away the bytes I loose an entry off the top of the log (not really a big deal). I can share this code if you want.
Title: Re: Log file parser utility
Post by: MostlyBonkers on November 19, 2016, 02:27:35 PM
Nice one Steve. Please do share, I'm sure it'll save people time.
Title: Re: Log file parser utility
Post by: steveg on November 20, 2016, 01:26:34 PM
Nice one Steve. Please do share, I'm sure it'll save people time.

Submitted a pull request on github. It's still messy, I didn't add anything to update the entry count so it overruns at the end.
Title: Re: Log file parser utility
Post by: PhreaK on January 19, 2017, 03:44:58 PM
Hey guys, I've just sold my SR. I'll likely remain non-Zero until either my charging options, or achievable range changes. I'm about to move and unfortunately what's possible does not align with where I'd like to ride for fun, and need to ride for transport.

With that being said, it's unlikely I'll be make any further updates to this.

So that the project is not orphaned, is there anyone who would be interested in becoming the new maintainer of this on GitHub?
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on January 20, 2017, 02:28:45 PM
Hey guys, I've just sold my SR. I'll likely remain non-Zero until either my charging options, or achievable range changes. I'm about to move and unfortunately what's possible does not align with where I'd like to ride for fun, and need to ride for transport.

With that being said, it's unlikely I'll be make any further updates to this.

So that the project is not orphaned, is there anyone who would be interested in becoming the new maintainer of this on GitHub?

Ah, that's too bad. I'm interested, although I'd not be great at improving the decoding itself. I guess the main thing would be building some tooling around it and taking in bug reports and other issues.
Title: Re: Log file parser utility
Post by: Keith on January 20, 2017, 09:02:06 PM
Screenshots from the Zero log file visualizer I've been working on. Here it is https://goo.gl/GGDcgr (https://goo.gl/GGDcgr) You'll need a Google login to use it, but gmail isn't required. Your Zero wants to tell you the distance, speed, charge, temperature, amps, volts and lots more about your recent rides. Ask it! No spreadsheet skills needed. https://www.facebook.com/media/set/?set=a.10210227494036469.1073741839.1613544878&type=1&l=a13849da85 (https://www.facebook.com/media/set/?set=a.10210227494036469.1073741839.1613544878&type=1&l=a13849da85)
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on January 25, 2017, 05:15:51 AM
I've created a GitHub organization to adopt the tool and incorporate others:
https://github.com/orgs/zero-motorcycle-community/ (https://github.com/orgs/zero-motorcycle-community/)

You're welcome to join and contribute, or just file issues/requests.

The log parser repo is now in there with a fix from Keith, and I added a setup script and test runner. I confirmed that we have 18 logfiles that yield an error now and before the fix there were 23 that yielded an error.

https://github.com/zero-motorcycle-community/zero-log-parser (https://github.com/zero-motorcycle-community/zero-log-parser)

If you submit a log file (not sure what I'll do for that), we'll add it to our test suite. We need a script to strip the VIN numbers and other identifying information before I can make the logfile set public.
Title: Re: Log file parser utility
Post by: anton on January 25, 2017, 06:20:25 AM
I've created a GitHub organization to adopt the tool and incorporate others:
https://github.com/orgs/zero-motorcycle-community/dashboard

You're welcome to join and contribute, or just file issues/requests.

That link doesn't work because I guess it requires you to be a part of org to see dashboard?

https://github.com/zero-motorcycle-community works but there is no option to join this org. Permissions issue?
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on January 25, 2017, 07:22:49 AM
I've created a GitHub organization to adopt the tool and incorporate others:
https://github.com/orgs/zero-motorcycle-community/dashboard (https://github.com/orgs/zero-motorcycle-community/dashboard)

You're welcome to join and contribute, or just file issues/requests.

That link doesn't work because I guess it requires you to be a part of org to see dashboard?

Excellent catch - I've fixed the link in the post.

https://github.com/zero-motorcycle-community (https://github.com/zero-motorcycle-community) works but there is no option to join this org. Permissions issue?

Huh. After searching just now, I think that is not possible. To join, send me some identification (email or github account name) so I can invite you.

Thanks!
Title: Re: Log file parser utility
Post by: MajorMajor on January 25, 2017, 02:49:56 PM
Does anyone here know what the current state of battery logs parsing is?
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on January 25, 2017, 10:39:16 PM
Does anyone here know what the current state of battery logs parsing is?

There's incomplete documentation but no attempt to decode yet. See:
https://github.com/zero-motorcycle-community/zero-log-parser/blob/master/log_structure.md#bms-log-file-layout-wip

I suppose I can say that patches are welcome, but the log parser I think needs to get all the bugs worked out on the MBB entries first before tackling the BMS. To be honest, it's not documented how the MBB and BMS logs relate - I'm not sure whether or how the app exports BMS logs.
Title: Re: Log file parser utility
Post by: MajorMajor on January 26, 2017, 03:37:19 PM
What do you mean Brian?
When I exported logs with the app I got 3 files:
A single MMB bin and two BMS bin files (BMS0 BMS1).

I assumed these were logs for each of my two batteries and that they would contain individual cell voltages (like the values that can be read directly from the bike).

I have no idea what information the BMS logs contain, my hope is that it would be information that would allow us to determine if there is a problem with a battery.
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on January 26, 2017, 04:29:02 PM
What do you mean Brian?
When I exported logs with the app I got 3 files:
A single MMB bin and two BMS bin files (BMS0 BMS1).

I assumed these were logs for each of my two batteries and that they would contain individual cell voltages (like the values that can be read directly from the bike).

I have no idea what information the BMS logs contain, my hope is that it would be information that would allow us to determine if there is a problem with a battery.

Damn it, they are just separate files and I've been ignoring the BMS logs. Sigh, I think my attention span is just drastically overburdened.

Thanks for the confirmation that an FX/S will export one log per battery pack.
Title: Re: Log file parser utility
Post by: Keith on February 01, 2017, 02:15:54 AM
I have made some progress in parsing battery log files but there is a lot of unknown data at this time. However the parser is now much improved and will output usable text from any log file. I could use some example decoded data especially BMS data. A set of files with both decoded text from the serial link and .bin files from the app on the same bike would be a great help in deciphering the binary files.
Title: Re: Log file parser utility
Post by: Keith on February 23, 2017, 06:37:16 PM
I've created an offline html parser using javascript. This will decode, display and download text from MBB and BMS .bin log files. Works on phone or desktop. Get it here https://raw.githubusercontent.com/zero-motorcycle-community/browser-parse/master/zero-log-parser.html or see the full repository here https://github.com/zero-motorcycle-community/browser-parse Easy to use, no python, just save the html, open in Chrome or Firefox, choose a log file and view. I use google drive to save the logs sent from the Zero app, then download to local file storage. Check it out!
Title: Re: Log file parser utility
Post by: Kocho on February 23, 2017, 10:24:03 PM
Do I just need to download the zero-log-parser.html or do I also need the zero-parse.js file?

Does it not work on IE or Edge browsers?

I've created an offline html parser using javascript. This will decode, display and download text from MBB and BMS .bin log files. Works on phone or desktop. Get it here https://raw.githubusercontent.com/zero-motorcycle-community/browser-parse/master/zero-log-parser.html or see the full repository here https://github.com/zero-motorcycle-community/browser-parse Easy to use, no python, just save the html, open in Chrome or Firefox, choose a log file and view. I use google drive to save the logs sent from the Zero app, then download to local file storage. Check it out!
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on February 23, 2017, 11:13:20 PM
I've created an offline html parser using javascript. This will decode, display and download text from MBB and BMS .bin log files. Works on phone or desktop. Get it here https://raw.githubusercontent.com/zero-motorcycle-community/browser-parse/master/zero-log-parser.html or see the full repository here https://github.com/zero-motorcycle-community/browser-parse Easy to use, no python, just save the html, open in Chrome or Firefox, choose a log file and view. I use google drive to save the logs sent from the Zero app, then download to local file storage. Check it out!

This is great! Thanks for contributing to the github group, too.

In particular, html+js can be embedded in a mobile app (even downloaded and cached offline for invisible upgrades) for a couple of extra integration possibilities.

Do I just need to download the zero-log-parser.html or do I also need the zero-parse.js file?

Does it not work on IE or Edge browsers?

If it doesn't, I or another suitable web developer can probably work that out.
Title: Re: Log file parser utility
Post by: Keith on February 23, 2017, 11:31:15 PM
The html is all you need. It has the js inline.

Good luck with IE. I tried and gave up, MS doesn't support indexOf or slice with typed arrays, and they are reluctant to do file read/write.
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on February 23, 2017, 11:39:13 PM
The html is all you need. It has the js inline.

Good approach - single-file for ease of adoption/use/upgrade.

Good luck with IE. I tried and gave up, MS doesn't support indexOf or slice with typed arrays, and they are reluctant to do file read/write.

Oh, dear, those would be tricky to compensate for. Thanks for checking. I filed an issue on GitHub just so it can be tracked properly:
https://github.com/zero-motorcycle-community/browser-parse/issues/1
Title: Re: Log file parser utility
Post by: Keith on February 23, 2017, 11:50:36 PM
The single file is clunky to edit because the language is mixed. That's why the js is separate in the repo. I plan to have a component version with html, js, and css separated just for that reason, but distribute it as one html file for users.
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on February 24, 2017, 05:33:05 AM
The single file is clunky to edit because the language is mixed. That's why the js is separate in the repo. I plan to have a component version with html, js, and css separated just for that reason, but distribute it as one html file for users.

Yes, this is a usual good practice: small separate files that are combined for distribution in a build step.

BUT, you didn't include any way for someone to update that build! Could you include what you used? I'm okay with a lot of toolchains (maybe too many).

I can see from the HTML that it's just a simple template, very easy to find something basic to make this work automatically:
https://github.com/zero-motorcycle-community/browser-parse/blob/master/components/zero-log-parser_HTML_ONLY.html
Title: Re: Log file parser utility
Post by: Keith on February 24, 2017, 07:15:18 AM
The build is strictly manual, copy and paste, crude but not many steps. That's why I added the comments where the insertions are done. Four external files, not a big deal. I'm using Brackets, open the components folder, open each external, copy and paste into a new html single file. If you know of a good merge tool let me know.

BTW I tried a quick and dirty phonegap build of the html parser. It works fine on my S5 except it won't download. Probably just needs write permission. I don't know much about Android so it's out of my league but it looks very feasible to wrap it as an app. The html runs now from the download folder, not pretty but not hard to do. Probably need more detailed usage instructions.
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on February 24, 2017, 07:21:03 AM
Okay, it sounds like a build script will be pretty easy when I or someone has some time, and PhoneGap or a similar toolkit would be fine after some investigation.

I know enough about Android to be dangerous and a lot of stale iOS information that I'd tend to toss out for a restart in Swift wrapping this. Ideally we'd have an app that advertises that it can "send/receive email" in a way that Zero's app (or a new update) can handle. Maybe support Google Drive and other storage options or something that email clients often link to...

I'm speculating, but there might be an easy opportunity somewhere with the right poking around.
Title: Re: Log file parser utility
Post by: Keith on February 28, 2017, 06:47:47 PM
Get the new browser parser on this GitHub hosted web page with instructions and a download link to the latest version https://zero-motorcycle-community.github.io/browser-parse/ This works well on phones and desktop, handles all log files from the Zero app. It is a stand alone offline html parser, just save the file, bookmark it, and you can view your log files anywhere with no Internet connection needed.
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on March 01, 2017, 01:59:35 AM
This is great, Keith. It works on both iOS and Android, as we've tested. It's just one step away from getting wrapped in a native app so it can more easily trade files, but already makes a big difference being able to decode logs on the device.

I'm definitely glad we have enough infrastructure and testing now that the JS version was pretty straightforward to get working as well as the Python version.
Title: Re: Log file parser utility
Post by: Keith on April 05, 2017, 06:43:18 PM
I have created a powerful Highcharts web based viewer for MBB log files. This is an offline html file you can download from GitHub https://zero-motorcycle-community.github.io/browser-parse/ (https://zero-motorcycle-community.github.io/browser-parse/)  Check out these screenshots https://www.facebook.com/media/set/?set=a.10210866026279376.1073741840.1613544878&type=1&l=1fbc3493f7. (https://www.facebook.com/media/set/?set=a.10210866026279376.1073741840.1613544878&type=1&l=1fbc3493f7.)
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on April 11, 2017, 12:00:37 AM
I have created a powerful Highcharts web based viewer for MBB log files. This is an offline html file you can download from GitHub https://zero-motorcycle-community.github.io/browser-parse/ (https://zero-motorcycle-community.github.io/browser-parse/)  Check out these screenshots https://www.facebook.com/media/set/?set=a.10210866026279376.1073741840.1613544878&type=1&l=1fbc3493f7. (https://www.facebook.com/media/set/?set=a.10210866026279376.1073741840.1613544878&type=1&l=1fbc3493f7.)

This is getting so useful and accessible. I need to try using these in earnest now on my phone for efficiency / data collection.

Thanks for being on this as I am terribly busy lately and still am catching up on forum activity.
Title: Re: Log file parser utility
Post by: Keith on April 13, 2017, 07:13:03 PM
I have a list of improvements for the viewer but it is hard to work on software when the weather is nice. One thing on my list: I'd like to show rpm as speed and motor amps as torque, but the conversion factors vary for the different models. Maybe the numbers are in the Zero app since it does the conversions, anyone into decompiling?
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on April 14, 2017, 07:35:10 AM
I have a list of improvements for the viewer but it is hard to work on software when the weather is nice. One thing on my list: I'd like to show rpm as speed and motor amps as torque, but the conversion factors vary for the different models. Maybe the numbers are in the Zero app since it does the conversions, anyone into decompiling?

The MBB settings have the factors stored for the speedometer calculation (since it performs it), which is obviously a kind of gearing/multiplication factor on the sprockets and outer tire diameter estimate.

I'm not sure about amps to torque, but I'll bet it's roughly the basic physics that uses the idea that power=current*voltage and power=torque*angular_velocity.

http://simplemotor.com/calculations/ (http://simplemotor.com/calculations/)

So, you could take battery voltage / (current * <angular velocity in radians from RPM>) to get a rough torque estimate, I think. With a fudge factor of maybe 95% for transmission and rolling friction losses.
Title: Re: Log file parser utility
Post by: nevetsyad on April 14, 2017, 04:08:33 PM
This tool confirmed that my bike has serious issues, while I'm told constantly that things are fine with it. 24-28% power available to the motor at 28-68% SOC and a decent ambient temp is not normal! Thank you!!! Going through old logs I've mailed in is making me angry.

Perfectly normal ride here:

Since I was in the parser, I pulled up my SR logs. 28% power available at 64% SOC. Yeah, that checks out, seems normal. Nothing wrong with this bike...

07615     01/11/2017 14:26:18   Riding                     PackTemp: h 19C, l 19C, PackSOC: 64%, Vpack: 92.516V, MotAmps: 148, BattAmps: 188, Mods: 10, MotTemp:  69C, CtrlTemp:  26C, AmbTemp:  15C, MotRPM:4564, Odo:12518km
 07616     01/11/2017 14:26:18   Batt Dischg Cur Limited    199 A (28%), MinCell: 3249mV, MaxPackTemp: 19C
When I got home:
07639     01/11/2017 14:37:18   Disarmed                   PackTemp: h 24C, l 24C, PackSOC: 53%, Vpack:102.373V, MotAmps:   0, BattAmps:   2, Mods: 01, MotTemp:  59C, CtrlTemp:  21C, AmbTemp:  13C, MotRPM:   0, Odo:12530km
Title: Re: Log file parser utility
Post by: mrwilsn on May 07, 2017, 01:02:29 AM
I have created a powerful Highcharts web based viewer for MBB log files. This is an offline html file you can download from GitHub https://zero-motorcycle-community.github.io/browser-parse/ (https://zero-motorcycle-community.github.io/browser-parse/)  Check out these screenshots https://www.facebook.com/media/set/?set=a.10210866026279376.1073741840.1613544878&type=1&l=1fbc3493f7. (https://www.facebook.com/media/set/?set=a.10210866026279376.1073741840.1613544878&type=1&l=1fbc3493f7.)

I just got around to playing with the tool.  What great work.  One suggested improvement would be to provide for downloading the data that gets graphed into a CSV file instead of just pics.  That would allow for some data manipulation.
Title: Re: Log file parser utility
Post by: Keith on May 07, 2017, 02:37:19 AM
 ;D You might try the spreadsheet I made if you want the data more directly. I found that Google Sheets was a lot more capable than I thought. https://goo.gl/GGDcgr CSV download would be pretty easy to add to the viewer, I'll put it on my list (waiting for bad riding weather).
Title: Re: Log file parser utility
Post by: Tiger on October 11, 2017, 03:12:28 PM
Dear Keith, hello everybody,

I am Jochen from Germany.

I got a firmware update some days ago. After that I took a log file using the Zero App. But unfortunately the log viewer is not able to read it anymore. It just says "Not an MBB log file.". Before that firmware update everything worked well.

Is this a knwon issue? Something wrong with my bike? What could I do to analyze this?

Best regards,
Jochen
Title: Re: Log file parser utility
Post by: nevetsyad on October 11, 2017, 05:18:50 PM
V51 made mine unreadable. They also take over and hour to pull now. You have SOC, capacity and range estimate issues also?
Title: Re: Log file parser utility
Post by: Tiger on October 11, 2017, 06:30:34 PM
You have SOC, capacity and range estimate issues also?

Yes, that was the reason to read out a log.
I am daily commuting the same route since a year. So I know what percantage is usually shown at "each corner", espacially the value arriving at work and arriving at home. Some day it looks as usuall, some day the consumption seems to be higher. So also on my last ride. Started with 100% at home in the morning and finished with 20% at home in the evening. Usually there was ~35%. After 2 hours doing nothing I switched on the bike again and there was 31%. 31% would be in the range of uncertainty. But 20% is definitely not.

I was completely satisfied with the original firmware (DSR 2016). Is it possible to go back?

Best reggards, Jochen
Title: Re: Log file parser utility
Post by: nevetsyad on October 11, 2017, 06:43:31 PM
I'm still waiting to hear back from Zero. Send them your logs, without battery information. Tell them what is going on and ask when a firmware fix will be released.

I heard rumor that there's a new, v52 or v53 out already. You may be able to go to a dealer and get it updated to fix it already. My dealer is an hour away, I have to bring the family out there to drop it off, then bring them out there to help me pick it up, it sucks. I shouldn't have accepted the free update, half the time it breaks something.
Title: Re: Log file parser utility
Post by: clay.leihy on October 12, 2017, 04:41:18 AM
I have v51 and the newest version of the app tells me I need to upgrade.

Sent from my Z982 using Tapatalk

Title: Re: Log file parser utility
Post by: gt13013 on October 16, 2017, 06:21:11 AM
I have discovered the Zero Log Viewer today, and it is a really impressive and useful work. Thanks!

It has shown me that twice in the previous month, the engine temperature suddenly dropped to -100°C !!!
Has somebody else experienced the same thing? If you get it, you will have a line with "MotTemp:-100C" in the Zero Log Viewer.

I have a list of improvements for the viewer but it is hard to work on software when the weather is nice. One thing on my list: I'd like to show rpm as speed and motor amps as torque, but the conversion factors vary for the different models. Maybe the numbers are in the Zero app since it does the conversions, anyone into decompiling?
I have found the numbers for my bike in the specifications, at the end of the Owners Manual. These manuals are available at http://www.zeromotorcycles.com/owner-resources/
I attach a rpm to speed converter with the data of my bike (FXS 2016 11kW)


Title: Re: Log file parser utility
Post by: RickSteeb on June 11, 2018, 01:22:55 AM
My 2013 FX logs don't translate; is there a version of the log parser available for the '13FX?

Many Thanks!
Title: Re: Log file parser utility
Post by: BrianTRice@gmail.com on June 13, 2018, 05:39:06 AM
My 2013 FX logs don't translate; is there a version of the log parser available for the '13FX?

Many Thanks!

Unfortunately, that usually means that the export is truncated in an unfixable way. Sometimes retrying works, but if the problem is serious enough, it'll be best to have a dealer look or access the MBB by the OBD-II port directly to get logs that way.
Title: Re: Log file parser utility
Post by: netdomon on June 13, 2018, 05:22:47 PM
thank you mam!!
Title: Re: Log file parser utility
Post by: Keith on June 13, 2018, 06:54:40 PM
One of these days I plan to write a very forgiving parser version that ignores structure and just decodes and outputs whatever it can find regardless of any corruption or sequence errors. This problem happens too often to ignore. Meanwhile, the sun is shining, time to ride!
Title: Re: Log file parser utility
Post by: MostlyBonkers on December 12, 2018, 06:10:19 PM
Thanks very much for writing the log file parser, Keith.  I used it recently to highlight the issues I've been having with the battery on my 2014DS(P) which has already had the BMS replaced.  Being able to add my own comments in relation to the test ride I did made all the difference and Zero have agreed to replace the battery.  You've done a great service to the community!  :-)
Title: Re: Log file parser utility
Post by: Keith on December 12, 2018, 08:26:19 PM
Ah thanks. You've reminded me of my promise to write a more forgiving decoder. Not riding much lately so it could happen.