Git Product home page Git Product logo

zero-log-parser's Introduction

Zero Log Parser

This is a small decoder utility to parse Zero Motorcycle main bike board (MBB) and battery management system (BMS) logs.

  • It is designed to emulate Zero Motorcycles' own official log parser, that turns the binary-encoded event log into a mostly-readable text file.
  • If you send a log to Zero Customer Support, they should provide you with a text file in response. (Often, a phone call prompts them to process the log file)
  • If you run this script, and the script does not parse some entries correctly, we can upgrade the log parser to handle them if we have a copy of Zero's official log. So try to provide us with examples like this to help the development of the parser.

Usage

Getting Logs

You can extract logs from the bike using the Zero mobile app:

  1. Download the Zero mobile app.
  2. Pair your motorcycle with it via bluetooth.
  3. Once the pairing is working, select Support > Email bike logs.
  4. Enter your email address into the To: line to send the logs to yourself rather than / in addition to Zero Motorcycles support.
  5. Open the email and download the attachment.

Running

You'll need to install Python 3 somehow from https://www.python.org/downloads/

$ python3 zero_log_parser.py <logfile.bin> [-o output_file]

Docker

If you want to run using Docker, there's only two steps: build, then run.

Docker Build

docker build . -t "zero-log-parser"

To explain:

docker build

Build a new Docker image

.

Use a Dockerfile in the current directory ("/.")

-t "zero-log-parser"

Tag it as "zero-log-parser"

Docker Run

We will change directory to where the logs are, then run the tool against a log.

cd ~/zero-logs
docker run --rm -v "$PWD:/root" zero-log-parser /root/VIN_BMS0_2019-04-20.bin -o /root/VIN_BMS0_2019-04-20.txt

To explain:

cd ~/zero-logs

Go to the directory where the logs are stored. Change this to the correct directory for you

docker run

Run a Docker image as a container

--rm

Don't keep the image when it exits

-v "$PWD:/root"

Mount the current working directory as a volume inside the container at /root

zero-log-parser

What Docker image to run

/root/VIN_BMS0_2019-04-20.bin

Name of the binary file. You can get this by doing an ls after the cd before this command. Make sure to add /root/ before it since the path in the container is different

-o /root/VIN_BMS0_2019-04-20.txt

Save the decoded log file as VIN_BMS0_2019-04-20.txt in /root, which will save it in the current working directory outside of the container

Development

Basic log documentation is at log_structure.md.

If you want to debug the script and contribute, it's helpful to be able to run the tests. These currently look at a suite of log files and just run the parser to look for errors.

Setup

$ python3 setup.py develop

Testing

$ python3 test.py <directory of log files>

Authors

Originally developed at https://github.com/KimBurgess/zero-log-parser

zero-log-parser's People

Contributors

apgodshall avatar briantrice avatar cornejo avatar keithxemi avatar kimburgess avatar nmoreel avatar tyzbit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zero-log-parser's Issues

Logfile anonymizer

We need to be able to use logfiles for testing. The logfiles contain identifiable information which makes distribution sensitive.

Information in a logfile:

  • VIN in the filename (easily scrubbed, just need to choose a method for it).
  • VIN in the logfile (requires writing a new/blank value to relevant entries).
  • Battery serial number in the logfile (requires writing a new/blank value to relevant entries).

Year 2017+ Header doesn't parse

The header section of the MBB files don't parse properly on 2017 (and presumably newer) VINs. The data in the file seems to parse ok but the header looks like this:

"
Zero MBB log

Serial number Z�tWR� ] sj421
VIN 20:12
Firmware rev. 1536
Board rev. 125
Model W

Printing 3925 of 3925 log entries..

Entry Time of Log Event Conditions
+--------+----------------------+--------------------------+----------------------------------
"

( none of the fields above show proper data - Serial number through Model

readme modification suggestion

Hi,

More a comment than an issue, but it took me a while to correctly run the python script simply because I wasn't aware that the command I should be typing was
python3 zero_log_parser.py XXX.bin

rather than just python. I suspect this is because my computer has python v 2 and 3 installed, but others may trip up in a similar manner. The error messages python gives aren't obvious that this was the problem.

Glyn.

Installer needed

Plenty of people don't want to upload their logs to a service, and also have trouble getting and running Python, so we should package the script to download, install, and run.

I'm considering https://pypi.python.org/pypi/bbfreeze for this purpose.

BMS log file layout incomplete

The parser now handles BMS logs and outputs a usable text file. However many entries are hex data of unknown significance. More BMS log files are needed for study and testing.

SR/F (and SR/S) Logs have a new format with no official decode examples

Zero has a new format for SR/F logs which only roughly matches the existing formats, so the parser will almost need to be written from scratch.

To be clear on one point: we have no copies of officially decoded logs to emulate. This is key to understanding the data embedded (though the basic record format and messages are recoverable).

It is encoded in a more clever way which is taking time to develop against. Assistance would be most appreciated.

merge of BIN Files

I have some log-files. Many data is redundant because it is always attached.
Is it possible that when you have all the files, every time-stamp has only once?

Improve error handling

Errors are reported without context right now, which makes it difficult for the user to understand what has gone wrong or whether it's significant or not a big deal.

Errors should be reported with some context about where in the file it happened and maybe show how much data was processed until that point - anything that helps clarify.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.