Dunker
29th August, 2010, 01:07 AM
Just having a bit of a rant. I have a USB to serial adapter (ID 1a86:7523), it gets picked up as a CH341 (to everyone else this is a HL-340 / CH340 but thats by the by). When inserted the ch341 and usbserial kernel modules are loaded as you would expect. I am writing a small perl prog to send a series of 5 characters to the USB serial port (bloody PC hasnt got a 9 pin). Heres a snippet:
#!/usr/bin/perl -w
use strict;
use Device::SerialPort;
my $port = Device::SerialPort->new("/dev/ttyUSB0");
$port->baudrate(300); <<< aaarghhh!!!
$port->parity("1");
$port->handshake("none");
$port->databits(7);
$port->stopbits(1);
$port->read_char_time(0);
$port->read_const_time(1);
# send data out
$port->write("/?!\r\n");
sleep(1);
The problem is that the baudrate will not change to anything lower than 2400. I thought I was cracking up at first but I have monitored the output with a digital storage scope and I can plainly see that settings of 2400, 4800, 9600 etc. work ok (the trace of the data sent reduces in horizontal size as the baudrate goes up as you would expect). Unfortunately setting the baudrate to anything less than 2400 does nothing - it leaves the rate at 2400.
Any ideas which driver is at fault here? Maybe a fresh look tomorrow minus the beer might help.
</rant>
#!/usr/bin/perl -w
use strict;
use Device::SerialPort;
my $port = Device::SerialPort->new("/dev/ttyUSB0");
$port->baudrate(300); <<< aaarghhh!!!
$port->parity("1");
$port->handshake("none");
$port->databits(7);
$port->stopbits(1);
$port->read_char_time(0);
$port->read_const_time(1);
# send data out
$port->write("/?!\r\n");
sleep(1);
The problem is that the baudrate will not change to anything lower than 2400. I thought I was cracking up at first but I have monitored the output with a digital storage scope and I can plainly see that settings of 2400, 4800, 9600 etc. work ok (the trace of the data sent reduces in horizontal size as the baudrate goes up as you would expect). Unfortunately setting the baudrate to anything less than 2400 does nothing - it leaves the rate at 2400.
Any ideas which driver is at fault here? Maybe a fresh look tomorrow minus the beer might help.
</rant>