Re: Driver CH341 USB Adapter Serial Port not Works in Linux
By testing, sometimes even when ENQ command, if they leave these four lines: ch341_update_line_status - multiple status change ch341_update_line_status - delta = 0x01 ch341_update_line_status - multiple status change ch341_update_line_status - delta = 0x01 Always gives Timeout. Apparently there is the problem ... I think XD. The problem with the driver gives me the kernel 3.12.6 original, a despairing attempt to update the two files you mentioned, but still always feel the same. Always respond timeout. 2014-04-14 1:02 GMT-04:30 Kijam López kija...@gmail.com: All commands and responses are formatted: STX data ETX LRC (I replace No printable Char for [space]0xXX[space]) If I sent a ENQ answers his state, which is 2 bytes, so replies: 0x02 `@ 0x03 # (`@ is a two-byte mask representing the internal state of the device) If sending the S1 command, which is 0x02 S1 0x03 a, I should say something like this: 0x02 S100 0x0A 0 0x0A 0479 0x0A 0 0x0A 0330 0x0A 0 0x0A 0061 0x0A 0x0A X- 0x0A X 0x0A 221715 0x0A 120414 0x0A 0x03 0x1B In Windows OS, it works perfectly with the same PC and the same USB adapter. But Linux is not responding. Or respond but the driver is not interpreted correctly. My Kernel is 3.12.6, but i updated from GitHub this file an rebuild this drivers: https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c https://github.com/torvalds/linux/blob/master/drivers/usb/serial/usb-serial.c (commit d9a38a8741fdffabc32e6d0943b1cdcf22712bec) 2014-04-14 0:53 GMT-04:30 Greg KH gre...@linuxfoundation.org: On Mon, Apr 14, 2014 at 12:16:40AM -0430, Kijam López wrote: I reported here: https://bugreports.qt-project.org/browse/QTBUG-38305 But just migrate my APP to ANSI C and is exactly the same. My code test in ANSI C: snip Test command: Fail I'm confused, what should it do? And what kernel version are you using here? thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Driver CH341 USB Adapter Serial Port not Works in Linux
As a side note, I mentioned in a previous post, but remember, the delta = 0x01 I print, not the original driver. In https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c file on line 464 approximately, I wrote: dev_info(port-dev, %s - delta=0x%02X\n, __func__, delta); 2014-04-14 2:06 GMT-04:30 Kijam López kija...@gmail.com: By testing, sometimes even when ENQ command, if they leave these four lines: ch341_update_line_status - multiple status change ch341_update_line_status - delta = 0x01 ch341_update_line_status - multiple status change ch341_update_line_status - delta = 0x01 Always gives Timeout. Apparently there is the problem ... I think XD. The problem with the driver gives me the kernel 3.12.6 original, a despairing attempt to update the two files you mentioned, but still always feel the same. Always respond timeout. 2014-04-14 1:02 GMT-04:30 Kijam López kija...@gmail.com: All commands and responses are formatted: STX data ETX LRC (I replace No printable Char for [space]0xXX[space]) If I sent a ENQ answers his state, which is 2 bytes, so replies: 0x02 `@ 0x03 # (`@ is a two-byte mask representing the internal state of the device) If sending the S1 command, which is 0x02 S1 0x03 a, I should say something like this: 0x02 S100 0x0A 0 0x0A 0479 0x0A 0 0x0A 0330 0x0A 0 0x0A 0061 0x0A 0x0A X- 0x0A X 0x0A 221715 0x0A 120414 0x0A 0x03 0x1B In Windows OS, it works perfectly with the same PC and the same USB adapter. But Linux is not responding. Or respond but the driver is not interpreted correctly. My Kernel is 3.12.6, but i updated from GitHub this file an rebuild this drivers: https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c https://github.com/torvalds/linux/blob/master/drivers/usb/serial/usb-serial.c (commit d9a38a8741fdffabc32e6d0943b1cdcf22712bec) 2014-04-14 0:53 GMT-04:30 Greg KH gre...@linuxfoundation.org: On Mon, Apr 14, 2014 at 12:16:40AM -0430, Kijam López wrote: I reported here: https://bugreports.qt-project.org/browse/QTBUG-38305 But just migrate my APP to ANSI C and is exactly the same. My code test in ANSI C: snip Test command: Fail I'm confused, what should it do? And what kernel version are you using here? thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Driver CH341 USB Adapter Serial Port not Works in Linux
Yes! Thank you so much, do not know how many days I had trying to make it work :D. That patch worked perfectly me, now if I works perfect. I look forward to mourn :'(. I do not understand why not even include that patch in the Kernel. 2014-04-14 5:43 GMT-04:30 Karl Palsson ka...@tweak.net.au: On Sun, Apr 13, 2014 at 08:51:56PM -0430, Kijam López wrote: The following code works for me correctly in Windows, but Linux does not work. I am using the same PC, both operating systems are installed native. I do not use virtual machine. I need to work on Linux. I have tried in different linux distributions and does not work anywhere. [snip] if(!serial.setParity(QSerialPort::EvenParity)) qCritical()Error in setParity; the ch34x driver does not (yet) support parities other than None. It doesn't report a failure though, it just simply ignores it altogether. If you're actually working with an even parity device, you're going to have all sorts of not-fun. I've got a patch here: http://www.spinics.net/lists/linux-usb/msg105238.html but I've not (yet) resubmitted it after Johan Hovold's comments Cheers, Karl P -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb/serial/ch341: Add parity support
Apply this patch because I have a device that uses even parity. It is a tax machine, it worked perfect in that case. I want to thank you again, though I did in my thread, I write only to support you and implement this PATCH soon. Based on wireshark packet traces from a windows machine. ch340 and ch341 both seem to support all parity modes, but only the ch341 appears to support variable data bits and variable stop bits, so those are left unimplemented, as before. Tested on a generic usb-rs485 dongle with the chip label scratched off, and some Modbus/RTU devices that required various parity settings. Signed-off-by: Karl Palsson ka...@tweak.net.au --- drivers/usb/serial/ch341.c | 27 ++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 82371f6..b870f6f 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -346,6 +346,7 @@ static void ch341_set_termios(struct tty_struct *tty, struct ch341_private *priv = usb_get_serial_port_data(port); unsigned baud_rate; unsigned long flags; + unsigned int par_flags; baud_rate = tty_get_baud_rate(tty); @@ -366,9 +367,33 @@ static void ch341_set_termios(struct tty_struct *tty, /* Unimplemented: * (cflag CSIZE) : data bits [5, 8] -* (cflag PARENB) : parity {NONE, EVEN, ODD} * (cflag CSTOPB) : stop bits [1, 2] */ + /* CH340 doesn't appear to support variable stop bits or data bits */ + if (C_PARENB(tty)) { + if (C_PARODD(tty)) { + if (C_CMSPAR(tty)) { + dev_dbg(port-dev, parity = mark\n); + par_flags = 0xeb; + } else { + dev_dbg(port-dev, parity = odd\n); + par_flags = 0xcb; + } + } else { + if (C_CMSPAR(tty)) { + dev_dbg(port-dev, parity = space\n); + par_flags = 0xfb; + } else { + dev_dbg(port-dev, parity = even\n); + par_flags = 0xdb; + } + } + } else { + dev_dbg(port-dev, parity = none\n); + par_flags = 0xc3; + } + ch341_control_out(port-serial-dev, 0x9a, 0x2518, par_flags); + } static void ch341_break_ctl(struct tty_struct *tty, int break_state) -- 1.9.0 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Driver CH341 USB Adapter Serial Port not Works in Linux
Hi!, I'm having trouble with this adapter, and lately I think it's the driver. Here I leave a link where I report the problem: http://stackoverflow.com/questions/23040820/driver-ch341-usb-adapter-serial-port-or-qserialport-not-works-in-linux -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Driver CH341 USB Adapter Serial Port not Works in Linux
is 3.12.6, but i updated from GitHub this file an rebuild this drivers: https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c https://github.com/torvalds/linux/blob/master/drivers/usb/serial/usb-serial.c (commit d9a38a8741fdffabc32e6d0943b1cdcf22712bec) PD: Sorry for my English, try to do my best with Google Translator :(... _ Atentamente Lic. Kijam López Página Web Curriculum Vitae 2014-04-13 20:50 GMT-04:30 Greg KH gre...@linuxfoundation.org: On Sun, Apr 13, 2014 at 08:19:11PM -0430, Kijam López wrote: Hi!, I'm having trouble with this adapter, and lately I think it's the driver. Here I leave a link where I report the problem: http://stackoverflow.com/questions/23040820/driver-ch341-usb-adapter-serial-port-or-qserialport-not-works-in-linux How about asking the question here, and not on some random web site, where there's nothing we can do about it... thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Driver CH341 USB Adapter Serial Port not Works in Linux
ttyUSB0: ch341_update_line_status - delta=0x01 Apr 14 00:10:02 kali kernel: [14845.144415] tty ttyUSB0: serial_close Apr 14 00:10:02 kali kernel: [14845.144432] tty ttyUSB0: serial_chars_in_buffer Apr 14 00:10:02 kali kernel: [14845.12] tty ttyUSB0: serial_wait_until_sent Apr 14 00:10:02 kali kernel: [14845.147914] usb 1-1: ch341_read_int_callback - urb shutting down: -2 Apr 14 00:10:02 kali kernel: [14845.149723] tty ttyUSB0: serial_cleanup I think it's not the fault of QT ... 2014-04-13 21:14 GMT-04:30 Greg KH gre...@linuxfoundation.org: On Sun, Apr 13, 2014 at 08:51:56PM -0430, Kijam López wrote: The following code works for me correctly in Windows, but Linux does not work. I am using the same PC, both operating systems are installed native. I do not use virtual machine. I need to work on Linux. I have tried in different linux distributions and does not work anywhere. snip Sounds like a Qt issue, what is the status of the bug you filed with those developers? greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Driver CH341 USB Adapter Serial Port not Works in Linux
All commands and responses are formatted: STX data ETX LRC (I replace No printable Char for [space]0xXX[space]) If I sent a ENQ answers his state, which is 2 bytes, so replies: 0x02 `@ 0x03 # (`@ is a two-byte mask representing the internal state of the device) If sending the S1 command, which is 0x02 S1 0x03 a, I should say something like this: 0x02 S100 0x0A 0 0x0A 0479 0x0A 0 0x0A 0330 0x0A 0 0x0A 0061 0x0A 0x0A X- 0x0A X 0x0A 221715 0x0A 120414 0x0A 0x03 0x1B In Windows OS, it works perfectly with the same PC and the same USB adapter. But Linux is not responding. Or respond but the driver is not interpreted correctly. My Kernel is 3.12.6, but i updated from GitHub this file an rebuild this drivers: https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c https://github.com/torvalds/linux/blob/master/drivers/usb/serial/usb-serial.c (commit d9a38a8741fdffabc32e6d0943b1cdcf22712bec) 2014-04-14 0:53 GMT-04:30 Greg KH gre...@linuxfoundation.org: On Mon, Apr 14, 2014 at 12:16:40AM -0430, Kijam López wrote: I reported here: https://bugreports.qt-project.org/browse/QTBUG-38305 But just migrate my APP to ANSI C and is exactly the same. My code test in ANSI C: snip Test command: Fail I'm confused, what should it do? And what kernel version are you using here? thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html