Date: Thu, 19 Aug 2021 20:33:44 +0200 From: Gary Jennejohn <gljennjohn@gmail.com> To: Bertrand Petit <freebsd-hackers@phoe.frmug.org> Cc: freebsd-hackers@freebsd.org Subject: Re: Is snp(4) in working order? Message-ID: <20210819183344.358e1f55@ernst.home> In-Reply-To: <YR6RiRVXSTkFtIr%2B@kib.kiev.ua> References: <20210819141224.GA93701@memo2.memo.frmug.org> <YR6RiRVXSTkFtIr%2B@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 19 Aug 2021 20:14:49 +0300 Konstantin Belousov <kostikbel@gmail.com> wrote: > On Thu, Aug 19, 2021 at 04:12:24PM +0200, Bertrand Petit wrote: > > > > I'm wondering if, on a 12.2 host, the snp(4) device is out of order or > > if I'm improperly using it. > > > > Here is the situation: a GPS receiver connected to the host through > > USB (umodem driver) feeding ntpd and keeping it happy. On this setup I perform > > the following calls as root in a dedicated process: > > > > int a=open("/dev/cuaU0", O_RDONLY|O_NONBLOCK); > > isatty(a); /* Yes it is */ > > int b=open("/dev/snp", O_RDONLY); > > ioctl(b, SNPSTTY, &a); > > int pending; ioctl(b, FIONREAD, &pending); /* Empty */ > > char buf; read(b, 1, &buf); > > > > I ommited error handling for brevity, all calls are successfull except read() > > which never return. > > > > I expected to be able to read the same bytes stream as ntpd does but I > > get nothing. Am I misusing the snp(4) interface or is it non-functioning? > > > > [As a side note: I could also had used gpsd but hooking ntpd directly > > to the serial device yields a far better jitter.] > Did you tried watch(8) first? > > I just used watch successfully over /dev/pts/N pseudoterminal. > I thought about using watch(8) too. If nothing else, reading the source of /usr/src/usr.sbin/watch/watch.c will give you a good idea about how to correctly use snp(4) in your C-code. Pay particuar attention to how FIONREAD is used in main(). -- Gary Jennejohn
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20210819183344.358e1f55>