Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Oct 1997 18:05:51 -0600
From:      dkelly@hiwaay.net
To:        "User Rdkeys Robert D. Keys" <rdkeys@seedlab1.cropsci.ncsu.edu>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Looking for ways to do serial datalogging on FreeBSD 
Message-ID:  <199711010005.SAA08496@nospam.hiwaay.net>
In-Reply-To: Message from "User Rdkeys Robert D. Keys" <rdkeys@seedlab1.cropsci.ncsu.edu>  of "Fri, 31 Oct 1997 14:14:12 EST." <199710311914.OAA07431@seedlab1.cropsci.ncsu.edu> 

next in thread | previous in thread | raw e-mail | index | archive | help
> 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.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711010005.SAA08496>