Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider command line option for other SHM addresses #9

Open
jshuggins opened this issue Nov 24, 2020 · 2 comments
Open

Consider command line option for other SHM addresses #9

jshuggins opened this issue Nov 24, 2020 · 2 comments

Comments

@jshuggins
Copy link

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.

@jorgedsmatias
Copy link
Contributor

jorgedsmatias commented May 5, 2022

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;

@jorgedsmatias
Copy link
Contributor

jorgedsmatias commented May 5, 2022

Just created Pull Request #10 to add this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants