UDP Receiver

class gpype.backend.sources.udp_receiver.UDPReceiver[source]

Bases: EventSource

UDP network receiver for capturing remote trigger events.

Listens on specified IP/port for UDP packets containing numeric trigger values. Each trigger outputs the received value, and then a zero once HOLD_TIME_MS has passed – not immediately. Emitted back to back, the value and its reset are observed microseconds apart, which at any real sampling rate is the same sample: they then place onto one row of the grid and the reset overwrites the value it was meant to follow. Measured through a Router at 250 Hz, six datagrams with frames of 25: one trigger reached the consumer with the immediate reset, five with it held.

DEFAULT_IP = '127.0.0.1'

Default IP address for localhost binding

DEFAULT_PORT = 1000

Default UDP port number for listening

HOLD_TIME_MS = 10

Hold time in milliseconds before the reset trigger follows a value. Declared with the protocol from the start and then never read: the reset went out on the line after the value, so the two shared a sample and the trigger was erased before any consumer saw it. Ten milliseconds is 2-3 samples at 250 Hz – enough to land on a row of its own at every rate g.Pype supports, and short enough that a paradigm asserting a code for 50 ms still reads as one pulse.

STOP_TIMEOUT_S = 1.0

How long stop() waits for the listener thread before giving up on it. The loop wakes on a 10 ms select timeout, so this is about a hundred chances to see the cleared flag – generous enough that reaching it means something is wrong, and short enough that it is not mistaken for a hang.

class Configuration[source]

Bases: Configuration

Configuration class for UDP receiver network parameters.

class Keys[source]

Bases: Keys

Configuration key constants for the UDP receiver.

IP = 'ip'

Configuration key for IP address binding

PORT = 'port'

Configuration key for UDP port number

__init__(ip='127.0.0.1', port=1000, edge_id=None, **kwargs)[source]

Initialize UDP receiver.

Parameters:
  • ip (str) – IP address to bind socket to. Use “0.0.0.0” for all interfaces or “127.0.0.1” for localhost. Defaults to localhost.

  • port (int) – UDP port number to listen on. Defaults to 1000, which macOS and Linux reserve for root: pass one from 1024 to 49151 there, and point the sender at it.

  • edge_id (Optional[str]) – Which edge runs this node, matched against the edge process’s –edge-id. None, the default, is every edge; ignored when the pipeline is not distributed.

  • **kwargs – Additional parameters for EventSource base class.

start()[source]

Start UDP receiver and begin listening for messages.

Initializes background UDP listener thread and starts monitoring for incoming trigger messages.

stop()[source]

Stop UDP receiver and cleanup network resources.

Stops background listener thread, closes UDP socket, and waits for clean thread termination.