Skip to main content

OxTS RT-Range data parsing utility

Project description

OxTS RT-Range data parsing utility

This simple parser is capable of parsing RT-Range Ethernet packets (NCOM and RCOM).

REQUIRES PYTHON 3.10 OR NEWER

Installation

Use pip to install

pip install rt-range

Usage

Basic parsing

from rt_range.ethernet import EthernetParser

rt_packet: bytes = ...  # RT-Range Ethernet packet

# Parsing with automatic packet type identification
parsed: dict[str, ...] = EthernetParser.parse_rt_ethernet(rt_packet)

The packet type will be determined automatically. Raises ValueError if the bytestring is not a valid RT-Range packet. Raises NotImplementedError if the parser for detected type is not implemented.

Specifying packet type

from rt_range.ethernet import EthernetParser, PacketType

ncom_data: list[bytes] = ...  # RT-Range Ethernet packets list

# Parsing with specified type
parsed: list[dict[str, ...]] = [
    EthernetParser.parse_rt_ethernet(packet, PacketType.NCOM)
    for packet in ncom_data
]

This forces the parser to use the specified packet type regardless of the packet contents. Use this only if you are sure about the packet content asit may lead to parsing errors or unexpected values in the parsing result.

Raises NotImplementedError if the parser for detected type is not implemented.

Using Pandas

import pandas as pd
from rt_range.ethernet import EthernetParser, PacketType

range_data: list[bytes] = ...  # RT-Range Ethernet packets list

# Parsing and converting to DataFrame
parsed = pd.DataFrame([
    EthernetParser.parse_rt_ethernet(packet, PacketType.RCOM_extended_range)
    for packet in range_data
])

The returned list of dictionaries can be easily converted to the Pandas Dataframe for further processing.

Short documentation

Class EthernetParser

  • Package: rt_range.ethernet.eth_parser
  • Import: from rt_range.ethernet import EthernetParser
  • Purpose: RT-Range NCOM and RCOM packets parsing
  • Members:
    • Class method is_implemented(cls, packet_type: PacketType)

      Returns True if the parser for the specified packet type is implemented, False otherwise

    • Class method parse_rt_ethernet(cls, buffer: bytes, packet_type: PacketType | None = None)

      Parse bytes buffer to dict[str, ...]

Enum PacketType

  • Package: rt_range.ethernet.eth_parser
  • Import: from rt_range.ethernet import PacketType
  • Purpose: RT-Range packets types definitions
  • Members:
    • NCOM
    • RCOM_lane
    • RCOM_extended_range
    • RCOM_wrapped_NCOM
    • RCOM_trigger_time
    • RCOM_polygon
    • RCOM_multiple_sensor_point
    • Unknown

Enum SyncByte

  • Package: rt_range.ethernet.eth_parser
  • Import: from rt_range.ethernet import SyncByte
  • Purpose: Sync Byte definitions for distinguishing NCOM and RCOM
  • Members:
    • NCOM
    • RCOM

Class Packet

  • Package: rt_range.ethernet.rt_packet
  • Import: from rt_range.ethernet.rt_packet import Packet
  • Purpose: RT-Range parseable Packet
  • Members:
    • Method decode(self, buffer: bytes) -> tuple[np.array, Selector]

      Decodes bytes buffer with np.dtype to np.array

    • Method get(self, obj: np.array, name: str, selector: Selector)

      Decodes raw value using rules defined in packet structure

    • Method translate(self, obj: np.array, selector: Selector) -> dict[str, ...]

      Translates np.array into a dictionary

    • Method parse(self, buffer: bytes) -> dict[str, ...]

      Wrapper for decoding and translation

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

rt_range-0.2.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

rt_range-0.2.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file rt_range-0.2.0.tar.gz.

File metadata

  • Download URL: rt_range-0.2.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for rt_range-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b1b9e72b7375fdca982da722a5a04b56b59fb0ed6a56e5f9b4759be38f1fb1c6
MD5 8c5773c117e15a84b3aea3690ecd5012
BLAKE2b-256 4f7c815abfca3ad0f0d6fea27ac4c84a34f433ea8808e3577de38025d2092d41

See more details on using hashes here.

File details

Details for the file rt_range-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rt_range-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for rt_range-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76cc8a854c1343b18877ae0a954a2b0472e82b0e37eb2d8ff3c18affb2ee83df
MD5 3b3641b2dc47ae5d1e9866c901026a36
BLAKE2b-256 400a3464a770d2ab6156f1255eb659fbefb12ddcf2ba1f8919325f687cef1e12

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