splitter

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimatePacketCount

func EstimatePacketCount(data []byte) int

EstimatePacketCount estimates the number of complete packets in the data This is a quick check without full parsing

func GetPacketType

func GetPacketType(packet []byte) (byte, error)

GetPacketType returns the protocol number from a packet Returns 0 and error if packet is invalid

func GetSerialNumber

func GetSerialNumber(packet []byte) (uint16, error)

GetSerialNumber extracts the serial number from a packet Serial number is always 2 bytes before CRC

func HasCompletePacket

func HasCompletePacket(data []byte) bool

HasCompletePacket quickly checks if the data contains at least one complete packet

func SplitPackets

func SplitPackets(data []byte) (packets [][]byte, residue []byte, err error)

SplitPackets splits concatenated packets from a TCP stream GPS devices often send multiple packets in a single TCP write, or packets may be fragmented across multiple reads.

Returns: - packets: Complete packets found in the data - residue: Incomplete packet data to be prepended to next read - error: Any error encountered during splitting

Example:

Input:  [CompletePacket1][CompletePacket2][PartialPacket3]
Output: packets=[Packet1, Packet2], residue=[PartialPacket3]

func ValidatePacketStructure

func ValidatePacketStructure(packet []byte) error

ValidatePacketStructure performs basic structural validation on a packet without decoding the full content

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL