radioclkd2
radioclkd2 copied to clipboard
Consider command line option for other SHM addresses
I needed to use SHM channel 2 so modified shm.h as shown below...
// ntpd shared memory reference clock driver structure
#define SHM_KEY 0x4e545032
Easy enough, but perhaps making this a command line argument would help put this parameter in a calling start script rather than hard coded into the binary.
I also needed this feature. So I developed a small change to the code that I have been using in Raspberry Pi to receive DCF77 and MSF at the same time running two instances of radioclkd2.
diff --git a/main.c b/main.c
index f31abf5..aab6a9d 100644
--- a/main.c
+++ b/main.c
@@ -126,7 +126,7 @@ void
usage (void)
{
printf (
-"Usage: radioclkd2 [ -s poll|iwait|timepps ] [ -t dcf77|msf|wwvb ] [ -d ] [ -v ] tty[:[-]line[:fudgeoffs]] ...\n"
+"Usage: radioclkd2 [ -s poll|iwait|timepps ] [ -t dcf77|msf|wwvb ] [ -n <shm start unit> ] [ -d ] [ -v ] tty[:[-]line[:fudgeoffs]] ...\n"
" -s poll: poll the serial port 1000 times/sec (poor)\n"
" -s iwait: wait for serial port interrupts (ok)\n"
" -s timepps: use the timepps interface (good)\n"
@@ -145,6 +145,7 @@ usage (void)
" -t dcf77: 77.5KHz Germany/Europe DCF77 Radio Station (default)\n"
" -t msf: UK 60KHz MSF Radio Station\n"
" -t wwvb: US 60KHz WWVB Fort Collins Radio Station\n"
+" -n shm#: NTP shared memory start unit - default is 0\n"
" -d: debug mode. runs in the foreground and print pulses\n"
" -v: verbose mode.\n"
" tty: serial port for clock\n"
@@ -241,7 +242,6 @@ main ( int argc, char** argv )
argv++;
parm = argv[0];
}
-
if ( strcasecmp ( parm, "dcf77" ) == 0 )
clocktype = CLOCKTYPE_DCF77;
else if ( strcasecmp ( parm, "msf" ) == 0 )
@@ -260,6 +260,28 @@ main ( int argc, char** argv )
verboseLevel ++;
break;
+ case 'n':
+ if ( strlen(arg) > 2 )
+ {
+ parm = arg + 2;
+ }
+ else
+ {
+ argc--;
+ argv++;
+ parm = argv[0];
+ }
+
+ if ( strcasecmp ( parm, "0" ) == 0 )
+ shmunit = 0;
+ else if ( strcasecmp ( parm, "1" ) == 0 )
+ shmunit = 1;
+ else if ( strcasecmp ( parm, "2" ) == 0 )
+ shmunit = 2;
+ else
+ usage();
+ break;
+
default:
usage();
break;
Just created Pull Request #10 to add this feature.