From nobody Thu Aug 19 14:12:24 2021 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9D4E8177B825 for ; Thu, 19 Aug 2021 14:14:06 +0000 (UTC) (envelope-from freebsd-hackers@phoe.frmug.org) Received: from frmug.org (enterprise.frmug.org [213.36.253.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gr6Fn4L9Nz4nbT for ; Thu, 19 Aug 2021 14:14:05 +0000 (UTC) (envelope-from freebsd-hackers@phoe.frmug.org) Received: by frmug.org (Postfix, from userid 66) id 3296E12B29F; Thu, 19 Aug 2021 16:14:04 +0200 (CEST) Received: by memo2.memo.frmug.org (Postfix, from userid 1001) id 6738317A40; Thu, 19 Aug 2021 16:12:24 +0200 (CEST) Date: Thu, 19 Aug 2021 16:12:24 +0200 From: Bertrand Petit To: freebsd-hackers@freebsd.org Subject: Is snp(4) in working order? Message-ID: <20210819141224.GA93701@memo2.memo.frmug.org> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) X-Rspamd-Queue-Id: 4Gr6Fn4L9Nz4nbT X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=frmug.org (policy=none); spf=neutral (mx1.freebsd.org: 213.36.253.97 is neither permitted nor denied by domain of freebsd-hackers@phoe.frmug.org) smtp.mailfrom=freebsd-hackers@phoe.frmug.org X-Spamd-Result: default: False [0.73 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.27)[-0.271]; DMARC_POLICY_SOFTFAIL(0.10)[frmug.org : No valid SPF, No valid DKIM,none]; R_SPF_NEUTRAL(0.00)[?all:c]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MID_RHS_MATCH_FROMTLD(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_SPAM_LONG(1.00)[1.000]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:12322, ipnet:213.36.0.0/16, country:FR]; SUBJECT_ENDS_QUESTION(1.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N 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