Is snp(4) in working order?

From: Bertrand Petit <freebsd-hackers_at_phoe.frmug.org>
Date: Thu, 19 Aug 2021 16:12:24 +0200
	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.]

-- 
%!PS -- Bertrand Petit
/D{def}def/E{exch}D/G{get}D/I{2 div}D/U{dup}D/L{roll}D/Y{setgray}D/N{newpath}D
/O{N 0 0 moveto}D/P{pop}D/T{translate}D currentpagedevice/PageSize G U 0 G/w E
D 1 G /h E D w I h I T 0 Y 1 setlinewidth 0 1 2 { P 120 rotate 2 4 w U mul h U
mul add sqrt I 50 add {N 50 0 3 2 L 0 360 arc stroke}for}for/s{O true charpath
pathbbox exch 4 -1 L E sub I 3 1 L sub I} D /l(bp)D 0.94 Y /Helvetica findfont
22 scalefont setfont l s P(x)s exch P T O l show showpage
Received on Thu Aug 19 2021 - 14:12:24 UTC

Original text of this message