From 07a6acc178848af21fedcfc65ee66d38b45894a2 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 2 Aug 2005 22:16:33 +0000 Subject: [PATCH] fixes to hostside and docs. now this stuff works and corresponds to the docs --- hostside/README | 26 +++++++++++--------------- hostside/main.c | 8 +++----- hostside/nmra-packets.h | 6 +++--- hostside/program-cv | 14 +++++++++----- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/hostside/README b/hostside/README index dc4c147..1cff570 100644 --- a/hostside/README +++ b/hostside/README @@ -1,19 +1,15 @@ -./hostside /dev/ttyS0 c|r|n \ - [ [ []]] - - 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 [] see nmra-packets.h +./hostside-old [] nmra_bytes +./hostside-old [] nmra_raw +./hostside-old [] command + options + -s eg -s/dev/ttyS0 normally necessary + -w usleep; 0 = no usleep; default is -1 = don't repeat at all + -i default is 0 = infinite; -1 means don't repeat + -f 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 diff --git a/hostside/main.c b/hostside/main.c index 1629a53..7f2cc6d 100644 --- a/hostside/main.c +++ b/hostside/main.c @@ -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"); diff --git a/hostside/nmra-packets.h b/hostside/nmra-packets.h index c0dfb07..480dac8 100644 --- a/hostside/nmra-packets.h +++ b/hostside/nmra-packets.h @@ -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- */ diff --git a/hostside/program-cv b/hostside/program-cv index 49ff618..46a36de 100755 --- a/hostside/program-cv +++ b/hostside/program-cv @@ -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 <