_MONITORING DATA IN REAL TIME_ by Tony Garcia, Jeff Woodard, and Craig Liddell Listing One /**************************************************************************** ** Procedure: Call_Logger ** Purpose: Calls the CR10 datalogger and gets values of current temperatures. *****************************************************************************/ int targets::Call_Logger (){ unsigned dataval, status; int loop; _bios_serialcom (_COM_INIT, 1, _COM_CHR8 | _COM_STOP1 | _COM_NOPARITY | _COM_9600); loop = 0; status = 0xe000; dataval = 0; /* try to call the logger 10 times or until it responds */ while ((loop < 10) && (status == 0xe000)) { status = _bios_serialcom (_COM_SEND, 1, 0x000d); status = _bios_serialcom (_COM_SEND, 1, 0x000d); status = _bios_serialcom (_COM_SEND, 1, 0x000d); status = _bios_serialcom (_COM_RECEIVE, 1, dataval); status = _bios_serialcom (_COM_RECEIVE, 1, dataval); loop++; } /* end while */ /* if the initial connection to the logger has failed, then exit */ if (status != 0x000a) { error_flags[comm_error] = 1; return(-1); } /* end if */ status = _bios_serialcom (_COM_SEND, 1, (unsigned) '7'); status = _bios_serialcom (_COM_SEND, 1, (unsigned) 'H'); status = _bios_serialcom (_COM_SEND, 1, 0x000d); status = _bios_serialcom (_COM_RECEIVE, 1, dataval); status = _bios_serialcom (_COM_RECEIVE, 1, dataval); status = _bios_serialcom (_COM_SEND, 1, (unsigned) '*'); status = _bios_serialcom (_COM_RECEIVE, 1, dataval); /* M */ status = _bios_serialcom (_COM_RECEIVE, 1, dataval); /* O */ status = _bios_serialcom (_COM_RECEIVE, 1, dataval); /* D */ status = _bios_serialcom (_COM_RECEIVE, 1, dataval); /* E */ status = _bios_serialcom (_COM_SEND, 1, (unsigned) '6'); /* gets unneeded characters sent by the CR10, and alligns read sequence */ for (loop = 0; loop < 24; loop++) { status = _bios_serialcom (_COM_RECEIVE, 1, dataval); } /* end for */ /* actually reads the required values from the CR10 in *6 mode */ for (loop = 0; loop < 19; loop++){ Get_Value (loop); } /* logs off from the keypad mode of the CR10 */ status = _bios_serialcom (_COM_SEND, 1, (unsigned) '*'); status = _bios_serialcom (_COM_SEND, 1, (unsigned) '0'); status = _bios_serialcom (_COM_RECEIVE, 1, dataval); status = _bios_serialcom (_COM_SEND, 1, (unsigned) 'E'); error_flags[comm_error] = 0; return(1); } /* end Call_Logger */ /***************************************************************************** ** Procedure: Get_Value ** Purpose: This procedure reads and converts the values obtained from ** logger as they come across the com port. ** Return Value: ****************************************************************************/ void targets::Get_Value (int count){ char value[10]; int loop; unsigned dataval, status; dataval = 0; /* sends the 'A' keyboard command to CR10 */ status = _bios_serialcom (_COM_SEND, 1, (unsigned) 'A'); /* reads the cr lf sequence sent by logger in response */ status = _bios_serialcom (_COM_RECEIVE, 1, dataval); status = _bios_serialcom (_COM_RECEIVE, 1, dataval); /* reads the location label from CR10 and throws it away */ for (loop = 0; loop < 3; loop++){ status = _bios_serialcom (_COM_RECEIVE, 1, dataval); } /* reads the actual number value from the logger */ for (loop = 0; loop < 7; loop++) { status = _bios_serialcom (_COM_RECEIVE, 1, dataval); value[loop] = (char)status; } /* end for */ value[7] = '\0'; /* assigns the old value, and sets the new value */ last_cork[count] = corks[count]; /* checks to make sure an acceptable value is being assigned */ if ((atof (value) > -999) && (atof (value) < 999)){ corks[count] = atof (value); } } /* end Get_Value */ Listing Two #!/usr/local/bin/perl $old_name = "/jackal1/tonyself/current.tmp"; $new_temp = "/jackal1/tonyself/c.tmp"; $new_name = "/taipan5/pub-html/pathlab/temp.html"; $html_header = "/taipan5/pub-html/pathlab/html.tags"; $gc = "/jackal1/tonyself/gc.dat"; $gctemp = "/jackal1/tonyself/gc.tmp"; $html_head2 = "/taipan5/pub-html/pathlab/html2.tags"; $gchtml = "/taipan5/pub-html/pathlab/gc.html"; if(-e "$old_name"){ system "dos2unix", $old_name, $new_temp; system "/bin/cat $html_header $new_temp > $new_name"; system "/bin/chmod 644 $new_name"; } if(-e "$gc"){ system "dos2unix", $gc, $gctemp; system "/bin/cat $html_head2 $gctemp > $gchtml"; system "/bin/chmod 644 $gchtml"; }