Re: Is snp(4) in working order?

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Thu, 19 Aug 2021 17:14:49 UTC
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.