[ntp:hackers] /dev/ntpsymlink1 -> COM1: for ntpd on Windows

Dave Hart davehart at gmail.com
Sun May 31 09:01:05 UTC 2009


I'm planning to check in changes to ports/winnt/ntpd/win32_io.c
common_serial_open() in the near future to implement this mapping to
minimize source changes to reference clock drivers, unless there is an
objection.

Cheers,
Dave Hart

P.S.  Thanks to Hal V. Engel <hvengel at ...> for assistance testing this
change unwillingly along with attempted fixes for another issue.

---------- Forwarded message ----------
From: Dave Hart <davehart at gmail.com>
Date: Thu, May 28, 2009 at 1:51 PM
Subject: refclock device names on Windows
To: Mailing list for people with source code commit privileges
<committers at lists.ntp.org>, "David L. Mills" <mills at udel.edu>


Most reference clocks have source code something like this:

#define DEVICE          "/dev/wwvb%d" /* device name and unit */
...
       sprintf(device, DEVICE, unit);
       if (!(fd = refclock_open(device, SPEED232, LDISC_CLK)))
...

The (very few) which have been adapted to work on Windows use
something like this:

#ifdef SYS_WINNT
# define DEVICE "COM%d:"        /* COM 1 - 3 supported */
#else
# define DEVICE "/dev/gps%d"    /* name of radio device */
#endif

With Windows refclock serial support code in Windows now approaching
respectability, I'd like to enable most reference clocks on Windows.
Rather than spread copies of that latter bit of code into more
drivers, I propose changing reflcock_open on Windows to no longer
require the correct native device name, and in particular, to support
Unix-style device names by looking for a leading '/', and in that case
use all trailing digits and ignore the rest, so that /dev/gps1 opens
COM1:, while /dev/refclock22 opens COM22:

That will of course not support symbolic links, still, on Windows, but
preserve existing behavior while allowing the #ifdef SYS_WINNT related
to DEVICE to go away.

Any comments?

Cheers,
Dave Hart


More information about the hackers mailing list