OpenBSD Journal

[c2k8]: ldattach(8) can pass data to a pty(4) pair

Contributed by merdely on from the what's-the-c-in-c2k8-stand-for? dept.

Marc Balmer (mbalmer@) writes from c2k8:

The ldattach(8) command was just extended to pass the data it receives from a device to the master device of a pty(4) pair. When started with the new '-p' command line option, ldattach(8) outputs the name of the pty(4) slave device (the 'tty' part of a pty/tty pair) on the console. A userland application can then open this tty device to peek at the NMEA data.

Marc continues below.

This is especially useful with a GPS receiver: ldattach(8) attaches the nmea(4) line discipline and gives us a precise reference clock for ntpd(8). At the same time any application that understands the NMEA protocol can use the NMEA data as well by opening the tty that was output by ldattach(8) as the NMEA source.

There are at least gpsd and xastir in our ports tree that can make use of this new feature.

Besides the commit to deprecate slattach(8), here is the ldattach commit message:

CVSROOT:	/cvs
Module name:	src
Changes by:	mbalmer@cvs	2008/06/09 15:06:10

Modified files:
	sbin/ldattach  : Makefile ldattach.8 ldattach.c 
Added files:
	sbin/ldattach  : atomicio.c atomicio.h 

Log message:
Add the '-p' option to ldattach(8) to pass data received from the device
to the master device of a pty(4) pair.  The name of the slave device is
written to standard output.

This is useful for applications like e.g. gpsd from the misc/gpsd port
that also use the serial data stream (e.g. nmea(4) as a time source and
gpsd to get at positional data).

help and ok deraadt, makes ckuethe happy.

Since the work on ldattach(8) also deprecates nmeaattach(8), Marc adds:

If you are using a GPS device with nmeaattach(8), please switch to ldattach(8) now.

The nmeaattach command has been removed in -current, so has the nmeaattach_flags option in /etc/rc.conf (replaced with ldattach_flags).

Please note that ldattach(8) has a slightly different synopsis than nmeaattach(8) had: 'nmeaattach cuaU0' becomes 'ldattach nmea cuaU0'

This is the first in what hopes to be a series of articles covering the 2008 General Hackathon. Please stay tuned.

(Comments are closed)


Comments
  1. By Motley Fool (MotleyFool) motleyfool@dieselrepower.org on

    YEA!!!

    c2k8 has started, looking forward to info updates.

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]