Subject: new TIODCDTIMESTAMP patch
To: None <thorpej@nas.nasa.gov>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: tech-kern
Date: 04/20/1998 16:38:58
Here you are, Jason. It's really up to you.  you can show us all how
professional you are by finding bugs and, this time, by telling the
person who wrote the patch that you found them. 

Or you can find bugs, *not* tell anybody about them, and then get on
your high horse when the bugs aren't fixed.

Other people have looked at this __three weeks__ ago, including bill
studenmund. How nice of you to waste our time by keeping the bugs
secret.  Are you professional enough to tell tech-kern (not just me)
or not?

I'd really prefer that you were. But it's up to you.




Index: com.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/com.c,v
retrieving revision 1.143
diff -c -r1.143 com.c
*** com.c	1998/03/22 00:55:37	1.143
--- com.c	1998/04/20 23:37:59
***************
*** 603,608 ****
--- 603,609 ----
  		com_modem(sc, 0);
  		(void) tsleep(sc, TTIPRI, ttclos, hz);
  	}
+ 	sc->sc_dcd_timestamping = 0;
  
  	/* Turn off interrupts. */
  #ifdef DDB
***************
*** 933,938 ****
--- 934,943 ----
  		*(int *)data = bits;
  		break;
  	}
+ 	case TIOCDCDTIMESTAMP:
+ 		com->sc_dcd_timestamping = 1;
+ 		*(struct timeval *)data = com->dcd_timestamp;
+ 		break;
  	default:
  		error = ENOTTY;
  		break;
***************
*** 1749,1754 ****
--- 1754,1777 ----
  		sc->sc_msr = msr;
  		if (ISSET(delta, sc->sc_msr_mask)) {
  			SET(sc->sc_msr_delta, delta);
+ 
+ 			/*
+ 			 * Check for timestamp on rising edge of clock.
+ 			 * NB: Some garmin uints use the falling rather than
+ 			 * rising edge as on-second signal. This should
+ 			 * be fixed in TTL-to-RS232 hardware, but some
+ 			 * setups don't do that.
+ 			 */
+ #ifdef PPS_TRAILING_EDGE
+ #define PPS_EDGE_SET(x, y) (!ISSET(x, y)
+ #else
+ #define PPS_EDGE_SET(x, y) ISSET(x, y)
+ #e
+ ndif
+ 			if (sc->sc_dcd_timestamping && ISSET(delta, MSR_DCD) &&
+ 			    PPS_EDGE_SET(msr, MSR_DCD)) {
+ 				microtime(&sc->sc_dcd_timestamp);
+ 			}
  
  			/*
  			 * Stop output immediately if we lose the output
Index: comvar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/comvar.h,v
retrieving revision 1.22
diff -c -r1.22 comvar.h
*** comvar.h	1998/02/02 23:01:05	1.22
--- comvar.h	1998/04/20 23:37:59
***************
*** 109,114 ****
--- 109,117 ----
  	void (*disable) __P((struct com_softc *));
  	int enabled;
  
+ 	int	sc_dcd_timestamping;		/* boolean flag */
+ 	struct timeval	sc_dcd_timestamp;
+ 
  #if NRND > 0 && defined(RND_COM)
  	rndsource_element_t  rnd_source;
  #endif