chiark / gitweb /
fixes to hostside and docs. now this stuff works and corresponds to the docs
authorian <ian>
Tue, 2 Aug 2005 22:16:33 +0000 (22:16 +0000)
committerian <ian>
Tue, 2 Aug 2005 22:16:33 +0000 (22:16 +0000)
hostside/README
hostside/main.c
hostside/nmra-packets.h
hostside/program-cv

index dc4c1470530f4127bba6511e7abe64b33f87abfe..1cff5706c036332e4a0216a7ad5f28ce68996c30 100644 (file)
@@ -1,19 +1,15 @@
-./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)
@@ -27,7 +23,7 @@ to tell decoder 3 to go speed 13 backwards every 10ms for 1000 times, ie 10s
                     03    (+)  48       = 4b ok
 
 To test:
>t; ./hostside t 0348 n && binview t
./hostside-old -st nmra_bytes 0348 && binview t
 
 
 
index 1629a53696a86a677cee67414004ee297036bfbd..7f2cc6d14edc71e51f9140b95d678da53572a427 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * 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
@@ -124,11 +126,7 @@ int main(int argc, const char **argv) {
     }
   }
 
-  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");
 
index c0dfb070d6874dd23cf362ccb4afa11a2d385837..480dac82add8a621b889307896119ab344827c6a 100644 (file)
@@ -51,13 +51,13 @@ NMRA(funcs0to4, Aint(addr,0) Abitmap(bitmap,1), {
   /* 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- */
index 49ff61898bbdb71bc8fece55d76bac8105388361..46a36dea6e4fa234e73bf5fc123885537843cbbc 100755 (executable)
@@ -1,11 +1,15 @@
 #!/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"