From owner-freebsd-hackers Fri Oct 31 16:54:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id QAA17239 for hackers-outgoing; Fri, 31 Oct 1997 16:54:04 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from fly.HiWAAY.net (root@fly.HiWAAY.net [208.147.154.56]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id QAA17218 for ; Fri, 31 Oct 1997 16:54:00 -0800 (PST) (envelope-from dkelly@nospam.hiwaay.net) Received: from nospam.hiwaay.net (tnt1-88.HiWAAY.net [208.147.147.88]) by fly.HiWAAY.net (8.8.7/8.8.6) with ESMTP id SAA30506; Fri, 31 Oct 1997 18:53:57 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by nospam.hiwaay.net (8.8.7/8.8.4) with ESMTP id SAA08496; Fri, 31 Oct 1997 18:05:51 -0600 (CST) Message-Id: <199711010005.SAA08496@nospam.hiwaay.net> X-Mailer: exmh version 2.0zeta 7/24/97 To: "User Rdkeys Robert D. Keys" cc: freebsd-hackers@FreeBSD.ORG From: dkelly@hiwaay.net Subject: Re: Looking for ways to do serial datalogging on FreeBSD In-reply-to: Message from "User Rdkeys Robert D. Keys" of "Fri, 31 Oct 1997 14:14:12 EST." <199710311914.OAA07431@seedlab1.cropsci.ncsu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 31 Oct 1997 18:05:51 -0600 Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > If I wanted to use a serial port as a datalogging input port on FreeBSD, > from, for example a small outboard box emitting lines of data at 300 baud > continuously, what might be good ways to do that? > > Ideally, I would like to have a script or a small program running that > would poll the system clock, poll the port for a line of data at hourly > intervals, write that line to a logfile, then sit until the next hour, > and repeat, over the course of several weeks or months. Haven't tried this, but for starters: #!/bin/sh IFS="" # Hopefully a simple "echo" wakes up the data board # and prompts it to spit out its information. If not, then # its time to play with stty. echo read line # You could read the date into a DATE then echo "$DATE \c" # and get the line of data AND the date on the same line. # See "man date" to learn how to format date's output. date >> logfile echo $line >> logfile exit 0 Then execute the above in crontab every hour, or whenever, something like this: #min hr day mo dow command 1 * * * 1-7 script < /dev/cuaaX > /dev/cuaaX 2> stderr Make sure you don't have a getty on the port in /etc/ttys. And the user you run your process as has RW on the port you use. Set the sio parameters on /dev/cuaiaX rather than setting them every time you open the port. See /etc/rc.serial. Put your settings there so you survive and restart after a reboot. > Basically, all > it is a stripchart temperature recorder. On DOS, where the system > currently runs it is a few lines of code in C or Basic or Fortran. > I was thinking it would be neat to have my FreeBSD box do that, since > it is sitting in the lab across from where the temperatures are being > measured, and retire the aging DOS box. This is the kind of thing that's almost trivial for Unix. -- David Kelly N4HHE, dkelly@hiwaay.net ===================================================================== The human mind ordinarily operates at only ten percent of its capacity -- the rest is overhead for the operating system.