# note, ive tried ttyS0 and S1, same error with both $port = '/dev/ttyS0'; # creates a hidden config file in user's home dir $config = '~/.conf'; # this tests for an existing config file, # and creates one if necessary... if(! -e $config) { $PortObj = new Device::SerialPort ($port) || die(RED,"Can't open $port: $^E\n",RESET); $PortObj->databits(7); $PortObj->baudrate(19200); $PortObj->parity("even"); $PortObj->stopbits(1); $PortObj->handshake("xoff"); $PortObj->buffers(4096, 4096); $PortObj->write_settings || undef $PortObj; $PortObj->save("$config"); $PortObj->close || die(RED,"failed to close",RESET); undef $PortObj; } # and this connects to the port by loading said # config file and tying to SERIAL filehandle $PortObj = tie (*SERIAL, 'Device::SerialPort', "$config") || die(RED,"Can't open $port: $^E\n",RESET); # use non-blocking read on serial port $PortObj->read_char_time(5); $PortObj->read_const_time(500); # create flag variables initialized to zero... my $EXIT = 0; # ...when a trapped system signal is sent, set flag to 1 $SIG{'INT'} = sub { $EXIT = 1 };