Skip to main content

pyfastnet

A Python library for decoding the FastNet protocol used by B&G Hydra / H2000 instruments. Feed it raw bytes from the Fastnet bus and it handles synchronisation, checksum validation, and decoding — returning instrument data as Signal K paths in SI units, ready for further processing.

v3.0 changes the output format. Decoded frames are now {signalk_path: SI_value} (e.g. navigation.speedThroughWater = 3.6) instead of the v2 name-keyed {value, display_text, layout} dicts. See Output format below. The full v2-style decode is still available via FrameBuffer(project=False).

Developed for personal use and published for general interest. Runs on Raspberry Pi, macOS, or Linux.

Quick start

pip install pyfastnet
#!/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 path, value in frame["values"].items():
                print(path, value)   # e.g. navigation.speedThroughWater 3.6
finally:
    ser.close()

Serial settings for a B&G Fastnet bus are 28,800 baud, 8 data bits, odd parity, 2 stop bits. No instruments to hand? The companion apps below ship recorded captures you can replay.

The Fastnet toolkit

Three projects stack together — pick the layer that matches where you want the data to end up:

Project What it does Use it when
pyfastnet (this library) Decoder. Turns raw Fastnet bytes into Signal K paths in SI units. You're writing your own Python and want the decoded data.
fastnet2ip Serial → network. Broadcasts decoded data over UDP as NMEA 0183 or NMEA 2000 (over IP). Feeding Signal K, OpenCPN, or a plotter over WiFi / Ethernet.
fastnet2n2k Serial → physical NMEA 2000 bus. Transmits PGNs onto a CAN backbone via SocketCAN. Wiring into a real NMEA 2000 network / chartplotter.
                          ┌─ fastnet2ip   → UDP (NMEA 0183 / NMEA 2000 over IP) → Signal K, OpenCPN, plotters
B&G Fastnet bus ─(serial)─→ pyfastnet ─┤
                          └─ fastnet2n2k → SocketCAN (NMEA 2000 PGNs)           → CAN backbone, chartplotter

pyfastnet is the engine at the bottom of the stack. If you only want the decoded data on your network or NMEA 2000 bus — including running it as an always-on systemd service — use one of the companion apps; they handle the serial port, a live data store, rate limiting, and output for you.

Output format

Each decoded frame is a dict with to_address, from_address, command, and values. values maps Signal K paths to SI values — one canonical entry per physical quantity:

{
  "to_address":   "Entire System",
  "from_address": "Normal CPU (Wind Board in H2000)",
  "command":      "Broadcast",
  "values": {
    "environment.wind.speedApparent":     4.6,    # m/s
    "environment.wind.angleApparent":     0.419,  # radians
    "environment.wind.directionMagnetic": 1.239,  # radians
    "navigation.speedThroughWater":       3.19,   # m/s
  }
}

Units follow the Signal K spec: angles in radians, speed in m/s, distance in metres, temperature in Kelvin, pressure in Pascals. A value is a float (SI), a str enum (e.g. steering.autopilot.state"standby"), a position object, or None when unavailable.

Redundant unit-variant channels the bus sends (feet/fathoms depth, knots wind, °F) are collapsed to one canonical path. B&G-proprietary channels with no standard Signal K path — including the pre-calibration raw sensor values — are emitted under a bandg.* namespace (e.g. bandg.wind.rawAngleApparent).

Units and the full path map

Every emitted path has a canonical SI unit, available programmatically:

from fastnet_decoder import unit_for
unit_for("navigation.speedThroughWater")   # "m/s"
unit_for("navigation.headingMagnetic")      # "rad"
unit_for("environment.water.temperature")   # "K"
unit_for("navigation.position")             # "deg"

The complete mapping — every B&G channel id/name → Signal K path + unit, the bandg.* vendor namespace, layout-driven Magnetic/True routing, and the dropped/collapsed channels — is documented in docs/v3_signalk_mapping.md.

Position

Position frames are emitted as navigation.position, a decimal-degree object (negative for S / W):

"navigation.position": {"latitude": -33.8742, "longitude": 151.2320}

True vs Magnetic

The reference is carried by the path, not a separate field: navigation.headingMagnetic vs navigation.headingTrue, environment.wind.directionMagnetic vs directionTrue, environment.current.setMagnetic vs setTrue. The decoder selects the right path from the display's indicator symbol at decode time. (The raw stream carries no magnetic variation or deviation, so it cannot convert between the two.)

Complete (rich) decode

FrameBuffer(project=False) queues the full internal decode instead of the Signal K projection. Each value is then a dict — value, display_text, layout, channel_id — keyed by human-readable channel name (the v2 format). Useful for debugging and reverse-engineering; display_text and layout are not exposed in the default Signal K output.

You can also project a single decoded frame yourself:

from fastnet_decoder import decode_frame, project
rich = decode_frame(raw_frame_bytes)      # complete decode
si = project(rich)                        # {signalk_path: SI_value}

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

Acknowledgments

License

MIT — see LICENSE.

Download files

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

Source Distribution

pyfastnet-3.0.0.tar.gz (33.0 kB view details)

Uploaded Source

Built Distribution

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

pyfastnet-3.0.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyfastnet-3.0.0.tar.gz
Algorithm Hash digest
SHA256 3a619c7008c2b04992e025e0d6d1ff3a07efe2b6e151215e0d39eca7eda0f81d
MD5 749cad43a9fc2adefdb983f951f9b4f2
BLAKE2b-256 80232194a0a12b51f21d592fdb6ca07757f12c867e6d2a5a308c84ba2266b814

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyfastnet-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7b3d38627fc0f774dc907d6d3c444b47e5c6583aac7daac962d81e971cd6de9
MD5 6bb642d261819a5266809964729a970b
BLAKE2b-256 2a5f70743d620a1e4fd21bf2f5a9374fd9f6595ff5278ed7229cbccda3b63e8c

See more details on using hashes here.

Release history Release notifications | RSS feed

3.1.0

2 files

This release

3.0.0 This release

2 files

2.0.18

2 files

2.0.17

2 files

2.0.16

2 files

2.0.15

2 files

2.0.14

2 files

2.0.13

2 files

2.0.12

2 files

2.0.11

2 files

2.0.10

2 files

2.0.9

2 files

2.0.8

2 files

2.0.7

2 files

2.0.6

2 files

2.0.5

2 files

2.0.4

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.2.5

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.9

2 files

1.1.8

2 files

1.1.7

2 files

1.1.6

2 files

1.1.5

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.23

2 files

1.0.22

2 files

1.0.21

2 files

1.0.20

2 files

1.0.19

2 files

1.0.18

2 files

1.0.17

2 files

1.0.16

2 files

1.0.14

2 files

1.0.13

2 files

1.0.12

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page