USAGE: arduino_delay OPTIONS (all permutations permitted; not all are sensible.)
OPTIONS: -h show this help.
-d print debugging messages to stderr (uses timeouts, so slower).
-a check communication (and protocol) with Arduino and exit .
-g get the current delay value in ns. 0 means bypassed; -1 uninitialised.
-s LEN_NS set the delay in ns. LEN_NS = { 0, [5120, 15728640] }. 0 means Bypass.
LEN may have suffixes s,ms,us,ns. Truncation/quantisation: 40 ns.
Setting the delay prefills the FIFO and inserts it into the path.
-v get verbose status information from the Arduino.
-b bypass the FIFO (the delay on subsequent re-insertion is unchanged).
-i inserts the FIFO into the path.
-m measure the actual FIFO delay (in ns) vs. the Arduino's clock. Returns
0 when bypassed. Accuracy: 8 us quantisation.
[This uses a spare FIFO bit, so is non-destructive of fill-level.]
-c LEN_MS count falling-edges for (integer) ms. Max freq ~2.5 MHz; accuracy ~0.2%.
LEN may also have suffixes of s,ms. Max LEN: 1000000 ms.
[FIFO is altered during this measurement; state is then restored.]
-u gets the Arduino uptime in seconds (wraps at 2^32, i.e. 71 days).
-l blink the diagnostic LED on the Arduino.
-w 60 second test: 25 kHz clock, with switch/led to generate/view pulses.
[FIFO is bypassed during this test; state is then restored.]
-r soft reset the Arduino (also clears the FIFO).
-R hard reset the Arduino (hangup DTR; also clears the FIFO).
RETURNS:
0 on success.
1 on error.
NOTE: * The NI4462 has a digital group delay of 63 samples. If pre-trigger samples is 2,
and it is clocked at 204.8 kHz, the trigger-delay should ideally be 317382.8 ns.
* Serial protocol is: send 1-line command; wait up to 100 ms, read 1-line reply. -d drains the
queue every time, reading n-lines till EOF: necessary if Arduino has '#define DEBUG 1'.
* The Arduino's own oscillator is not used for any timing functions (except -m, -c).
* The circuit doesn't use the Arduino's 8 Analog pins; these are available for future expansion.