# UDP driver

The udp driver supports receiving mode2 input via UDP.

Received UDP packets consist of a number of little endian 16-bit integers. The high bit signifies the state of the received signal; set indicates a mark, clear a space. The low 15 bits specify how long the signal lasted.

With the default resolution setting (61) the times are measured in 1/16384 second intervals. This was used by old hardware using a cheap 32kHz clock crystal, when designing new devices a 1MHz 1µs clock is recommended.

To allow long times to be transfered a long UDP input format is available, this consists of a zero time as specified by the short format followed by a four byte little endian time value. This should only be needed occasionally for example the time between button presses.

The UDP port can be set using the `--device=port` or `-d port` command line switch. In the time of writing, there is no way to specify the interface to use - the driver will listen to all interfaces.

The timing resolution can be set using the `--driver-option=clocktick:value` or `-A clocktick:value` command line switch e.g.,

    mode2 --driver=udp --device=8766 --driver-option=clocktick:1

to use port 8766 and 1 microsecond timing resolution.

Note: Little endian is not conventional network byte order.