#!/usr/bin/perl #the ubiquitous RS-232 Serial Port. built an interface #for my Aware Electronics Geiger Counter (RM-70) that #used a Basic Stamp IISX chip set. Every 20 seconds it #would spit out an ASCII string of radiation and #temperature data. I had hunted around for examples #using the Device::SerialPort module and found many. #Most were copies of code used to read PBX data. But #it wouldn't work. Ouch. Finally, after much research #I realized that - by golly - you had to terminate #the IO with a new line and not a carriage return. #Oddly doing a cat 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