Hi thanks for the reply, I thought of it so but then I view the codes and could not find any possibility that they could have cause the hang up. Below are the codes, would appreciate if you all help me take a look.

sub readXML{ # create object $xml = new XML::Simple (KeyAttr=>[]); # read XML file $data = $xml->XMLin($config_path . "sensors.xml"); } sub writeValueXML{ while(! (-x $config_path . "sensors.xml")){} #wait until other + process finish writing the file system("sudo chmod 644 $config_path" . "sensors.xml"); #set per +mission for root to rw only (exclusive write) my $output = new IO::File(">" . $config_path . "sensors.xml"); my $writer = new XML::Writer(OUTPUT => $output); my $flag = 0;; $count = 0; $writer->startTag("Sensors"); while($count < $DATANUM){ #write xml values $e = $data->{$sensor_type[$count]}; $writer->startTag("$sensor_type[$count]"); $writer->startTag("value"); $writer->characters($vars[$count]); $writer->endTag("value"); $writer->startTag("threshold"); $writer->characters($e->{threshold}); $writer->endTag("threshold"); $writer->endTag("$sensor_type[$count]"); if(($vars[$count]*1.0) > ($e->{threshold}*1.0)){ #*1 to for +ce it to float type if (-e $config_path . "SensorAlert.txt" && !$flag){ while(! (-x $config_path . "SensorAlert.txt")){} # +wait until other process finish writing the file unlink($config_path . "SensorAlert.txt"); #set perm +ission for root to rw only (exclusive write) } open WRITEFILE, "+>>", $config_path . "SensorAlert.txt"; print WRITEFILE "$count:$vars[$count]\n"; close(WRITEFILE); $flag++; } $count++; } $e = $data->{Weather_Data_Interval}; $writer->startTag("Weather_Data_Interval"); $writer->startTag("value"); $writer->characters($e->{value}); $writer->endTag("value"); $writer->endTag("Weather_Data_Interval"); $writer->endTag("Sensors"); $writer->end(); $output->close(); if($flag){ read_config_file; if ($config_data[10] ne "Sensors:disabled\n"){ $config_data[10] = "Sensors:true\n"; write_config_file; } system("sudo chmod 777 $config_path" . "SensorAlert.txt"); } system("sudo chmod 777 $config_path" . "sensors.xml"); } sub appendLoggedFile{ my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $da +yOfWeek, $dayOfYear, $daylightSavings) = localtime(); $year = 1900 + $yearOffset; my $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $month +s[$month] $dayOfMonth, $year"; open WRITEFILE, "+>>", $data_path . "$months[$month]_$dayOfMonth +" . "_SensorLog.txt" or die $!; print WRITEFILE $values . ",\t\t" . $theTime . "\n"; close(WRITEFILE); }

and roboticus, when the program hang, I end the process and use minicom to read from the port again, and the data is still transmittin. I cannot use 2 programs to read the same port at the same time, as it will say the port is being used by other process right now.

Thanks!


In reply to Re^2: Continusously reading from serial port by rustybar
in thread Continusously reading from serial port by rustybar

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.