-./hostside /dev/ttyS0 <hex-digit-pairs> c|r|n \
- [<serial-fudge-delay> [<repeat-delay> [<iterations>]]]
-
- c = send directly to serial port as specified
- r = nmra packet with checksum - encode for pic (including preamble) and send
- n = nmra packet without checksum
-
- delays are in us.
- serial-fudge delay is usleep between bytes transmitted to serial port
- (for pic to catch up in slow, debugging, mode), 0 meaning not to usleep
- repeat-delay is -1 not to repeat, or 0 not to usleep, or +ve
- to repeat with usleeps in between
- iterations limits the looping (default is unlimited)
+./hostside-old [<options>] <nmra-command> <nmra-args...> see nmra-packets.h
+./hostside-old [<options>] nmra_bytes <nmra-command-hex-no-csum>
+./hostside-old [<options>] nmra_raw <nmra-command-hex-with-csum>
+./hostside-old [<options>] command <literal-data-for-pic>
+ options
+ -s<serialport> eg -s/dev/ttyS0 normally necessary
+ -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
+ -f<fudgedelay> usleep; each character; default is 0 = no usleep
Eg,
- ./hostside /dev/ttyS0 0348 n 0 10000 1000
+ ./hostside-old -s/dev/ttyS0 -w10000 -i1000 nmra_bytes 0348
to tell decoder 3 to go speed 13 backwards every 10ms for 1000 times, ie 10s
(on norway this means it actually happens every 20ms, ie for 20s,
which makes it a bit of a fudge really)
03 (+) 48 = 4b ok
To test:
- >t; ./hostside t 0348 n && binview t
+ ./hostside-old -st nmra_bytes 0348 && binview t
/*
* simple test harness for now
* asserts on usage errors
+ * see README for usage info
+
* usage:
* ./hostside /dev/ttySn DATA nmra
* ./hostside /dev/ttySn DATA command already encoded - raw transmit
}
}
- if (!serial_port) {
- if (!arg) badusage("need serial port as -s or arg");
- serial_port= arg;
- arg= *argv++;
- }
+ if (!serial_port) badusage("need serial port option");
if (!arg) badusage("need arg");
/* Function Group One RP9.2.1 C l.234- */
FUNCS(0x80 | ((bitmap >> 1) & 0x0f) | ((bitmap << 4 & 0x10)));
})
-NMRA(funcs5to9, Aint(addr,0) Abitmap(bitmap,1), {
+NMRA(funcs5to8, Aint(addr,0) Abitmap(bitmap,1), {
/* Function Group Two RP9.2.1 C l.246- */
- FUNCS(0xa0 | ((bitmap >> 5) & 0x0f));
+ FUNCS(0xb0 | ((bitmap >> 5) & 0x0f));
})
NMRA(funcs9to12, Aint(addr,0) Abitmap(bitmap,1), {
/* Function Group Two RP9.2.1 C l.246- */
- FUNCS(0xb0 | ((bitmap >> 9) & 0x0f));
+ FUNCS(0xa0 | ((bitmap >> 9) & 0x0f));
})
NMRA(cvwrite, Aint(addr,0) Aint(cv,1) Abyte(value,2), {
/* Configuration Variable Access Long Form RP9.2.1 C l.286- */
#!/bin/sh
-# usage:
-# ./program-cv /dev/ttyS0 DECODER-ADDR CV VALUE
-# where DECODER-ADDR, CV, VALUE are all decimal unless
-# prefixed by 0x or 0.
+
set -e
+
+if [ $# != 4 ]; then cat >&2 <<END; exit 1; fi
+ usage:
+ ./program-cv /dev/ttyS0 DECODER-ADDR CV VALUE
+ where DECODER-ADDR, CV, VALUE are all decimal unless prefixed by 0x or 0.
+END
+
port="$1"; shift
addr="$1"; shift
cv="$1"; shift
value="$1"; shift
-./hostside "$@" -s"$port" -i100 -w10000 cvwrite "$addr" "$cv" "$value"
+./hostside-old "$@" -s"$port" -i100 -w10000 cvwrite "$addr" "$cv" "$value"