in reply to Cannot write to, or read from, the SerialPort

Always Use strict and warnings!

# I tried each of the below my $port = Device::SericalPort->new ...Lin +es of Code. #my $port = Device::SerialPort->new("/dev/cu.usbserial"); #my $port = Device::SerialPort->new("/dev/tty.usbserial"); #my $port = Device::SerialPort->new("/dev/ttys0");

You should use the same device name that works in your other scripts.

#$port->write_settings || undef $port;

Why did you commment this out? Try uncommenting this.

Although I've used Device::SerialPort successfully in the past, I now strongly recommend IO::Termios on *NIX systems instead - see my post Lower-Level Serial Port Access on *NIX.

Replies are listed 'Best First'.
Re^2: Cannot write to, or read from, the SerialPort
by macdev (Initiate) on Jun 16, 2022 at 16:59 UTC
    01. Thank you for viewing the Code and replying.

    02. In my Python Code the following is used: 'lSer=serial.Serial('/dev/cu.usbserial', 4800)' is used.

    With respect to the following Lines of Code ...
    my $port = Device::SerialPort->new("/dev/cu.usbserial"); my $port = Device::SerialPort->new("/dev/tty.usbserial"); my $port = Device::SerialPort->new("/dev/ttys0"); my $port = Device::SerialPort->new("/dev/ttys1");
    Thus, the need for the commented out Lines of Code, of the unwanted Lines. I was trying any Driver I thought may work.

    03. Viewing various Perl Code Examples ...
    $port->write_settings || undef $port;
    ... was not in some of the Example Code. Thus, I tried my Perl Code with / without 'port->write_settings' used.
    I just happened to comment out that Line of Code, on my last Test, before posting my Request.

    I will make sure in any new Code, to use: $port->write_settings || undef $port;

    04. I am looking into the 'IO::Termios' Module and your 'Lower-Level Serial Port Access on *NIX' Post; thank you for the Suggestions.