Hi, this is Shin-ichiro KAWASAKI My usb-to-serial converter (pl2303) shows similar problem as dave found. When I put a string with command 'echo hello > /dev/ttyUSB0', string 'hello' is sent correctly, but the echo command stop working and do not return to command prompt.
I found that 'echo -n hello> /dev/ttyUSB0' works well. The option '-n' suppresses sending newline, so the newline code seems to causes the problem. And as dave mentioned, only if terminal's options OPOST and ONLCR is enabled, this problem happens. I'll try to explain this as follows (a little bit long text). I hope it would clarify the problem. --------------------------------------------------------------------------- When the echo command write 'hello\n', the function write_chan() in 'dirvers/char/n_tty.c' is called. Then write_chan() calls opost_block() to write the string, but opost_block() write only five bytes 'hello' and do not write '\n'. So write_chan() calls opost() to send '\n', which converts '\n' into '\r' and '\n'. 1st, the string 'hello' is sent correctly by the function pl2303_write(). 2nd, opost() checks if write() will success or not with serial_write_room() function (usbserial.c), but the driver is busy to send the string 'hello', so serial_write_room() returns zero. So opost() do not send '\n'. 3rd, after calling schedule(), write_chan() calls not 'opost()' but 'opost_block()' to try to send '\n' again. Same as before, opost_block() do not write '\n', but try to write ZERO LENGTH string because the string '\n' has zero length when you subtract '\n' from it. This is the reason why many zero length write is logged in debug print. In pl2303_write(), length of data is not checked, so pl2303 driver gets busy again to send zero length data. 4th, opost() calls serial_write_room() and finds that the pl2303 driver is busy. So '\n' is not sent. 3rd and 4th procedures will be repeated eternally. --------------------------------------------------------------------------- Loading both 'usbserial' and 'pl2303' with debug=1 option, it will be clearer. The log is as follows. --------------------------------------------------------------------------- Sep 12 12:45:46 localhost kernel: usb.c: registered new driver serial Sep 12 12:45:46 localhost kernel: usbserial.c: none matched Sep 12 12:45:46 localhost kernel: usbserial.c: USB Serial support registered for Generic Sep 12 12:45:46 localhost kernel: usbserial.c: none matched Sep 12 12:45:46 localhost kernel: usbserial.c: USB Serial Driver core v1.4 Sep 12 12:45:50 localhost kernel: usbserial.c: USB Serial support registered for PL-2303 Sep 12 12:45:50 localhost kernel: usbserial.c: descriptor matches Sep 12 12:45:50 localhost kernel: usbserial.c: found interrupt in Sep 12 12:45:50 localhost kernel: usbserial.c: found bulk out Sep 12 12:45:50 localhost kernel: usbserial.c: found bulk in Sep 12 12:45:50 localhost kernel: usbserial.c: PL-2303 converter detected Sep 12 12:45:50 localhost kernel: usbserial.c: get_free_serial 1 Sep 12 12:45:50 localhost kernel: usbserial.c: get_free_serial - minor base = 0 Sep 12 12:45:50 localhost kernel: usbserial.c: usb_serial_probe - setting up 1 port structures for this device Sep 12 12:45:50 localhost kernel: usbserial.c: PL-2303 converter now attached to ttyUSB0 (or usb/tts/0 for devfs) Sep 12 12:45:50 localhost kernel: usb.c: serial driver claimed interface dd1d2540 Sep 12 12:45:50 localhost kernel: pl2303.c: Prolific PL2303 USB to serial adaptor driver v0.9 Sep 12 12:45:58 localhost kernel: usbserial.c: serial_open Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_open - port 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0xc0:0x1:0x8484:0x0 1 - 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0x40:0x1:0x404:0x0 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0xc0:0x1:0x8484:0x0 1 - 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0xc0:0x1:0x8383:0x0 1 - 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0xc0:0x1:0x8484:0x0 1 - 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0x40:0x1:0x404:0x1 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0xc0:0x1:0x8484:0x0 1 - 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0xc0:0x1:0x8383:0x0 1 - 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0x40:0x1:0x0:0x1 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0x40:0x1:0x1:0xc0 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0x40:0x1:0x2:0x4 0 Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_set_termios - port 0, initialized = 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0xa1:0x21:0:0 7 - 80 25 0 0 0 0 8 Sep 12 12:45:58 localhost kernel: pl2303.c: 0x40:1:0:1 0 Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_set_termios - data bits = 8 Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_set_termios - baud = 9600 Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_set_termios - stop bits = 1 Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_set_termios - parity = none Sep 12 12:45:58 localhost kernel: pl2303.c: 0x21:0x20:0:0 7 Sep 12 12:45:58 localhost kernel: pl2303.c: set_control_lines - value = 3, retval = 0 Sep 12 12:45:58 localhost kernel: pl2303.c: 0xa1:0x21:0:0 7 - 80 25 0 0 0 0 8 Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_open - submitting read urb Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_open - submitting interrupt urb Sep 12 12:45:58 localhost kernel: usbserial.c: serial_write_room - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: generic_write_room - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: generic_write_room - returns 64 Sep 12 12:45:58 localhost kernel: usbserial.c: serial_write - port 0, 5 byte(s) Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_write - port 0, 5 bytes Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_write - length = 5, data = 68 65 6c 6c 6f Sep 12 12:45:58 localhost kernel: usbserial.c: serial_write_room - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: generic_write_room - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: generic_write_room - returns 0 Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_write_bulk_callback - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: port_softint - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: serial_write_room - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: generic_write_room - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: generic_write_room - returns 64 Sep 12 12:45:58 localhost kernel: usbserial.c: serial_write - port 0, 0 byte(s) Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_write - port 0, 0 bytes Sep 12 12:45:58 localhost kernel: pl2303.c: pl2303_write - length = 0, data = Sep 12 12:45:58 localhost kernel: usbserial.c: serial_write_room - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: generic_write_room - port 0 Sep 12 12:45:58 localhost kernel: usbserial.c: generic_write_room - returns 0 (same messages repeat...) --------------------------------------------------------------------------- I wish pl2303.c would accept write request while the device is busy. Regards, shin -- Hitachi, Ltd. Systems Development Lab. 405 Unit Shin-ichiro KAWASAKI [EMAIL PROTECTED] Intra. Tel, 869-3455 (since Aug. 1st) ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
