PDA

View Full Version : Fu@#ki&% Linux AGAIN!



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>

Dunker
30th August, 2010, 06:34 PM
Sussed it in case anyone else has a similar problem... Crap ch341 driver. I've cobbled together a FDTI USB to serial interface and the FDTI drivers work ok and I can change the baudrate.

radu_gostian
8th September, 2010, 02:15 PM
Probably the USB - > Serial device doesn't support all boudrates. Try searching for different kernel module (it also can be a hardware limitation so better try with an other device)

jeff114
17th September, 2010, 05:17 AM
Hello
you can try to set your ttyUSB0 with this scritp:


#!/bin/sh
(
stty 300
stty cs8
stty -parenb
stty -parodd
stty -clocal
stty crtscts
stty -echo
) < /dev/ttyUSB0 > /dev/ttyUSB0
in this sample:
300 = speed
cs8 = 8 bits data
-parenb
-parodd
= no parity
-clocal = not local (modem DCD, DTR)
crtscts = hardware flow control
-echo = no local echo

Regards,
jeff