Skip to main content

A Python library for decoding FastNet protocol data streams.

Project description

pyfastnet

Python library for decoding the FastNet protocol used by B&G Hydra/H2000 instruments. Developed for personal use and published for general interest.

Purpose

Feed a raw byte stream from a FastNet bus into the library. It handles synchronisation, checksum validation, and decoding — returning structured instrument data ready for further processing.

Installation

pip install pyfastnet

Example usage

#!/usr/bin/env python3
import serial
from fastnet_decoder import FrameBuffer

fb = FrameBuffer()

ser = serial.Serial(
    port="/dev/ttyUSB0",
    baudrate=28800,
    bytesize=serial.EIGHTBITS,
    stopbits=serial.STOPBITS_TWO,
    parity=serial.PARITY_ODD,
    timeout=0.1,
)

try:
    while True:
        data = ser.read(256)
        if not data:
            continue
        fb.add_to_buffer(data)
        fb.get_complete_frames()
        while not fb.frame_queue.empty():
            frame = fb.frame_queue.get()
            for channel, decoded in frame["values"].items():
                print(channel, decoded)
finally:
    ser.close()

Output format

Each decoded frame is a dict with to_address, from_address, command, and values. Each entry in values is keyed by channel name:

{
  "to_address":   "Entire System",
  "from_address": "Normal CPU (Wind Board in H2000)",
  "command":      "Broadcast",
  "values": {
    "Apparent Wind Speed (Knots)": {
      "channel_id":   "0x4D",
      "value":        7.0,
      "display_text": "7.0",
      "layout":       None,
    },
    "Apparent Wind Angle": {
      "channel_id":   "0x51",
      "value":        -6.0,
      "display_text": "-6.0",
      "layout":       "-[data]",
    },
    "True Wind Direction": {
      "channel_id":   "0x6D",
      "value":        213.0,
      "display_text": "213.0°M",
      "layout":       "°M",
    },
  }
}

Position (LatLon) frames

Position frames (command LatLon) appear under the "LatLon" key. The raw coordinate string (DDMM.mmm with hemisphere letters) is carried in display_text; value is None. The originating source's marker byte is preserved in channel_id (e.g. 0x47, 0x4E) but does not affect the key:

"LatLon": {
    "channel_id":   "0x4E",
    "value":        None,
    "display_text": "3352.450S15113.920E",
    "layout":       None,
}

Layout field

The layout field describes the indicator symbol shown on the physical display around the numeric value:

layout Meaning Sign
None No indicator symbol positive
"[data]=" = after value (starboard) positive
"=[data]" = before value (port) negative
"[data]-" - after value (starboard) positive
"-[data]" - before value (port) negative
"H[data]" H prefix — heading positive
"°M" Magnetic bearing suffix positive
"u[data]" u prefix — upwind (VMG) positive
"d[data]" d prefix — downwind (VMG) positive
"L[data]" L before — leeway port negative
"[data]L" L after — AP compass target positive
"[data]°C" Celsius suffix positive
"[data]°F" Fahrenheit suffix positive
"[data]z" / "z[data]" Dog-leg symbol — AP off course positive
"TBC" Symbol seen but not yet identified positive

Debug API

from fastnet_decoder import set_log_level
import logging
set_log_level(logging.DEBUG)
fb.get_buffer_size()      # bytes currently in buffer
fb.get_buffer_contents()  # hex string of buffer contents

Companion apps

  • fastnet2ip — reads FastNet from serial and broadcasts it over UDP as either NMEA 0183 or NMEA 2000 (selected with --output). Install with pipx install fastnet2ip.

Runs on Raspberry Pi, macOS, or Linux.

Acknowledgments

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

pyfastnet-2.0.16.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfastnet-2.0.16-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file pyfastnet-2.0.16.tar.gz.

File metadata

  • Download URL: pyfastnet-2.0.16.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyfastnet-2.0.16.tar.gz
Algorithm Hash digest
SHA256 0b84265ecda4c5f7f1975ac2d325b4ffb7f6c4f575a2b175825d3ef8c689f5bd
MD5 1426eafadaba0ae1cc14f8b0be764282
BLAKE2b-256 7c69a35d2b0c0ed1458c76ce1b445f7abde210bfc80f3d468302f88d3c363f24

See more details on using hashes here.

File details

Details for the file pyfastnet-2.0.16-py3-none-any.whl.

File metadata

  • Download URL: pyfastnet-2.0.16-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyfastnet-2.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 6d0075755c5b2eab6d429e65ffdd06bf5cb4986bb36650e25ffd46f9be22acff
MD5 eac402d623e21911854e367c509d2d26
BLAKE2b-256 610c07cf76260787685ab5d8157447c5267ee2e8be2655c34a3197e6019f4230

See more details on using hashes here.

Supported by

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