Hi,

On a FC3 box, log script launched with command
"perl - w -I $ScriptDir $ScriptName $Args < $Port > $Port",
and serial port initialize with "stty time 20 min 0 -icanon".
It worked fine at the beginning, but after a few of minutes, it couldn't read data througth serial port any more, just logged a few KB data. I can make sure that GPS outputs data to serial port every 30 seconds continuously.

Any ideas?

Here are the main parts of data logging script
sub LogData { $SessNum =0; $BuffLen = 1024; $TempFileName = ".temp.log"; $SiteName = ReadVar($ConfigFile,"SiteName","____"); $SessDuration = ReadVar($ConfigFile,"SessDuration",60); # Minutes $SessDuration *= 60*1000; # ms print STDERR "Open log file $TempFileName\n"; open(LOGFILE,">$TempFileName") or die "Can not open log file $Temp +FileName"; $SIG{INT} = \&catch_zap; # Install signall handler print "\$PASHQ,SNV\n\r"; # Query ephemeris undef $EndTime; LoggingData: while (not $Killed) { $ReadLen = 0; $timeout = 60; eval { local $SIG{ALRM} = sub { die "alarm\n" }; # NB \n require +d alarm $timeout; $ReadLen = read(STDIN,$Buff,$BuffLen); alarm 0; }; if ( $ReadLen > 0 ) { ($Time,$LastPbnPos) = CheckTime($Buff,$EndTime); $SetEndTime = 0; $SetEndTime = 1 if ( not defined($EndTime) and defined($Time) +); $SetEndTime = 2 if ( defined $LastPbnPos) ; $EndTime = $Time + ($SessDuration - $Time % $SessDuration ) if + ( $SetEndTime ); if ( $SetEndTime == 2 ) { # Write part of the buffer containing the PBN # with the given yime tag to the file and then close it $SplitPoint = $LastPbnPos + 58; $SplitPoint = $ReadLen if $SplitPoint > $ReadLen; $Head = substr($Buff,0,$SplitPoint); $Tail = substr($Buff,$SplitPoint); syswrite(LOGFILE,$Head,$SplitPoint); print STDERR "Close log file $TempFileName\n"; close(LOGFILE) or die "Can not close log file $FileName"; # Give the valid name to the temporary file $FileName = ComposeLogFileName($SiteName,$SessNum); print STDERR "Rename $TempFileName to $FileName\n"; rename ($TempFileName,$FileName) or die "Can not rename fil +es\n"; # Open the new file, write remainder of the buffer to it print STDERR "Open log file $TempFileName\n"; open(LOGFILE,">$TempFileName") or die "Can not open file $T +empFileName"; syswrite(LOGFILE,$Tail,$ReadLen - $SplitPoint); # Make sure we have ephemeris in the new file print "\$PASHQ,SNV\n\r"; ++$SessNum; } else { syswrite(LOGFILE,$Buff,$ReadLen); } } } if ( $Killed ) { print STDERR "Log processed killed, clean up...\n"; print STDERR "Close log file $TempFileName\n"; close(LOGFILE) or die "Can not close log file $FileName"; # Give the valid name to the temporary file $FileName = ComposeLogFileName("____",$SessNum); print STDERR "Rename $TempFileName to $FileName\n"; rename ($TempFileName,$FileName) or die "Can not rename files\n"; print STDERR "Delete ID file [$LogIdFile]\n"; unlink $LogIdFile; } } sub catch_zap { $Killed = 1; }

Edit: g0n - added readmore tags


In reply to Problem with logging raw data through serial port by jerryleo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.