summaryrefslogtreecommitdiff
path: root/sbin/ldattach/ldattach.c
diff options
context:
space:
mode:
authorMarc Balmer <mbalmer@cvs.openbsd.org>2008-01-05 17:33:29 +0000
committerMarc Balmer <mbalmer@cvs.openbsd.org>2008-01-05 17:33:29 +0000
commit2a0eec3d922ea9fda272a0a239ac6eb30cadc40b (patch)
treed48c394d5a9db8c4f953389e4ff44df8005b4fbb /sbin/ldattach/ldattach.c
parentf1d430b3cf60f8e6d4f5810bcde9bc17bd36ac8c (diff)
Add support for the Meinberg Standard Time String format that all Meinberg
radio clocks can transmit over serial ports. This is implemented as a line discipline similar to nmea(4) and provides a timedelta sensor. See http://www.meinberg.de/english/specs/timestr.htm for details on the MSTS format. ldattach(8) is extended to support the "msts" line discipline and two stopbits (which some radio clocks, e.g. the C51 use). Do a "make includes" before your next system build. Initially from Maurice Janssen based on nmea(4). "go for it" deraadt
Diffstat (limited to 'sbin/ldattach/ldattach.c')
-rw-r--r--sbin/ldattach/ldattach.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sbin/ldattach/ldattach.c b/sbin/ldattach/ldattach.c
index eb8ae9a1eef..19667b08ed7 100644
--- a/sbin/ldattach/ldattach.c
+++ b/sbin/ldattach/ldattach.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: ldattach.c,v 1.3 2007/11/13 19:32:34 mbalmer Exp $ */
+/* $OpenBSD: ldattach.c,v 1.4 2008/01/05 17:33:28 mbalmer Exp $ */
/*
- * Copyright (c) 2007 Marc Balmer <mbalmer@openbsd.org>
+ * Copyright (c) 2007, 2008 Marc Balmer <mbalmer@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -47,7 +47,7 @@ usage(void)
{
extern char *__progname;
- fprintf(stderr, "usage: %s [-7dehmo] [-s baudrate] "
+ fprintf(stderr, "usage: %s [-27dehmo] [-s baudrate] "
"[-t cond] discipline device\n", __progname);
exit(1);
}
@@ -61,7 +61,7 @@ main(int argc, char *argv[])
sigset_t sigset;
pid_t ppid;
int ch, fd, ldisc, nodaemon = 0;
- int bits = 0, parity = 0, flowcl = 0, hupcl = 1;
+ int bits = 0, parity = 0, stop = 0, flowcl = 0, hupcl = 1;
speed_t speed = 0;
char devn[32], *dev, *disc;
@@ -70,8 +70,11 @@ main(int argc, char *argv[])
if ((ppid = getppid()) == 1)
nodaemon = 1;
- while ((ch = getopt(argc, argv, "7dehmos:t:")) != -1) {
+ while ((ch = getopt(argc, argv, "27dehmos:t:")) != -1) {
switch (ch) {
+ case '2':
+ stop = 2;
+ break;
case '7':
bits = 7;
break;
@@ -143,6 +146,8 @@ main(int argc, char *argv[])
ldisc = NMEADISC;
if (speed == 0)
speed = B4800; /* default is 4800 baud for nmea */
+ } else if (!strcmp(disc, "msts")) {
+ ldisc = MSTSDISC;
} else {
syslog(LOG_ERR, "unknown line discipline %s", disc);
goto bail_out;
@@ -180,6 +185,11 @@ main(int argc, char *argv[])
else
tty.c_cflag &= ~PARODD;
+ if (stop == 2)
+ tty.c_cflag |= CSTOPB;
+ else
+ tty.c_cflag &= ~CSTOPB;
+
if (flowcl)
tty.c_cflag |= CRTSCTS;