CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Suppress error messages

 



ms10380
Novice

Mar 23, 2011, 6:10 AM

Post #1 of 2 (1886 views)
Suppress error messages Can't Post

How can I suppress error messages from printing to the screen? I have a script that is querying all the system COM ports to find which port a specific device is connected to. The problem is that if nothing is connected to that port, I receive “The system cannot find the file specified. can't open device: \\.\COM48” This prints out 250 times since I am checking all COM ports since I am never sure what port number the devices are connected to. A loop calls the code below that does the actual open



Code
sub open_serial_port { 
my $open_serial_port_com = shift;
if (not defined $port_object){
if (not $port_object=Win32::SerialPort->new('\\\\.\\'.$open_serial_port_com)) {return 1;}
print "$open_serial_port_com = $port_object\n";
$port_object->baudrate($COM_PORT_BAUDRATE);
$port_object->databits($COM_PORT_DATABITS);
$port_object->parity('none');
$port_object->stopbits($COM_PORT_STOPBIT);
$port_object->handshake('none');
$port_object->read_interval($COM_PORT_READ_INTERVAL);
$port_object->write_settings;
$port_object->read_const_time($READ_CONST_TIME);
}
return 0;
}



Karazam
User

Mar 23, 2011, 11:10 AM

Post #2 of 2 (1876 views)
Re: [ms10380] Suppress error messages [In reply to] Can't Post

Try


Code
$port_object = new Win32::SerialPort ('\\\\.\\'.$open_serial_port_com, $quiet)


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives