From linux-activists@joker.cs.hut.fi Tue Nov  9 12:28:58 1993
Date: Tue, 9 Nov 1993 01:12:31 +0200
From: Linux Activists <linux-activists@joker.cs.hut.fi>
To: Linux-Activists <linux-activists@joker.cs.hut.fi>
Subject: Linux-Activists - KERNEL Channel digest. 93-10-8-19:44


Topics:
	 New tty line discipline for radio clock receivers


----------------------------------------------------------------------

From: koenig@ceres.tat.physik.uni-tuebingen.de (Harald Koenig)
Subject: New tty line discipline for radio clock receivers
Date: Mon, 8 Nov 1993 20:10:15 +0200



Hi,

I added a new tty line discipline N_DCF (DCF is a german radio clock
transmitter) which inserts a time time stamp (struct timeval) after
each incoming  character. This is quite usefull for time
synchronisation to an external clock or radio clock receiver.

All comments on this topic and code are welcome,

Harald

-------------------------------------------------------------------------------
--- ./include/linux/termios.h.orig	Tue Sep  7 02:41:16 1993
+++ ./include/linux/termios.h	Fri Nov  5 14:40:38 1993
@@ -237,5 +237,6 @@
 #define N_TTY		0
 #define N_SLIP		1
 #define N_MOUSE		2
+#define N_DCF		3
 
 #endif
--- ./drivers/char/tty_io.c.orig	Mon Oct 18 13:20:50 1993
+++ ./drivers/char/tty_io.c	Fri Nov  5 15:55:48 1993
@@ -1660,6 +1660,7 @@
 	/* Setup the default TTY line discipline. */
 	memset(ldiscs, 0, sizeof(ldiscs));
 	(void) tty_register_ldisc(N_TTY, &tty_ldisc_N_TTY);
+	(void) tty_register_ldisc(N_DCF, &tty_ldisc_N_TTY);
 
 	kmem_start = kbd_init(kmem_start);
 	kmem_start = con_init(kmem_start);
--- ./drivers/char/serial.c.orig	Wed Nov  3 20:23:35 1993
+++ ./drivers/char/serial.c	Sat Nov  6 16:55:51 1993
@@ -323,6 +323,11 @@
 {
 	struct tty_queue * queue;
 	int head, tail, ch;
+#ifdef N_DCF
+	int i, disc = info->tty->disc;
+	struct timeval tv;
+	extern void do_gettimeofday(struct timeval *tv);
+#endif /* N_DCF */
 
 /*
  * Just like the LEFT(x) macro, except it uses the loal tail
@@ -335,6 +340,14 @@
 	tail = queue->tail;
 	do {
 		ch = serial_inp(info, UART_RX);
+#ifdef N_DCF
+		if (disc == N_DCF) {
+		  do_gettimeofday(&tv);
+		  if (VLEFT < 2 + sizeof(struct timeval))
+		    break;
+		}
+		else 
+#endif /* N_DCF */
 		/*
 		 * There must be at least 2 characters
 		 * free in the queue; otherwise we punt.
@@ -354,6 +367,14 @@
 		}
 		queue->buf[head++] = ch;
 		head &= TTY_BUF_SIZE-1;
+#ifdef N_DCF
+		if (disc == N_DCF) {
+		  for(i=0; i<sizeof(tv); i++) {
+		    queue->buf[head++] = ((char*)(&tv))[i];
+		    head &= TTY_BUF_SIZE-1;
+		  }
+		}
+#endif /* N_DCF */
 	} while ((*status = serial_inp(info, UART_LSR)) & UART_LSR_DR);
 	queue->head = head;
 	if ((VLEFT < RQ_THRESHOLD_LW) && !set_bit(TTY_RQ_THROTTLED,
--- ./kernel/time.c.orig	Tue Oct 12 16:24:45 1993
+++ ./kernel/time.c	Sat Nov  6 16:31:45 1993
@@ -164,7 +164,7 @@
 /*
  * This version of gettimeofday has near microsecond resolution.
  */
-static inline void do_gettimeofday(struct timeval *tv)
+inline void do_gettimeofday(struct timeval *tv)
 {
 #ifdef __i386__
 	cli();
-------------------------------------------------------------------------------

-- 
Harald Koenig, Inst.f.Theoret.Astrophysik  (koenig@tat.physik.uni-tuebingen.de)

    All SCSI disks will from now on be required to send an email
         notice 24 hours prior to complete hardware failure!




------------------------------

End of KERNEL Digest
********************
-------
