#!/usr/bin/perl #file geiger.pl # # Author: David Drake # Date: July 18, 2003 # Requirements: Device::SerialPort 0.22 (from cpan July 2003) # # Version: 1.0 #This script is used to read a serial port to obtain data from a #combined Geiger counter and temperature sensor. #The Geiger Counter is an Aware Electronics RM-70 unit. Each count #maps to one microR per hour. The RM-70 pulse output is sent to a #Basic Stamp-IISX microcontroller. The BS2SX accumulates counts for 20 #seconds and then sends a serial data stream out of its serial port. #The data stream goes into the input serial port on the Linux system. #This program then tabulates the data to a log file. use Device::SerialPort; use Time::gmtime; $LOGDIR = "/home/drake/SerialPort_files"; # path to data file $LOGFILE = "geiger.log"; # file name to output to $PORT = "/dev/ttyS0"; # port to watch # # # Serial Settings # #make the serial port object #note the need to convert carriage returns to new lines to terminate each #read. $ob = Device::SerialPort->new ($PORT) || die "Can't Open $PORT: $!"; $ob->baudrate(9600) || die "failed setting baudrate"; $ob->parity("none") || die "failed setting parity"; $ob->databits(8) || die "failed setting databits"; $ob->stty_icrnl(1) || die "failed setting convert cr to new line" ; $ob->handshake("none") || die "failed setting handshake"; $ob->write_settings || die "no settings"; # # open the logfile, and Port # open(LOG,">>${LOGDIR}/${LOGFILE}") ||die "can't open smdr file $LOGDIR/$LOGFILE for append: $SUB $!\n"; select(LOG), $| = 1; # set nonbuffered mode, gets the chars out NOW open(DEV, "<$PORT") || die "Cannot open $PORT: $_"; # # Loop forver, logging data to the log file # while($_ = ){ # print input device to file $gmc = gmctime(); print LOG $gmc," ",$_; } undef $ob; #we are done dude