Skip to main content

A tool to import and format data from Kvaser CAN files when you dont have a DBC file.

Project description

canLogParse

This is a library for importing and parsing data from Kvaser CAN files when you don't have a DBC file. The code should be fairly simple and self-documenting, and all other information should be contained within this file. You can install the library on pip via pip3 install canLogParse.

Functions

parseCanPacket(rawPacket, outputFormat="2dArray")

Takes a raw, unformatted CAN packet and returns it in a more useful format. The possible formats are array (the default), tuple, and dict.

Output data

The data is structured as follows:

leadingZero: The zero at the start of the packet.

id: The packet ID.

dataLength: The number of data bytes.

data: The data bytes in an array of strings.

T/R: It is assumed that this is transmit/receive, but so far it has only been observed as R.

timeStamp: The packet timestamp.

In array and tuple formats, the data is in the order above. In dict format, the keys are as stated above and

parseCanData(rawData, outputFormat="array")

Parses an array of CAN packets in the same way as parseCanPacket. Formats are the same as parseCanPacket, but put together in an array.

importCanLogFile(file, outputFormat="array")

The same as parseCanData, but taking the data from a file.

findUniqueIDs(packets)

Takes a 2D array (or array of tuples) of packets, returns a list of all unique packet IDs.

exportLogToCSV(log, filename)

Takes a 2D array of packets and writes the data in CSV format to the specified file.

_formatPacket(leadingZero, id, dataLength, data, tr, timeStamp, outputFormat="2dArray")

This function takes the given data and formats it in the specified way.

_formatPacketList(leadingZero, id, dataLength, data, tr, timeStamp), _formatPacketDict, and _formatPacketTuple

These functions take in the packet data and format it into either a list, a dictionary, or a tuple.

_extractDataFromPacket(packet)

This function takes a packet array and returns the data bytes as an array of strings. It does this by removing all known non-data bytes, which is a terrible way to do it. This function should be updated to extract it using the included dataLength byte.

_fileToList(file)

This takes a file name, and returns its rows in a list.

TODO

  • Update _extractDataFromPacket to use the dataLength byte

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

canLogParse-1.0.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

canLogParse-1.0.3-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file canLogParse-1.0.3.tar.gz.

File metadata

  • Download URL: canLogParse-1.0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for canLogParse-1.0.3.tar.gz
Algorithm Hash digest
SHA256 adbb015d4882eaab48fd00ad2d18f1fa6e30419204f13db3f770ff4d0691ea0e
MD5 79055dfee902e6f89c4b3678a36fe50b
BLAKE2b-256 9f7eca4b72a07ec4de3347d2a4aebb03a2bc951678c03c96c2e22ae6dccedd74

See more details on using hashes here.

File details

Details for the file canLogParse-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: canLogParse-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for canLogParse-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 32810efd3dd1a51ea5eb599a58f12e035902537c2424210fadc01b42fa449fa4
MD5 92622827380ed22a4cb10c54d6035de9
BLAKE2b-256 03c444f5663a2ddd282d154af4f9ec0acd213c4cef4f09746a2a8cee206de858

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page