David Christensen <dpchr...@holgerdanske.com> writes: > Post a console session showing the commands issued and the error messages > produced.
I'll go you one better. I'll show the code of one of the programs that dies instantly. It uses /dev/ttyACM0 which is the device created when a Uniden scanner radio is plugged in to a usb port. I also have the program that controls a RS-232 modem and uses /dev/ttyS0 and gives the same results but contains more lines so let's go with the scanner program. Here's the console session short but not sweet. Script started on 2019-07-10 12:32:35-05:00 [TERM="linux" TTY="/dev/pts/7" COLUMNS="80" LINES="25"] 1wb5agz martin tmp $ p2 sts Can't call method "baudrate" on an undefined value at /home/martin/etc/p2 line 37. 2wb5agz martin tmp $ ls -l /dev/ttyACM0 crw-rw---- 1 root dialout 166, 0 Jul 10 08:32 /dev/ttyACM0 3wb5agz martin tmp $ exit Script done on 2019-07-10 12:33:21-05:00 [COMMAND_EXIT_CODE="0"] You used to only see that kind of response if /dev/ttyXXX was missing. On rare occasions, the scanner radio's tty would go away and one would need to umplug it and reseat the plug to get it back and it would then work. The rest is 66 lines of code for the scanner control program. #!/usr/bin/perl -w use strict; use warnings::unused; use File::Basename; use File::Copy; use File::Spec; use Time::Local; use Device::SerialPort; sub waitfor { #Receive from serial port. my $received = ""; our $port; until ( "" ne $received ) { $received = $port->lookfor; } return ($received); } #Receive from serial port. #no more sub routine code past this point #main global variables our @dbstrings; #main local variables my $response; my $cmd = ""; my $ONEARG = ""; #my $counter = 1; #Setup the comm port. my $dev = "/dev/ttyACM0"; our $instring = ""; our $port = Device::SerialPort->new("$dev"); $port->baudrate(115200); $port->databits(8); $port->parity("none"); $port->stopbits(1); $port->handshake("none"); $port->read_const_time(500); # 500 milliseconds = 0.5 seconds $port->are_match( "\r", "\n", ); # possible end strings foreach $ONEARG (@ARGV) { #each argument $ONEARG =~ s/^\s+//; $ONEARG =~ s/\s+$//; $cmd = $cmd . " " . $ONEARG; $cmd =~ s/^\s+//; $cmd =~ s/\s+$//; } #each argument $cmd = uc $cmd; $port->write("$cmd\r"); $instring = waitfor; my @chars = split( "", $instring ); foreach my $char (@chars) { # #print ord($char); if ( $char =~ /[\,\s\.\-\+\_0-9A-Za-z]/ ) { #printable $response = $response . $char; } #printable } # print "$response\n"; $instring = ""; exit(0);