[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#704242: Driver for PL-2303 HX not working



On Fri, Apr 19, 2013 at 09:25:19AM +0200, Karsten Malcher wrote:
> Am 18.04.2013 11:35, schrieb Johan Hovold:
> >> I have used a little perl program that opens the port and send "Test"
> >> to the looped back device.
> >> The length of the log looks good.
> > Great. Now I can see what's going on. The only problem (?) is that
> > everything seems to be working. The write succeeds and the four bytes
> > are read back as they should by the driver.
> 
> But where the data has gone?
> With cutecom i can see that some of the first bytes are looped back.
> 
> It must be possible to read any binary (streamed) data.

Yes, but not in canonical mode as then the input is buffered by the
kernel tty-layer until certain characters are encountered.

> > The first thing that comes to mind that could prevent you from reading
> > the received data would be if the tty device is configured for canonical
> > input processing. Have you made sure this is not the case? Can you read
> > the data back if you add a newline to your test string (e.g. "test\n")?
> 
> Hmmn - i don't know which method is used by programs like cutecom or putty?

Unless it's configurable it should be non-canonical mode.

> But i know everything works fine before.
> In this programs every data is terminated with newline, but it does not work.

You mean that you updated your test program so that it writes "test\n"
but it still does not work?

> >> I use this script with a ch341 adapter and it works.
> > Hmmm. Did you remember to initialise the device (e.g. set the termios
> > flags)?
> 
> Here you can see what's initialized in Perl:
> 
> use Device::SerialPort 0.12;
> 
> $port->baudrate(9600)   || die "failed setting baudrate";
> $port->parity("none")    || die "failed setting parity";
> $port->databits(8)       || die "failed setting databits";
> $port->handshake("none") || die "failed setting handshake";
> $port->write_settings    || die "could not write settings";
> $port->lookclear         || die "could not empty buffer";
> $port->read_char_time(0);        # don't wait for each character
> $port->read_const_time(1000);        # 1 second per unfulfilled "read" call
> my $STALL_DEFAULT = 1;            # how many seconds to wait for new input

I don't use perl so can't help you there. Search for perl and icanon or
something.

You can use stty to determine if canonical-mode is enabled; the output
of 'stty -aF /dev/ttyUSB0' contains "icanon" if enabled and "-icanon"
otherwise. By default it is enabled. 

You should also make sure that VMIN and VTIME are initialised in
non-canonical mode. Specifically, if VMIN is greater than the number of
characters written by your test program over the loopback and VTIME is
0, read will block also in non-canonical mode.

Johan


Reply to: