-w<repeatdelay> usleep; 0 = no usleep; default is -1 = don't repeat at all
-i<iterations> default is 0 = infinite; -1 means don't repeat
*** the above seems wrong; -1 seems to mean infinite
+ *** and 0 means once ?!
-f<fudgedelay> usleep; each character; default is 0 = no usleep
Eg,
*c++= value;
})
+/*
+ * Service mode.
+ */
+NMRA(svc_cvwrite, Aint(cv,0) Abyte(value,1), {
+ /* Service Mode Instruction for Direct Mode, Write Byte
+ * RP 9.2.3 E l.107-
+ */
+ int adj;
+ nmra_errchk(cn, cv, cv>=1 && cv<=1024);
+ adj= cv - 1;
+ *c++= 0x7c | (adj >> 8);
+ *c++= adj;
+ *c++= value;
+})
+
#undef Aint
#undef Abitmap
#undef Abyte
--- /dev/null
+#!/bin/sh
+
+set -e
+
+if [ $# != 3 ]; then cat >&2 <<END; exit 1; fi
+ usage:
+ ./program-cv /dev/ttyS0 CV VALUE
+ where CV, VALUE are all decimal unless prefixed by 0x or 0.
+END
+
+port="$1"; shift
+cv="$1"; shift
+value="$1"; shift
+
+ho () { ./hostside-old -s"$port" -w20000 -i0 -d "$@"; }
+
+# Packet Sequence for Command Stations/Programmers using Direct Mode
+# RP 9.2.3 E l.100-
+
+ho command 10
+sleep 1
+ho command 11
+sleep 1
+ho -i10 reset
+sleep 1
+ho -i10 svc_cvwrite "$cv" "$value"
+sleep 1
+ho command 10