UDP broadcast
Beside WebSockets, AMMC can broadcast every passing as a small UDP datagram on your local network. It suits simple scoreboards, timing displays or legacy software that just listens on a port, with no connection to set up: AMMC sends, anything on the network may listen.
Use -e <port> (or --udp_port <port>). An example reading the decoder on IP
192.168.1.11 and broadcasting on port 35000:
ammc-amb.exe -e 35000 192.168.1.11
It can run together with a database and a WebSocket server:
ammc-amb.exe -e 35000 -w 9000 --db mysql://root:password@localhost:3306/mysql 192.168.1.11Message format
Each passing is one datagram sent to the broadcast address 255.255.255.255 on
the chosen port. The payload is plain text, three semicolon-separated fields and
a trailing semicolon:
<transponder or transponder code>;<time>;<decoder id>;
Real examples:
87654321;09:56:41.5695;0A87E5;
123456;09:56:41.6068;0A87E5;
- transponder — the transponder number, or the transponder code when the decoder sends one (a code takes precedence over the number)
- time — the passing time as
HH:MM:SS.ffff, in the local timezone of the machine running AMMC - decoder id — the decoder that recorded the passing; empty if it did not report one
Passings without a time, or without both a transponder and a code, are skipped.
Receiving
Any UDP client works. To check quickly from the command line:
socat STDIO UDP4-DATAGRAM:255.255.255.255:35000,bind=:35000,range=10.0.10.0/24,broadcast
or in Python:
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(("0.0.0.0", 35000))
while True:
data, addr = sock.recvfrom(1024)
transponder, time, decoder_id, _ = data.decode().split(";")
print(transponder, time, decoder_id)Things to keep in mind
UDP broadcast is fire-and-forget. There is no acknowledgement, so a datagram can be lost, arrive out of order or be delivered more than once — for example when the receiving machine has several network interfaces. If you need every passing exactly once, use a database or WebSockets instead.
Broadcasts do not cross routers, so listeners must be on the same subnet, and some networks block broadcast traffic. Nothing in the message is encrypted or authenticated: anyone on the network can read it.