Merged
Conversation
Closed
nicolomarconi02
requested changes
Feb 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
The goal of this pull request is to enable concurrent access to GPS data by implementing a TCP Server/Client architecture within
gpslib, resolving #2.This PR decouples the hardware connection from the data processing, allowing a single Server instance to broadcast raw GPS data to multiple Clients simultaneously.
Overview
This pull request introduces significant changes to
gps_interfaceto support connection management and ensure data integrity for both NMEA and UBX protocols.gps_serial_portwith a server context that wraps the underlying physical GPS port, managing the server socket in the top layer and the serial connection in the bottom layer.gps_interface_get_lineto reconstruct the full raw packet (re-attaching stripped Start Sequences/Sync Bytes and Newlines) before broadcasting. This ensures clients receive valid, checksum-verifiable data.broadcast_to_clients. It usesMSG_NOSIGNALto detect broken pipes (EPIPE/ECONNRESET) and disconnects dead clients immediately, while tolerating temporary failures (up toMAX_FAILS) for congested connections.pthreadsupport to manage the acceptance of new connections and mutexes to protect the client socket and failure lists during broadcast operations.Guidance
I recommend reviewing the files in the following order:
gps_interface.h: Start here to review the changes to thegps_serial_portstruct and the new server context definitions.gps_interface.c:gps_interface_open_serverto see how the context is initialized.gps_interface_readandgps_interface_get_lineto see how the code detects the protocol type and reconstructs the full message buffer before calling broadcast.broadcast_to_clientsto examine theMSG_NOSIGNALimplementation and the strike-count logic for handling client disconnects.acceptThreadFunc, the detached thread that continuously listens for and accepts new client connections.gps_interface_open_clientto see how the connection is established.gps_interface_readfor the client-side socket handling.