From nobody Thu Aug 19 17:14:49 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 CAA4C12DE4AD for ; Thu, 19 Aug 2021 17:15:03 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 4GrBGb3VlDz3GDS for ; Thu, 19 Aug 2021 17:15:03 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 17JHEokr036365 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 19 Aug 2021 20:14:53 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 17JHEokr036365 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 17JHEndD036364; Thu, 19 Aug 2021 20:14:49 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 19 Aug 2021 20:14:49 +0300 From: Konstantin Belousov To: Bertrand Petit Cc: freebsd-hackers@freebsd.org Subject: Re: Is snp(4) in working order? Message-ID: References: <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=us-ascii Content-Disposition: inline In-Reply-To: <20210819141224.GA93701@memo2.memo.frmug.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4GrBGb3VlDz3GDS X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N 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.