usbserial adapter driving me crazy...

Issues related to hardware problems
Locked
stoggy
Posts: 9
Joined: 2008/04/28 00:28:17

usbserial adapter driving me crazy...

Post by stoggy » 2013/02/01 00:05:22

I have this usb serial adapter, ch341 chipset.

I have used it before but now i cant get it to work. The switch, 96008N1, works with this ch341 adapter and windows xp using putty. I haven't tried linux putty yet, ill try and update.
I have seen online about an update for vendor prod number, but my .ko has the new strings and lsusb shows my devices name.
I noticed the alias has the vendor id with 1A86 and lsusb lists 1a86. I cant find anywhere if this matters or is correct. I did find a patch and it shows using lowercase 1a86. Module is from 2.6.32-279.19.1.el6.x86_64 rpm.


$ sudo lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

$ strings /lib/modules/2.6.32-279.19.1.el6.x86_64/kernel/drivers/usb/serial/ch341.ko | grep -i 1a86
alias=usb:v1A86p7523d*dc*dsc*dp*ic*isc*ip*

$ lsmod | grep ch341
ch341 9185 0
usbserial 38460 1 ch341

$ dmesg | grep tty
console [tty0] enabled
usb 2-4: ch341-uart converter now attached to ttyUSB0
ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
usb 2-4: generic converter now attached to ttyUSB0


when i try to `screen /dev/ttyUSB0 9600` it just sits there, I can hit enter and cursor moves but no console chars.
If i try minicom, i don't usually use minicom, but the status shows not connected and no chars from console.


any suggestions?

stoggy
Posts: 9
Joined: 2008/04/28 00:28:17

Re: usbserial adapter driving me crazy...

Post by stoggy » 2013/02/01 01:02:31

so i went and go the kernel source linux-2.6.32.60.tar.bz2

$ grep -i 1a86 ./linux-2.6.32.60/drivers/usb/serial/ch341.c
{ USB_DEVICE(0x1a86, 0x7523) },
{ USB_DEVICE(0x1a86, 0x5523) },

It has the Devices listed with lower case. I'm going to try to build and insert.

stoggy
Posts: 9
Joined: 2008/04/28 00:28:17

Re: usbserial adapter driving me crazy...

Post by stoggy » 2013/02/01 03:24:20

$ grep -i 1a86 ./drivers/usb/serial/ch341.c
{ USB_DEVICE(0x1a86, 0x7523) },
{ USB_DEVICE(0x1a86, 0x5523) },

$ strings ./drivers/usb/serial/ch341.ko | grep -i 1a86
alias=usb:v1A86p5523d*dc*dsc*dp*ic*isc*ip*
alias=usb:v1A86p7523d*dc*dsc*dp*ic*isc*ip*


samething...

User avatar
AlanBartlett
Forum Moderator
Posts: 9320
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

usbserial adapter driving me crazy...

Post by AlanBartlett » 2013/02/01 07:08:50

[quote]
stoggy wrote:
I have this usb serial adapter, ch341 chipset.

[i][/i]

when i try to `screen /dev/ttyUSB0 9600` it just sits there, I can hit enter and cursor moves but no console chars.
If i try minicom, i don't usually use minicom, but the status shows not connected and no chars from console.

any suggestions?[/quote]
Open a terminal and become root. Then --

[code]
[b]chown [i]your_id[/i].[i]your_id[/i] /dev/ttyUSB0
chmod 666 /dev/ttyUSB0
stty 9600 < /dev/ttyUSB0 > /dev/ttyUSB0[/b]
[/code]
Open a second terminal and --

[code]
[b]screen /dev/ttyUSB0[/b]
[/code]
It has been a few months since I last did similar . . . If I remember correctly, I used something like the above.

stoggy
Posts: 9
Joined: 2008/04/28 00:28:17

Re: usbserial adapter driving me crazy...

Post by stoggy » 2013/02/01 08:23:29

$ ls -l /dev/ttyUSB0
crw-rw-rw-. 1 me me 188, 0 Feb 1 01:39 /dev/ttyUSB0

$ stty 9600 /dev/ttyUSB0
$

the stty command is just going back to a command prompt. screen still doing the samething though. I think your redirection is wrong too.

$ ps aux | egrep -i stty\|USB
me 4440 0.0 0.0 101020 928 pts/0 S+ 01:41 0:00 egrep --color=auto -i stty|USB

not running. I dont think stty will do that, it just gets and sets term settings. looking at mine though... forgot about that.


$ stty -a -F /dev/ttyUSB0
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^H; eof = ^D; eol = ; eol2 = <un ;
werase = ^W; lnext = ^V; flush = ^O; min = 100; time = 2;
-parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts -cdtrdsr
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff -i
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt e



Also went back through previously loaded kernels and tried. none are working.

stoggy
Posts: 9
Joined: 2008/04/28 00:28:17

Re: usbserial adapter driving me crazy...

Post by stoggy » 2013/02/01 08:35:20

i dont think the settings are changing.


$ sudo stty 9600 cs8 -cstopb -clocal crtscts hup -parenb parodd -F /dev/ttyUSB0
[sudo] password:

$ stty -a -F /dev/ttyUSB0
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^H; eof = ^D; eol = ; eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
flush = ^O; min = 100; time = 2;
-parenb parodd cs8 hupcl -cstopb cread -clocal crtscts -cdtrdsr
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

User avatar
AlanBartlett
Forum Moderator
Posts: 9320
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: usbserial adapter driving me crazy...

Post by AlanBartlett » 2013/02/02 03:54:40

Either I am right or I am wrong. If I am wrong, then I have been doing things wrong since the 1970s. :-x

There is nothing 'wrong' with any of the kernels, there is nothing 'wrong' with setting parameters for the serial adaptor via the redirection technique -- at least, as long as it is performed as 'root' from one terminal and the adaptor is 'used' by an ordinary user from another terminal.

stoggy
Posts: 9
Joined: 2008/04/28 00:28:17

Re: usbserial adapter driving me crazy...

Post by stoggy » 2013/02/02 06:38:58

I didn't mean it like that. I have only been doing it since the 90s.

I tried a different usb-serial adapter I borrowed from a friend and it popped right up. Module is borke or serial settings are wrong. Never used serial ports in linux much so limited knowledge, but I would assume either the module or the device itself, which i doubt, is supplying the settings that stty -a -F /dev/ttyUSB0 is reading.


Ok then what would your redirection do? Read from /dev/ttyUSB0 and then write to /dev/ttyUSB0? Re-upping the settings? What do you call that a Unix Reboot?


I did try it though.

User avatar
AlanBartlett
Forum Moderator
Posts: 9320
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: usbserial adapter driving me crazy...

Post by AlanBartlett » 2013/02/03 06:11:18

It is a three stage process, all in one. It reads the current settings from the device, it then modifies the settings according to the white-space separated list that follows the 'stty' command and finally it writes (i.e. applies) the settings to the device. :-)

dpeddi
Posts: 1
Joined: 2015/02/04 13:49:47

Re: usbserial adapter driving me crazy...

Post by dpeddi » 2015/02/04 13:53:21

I've got recently following device.

Bus 003 Device 014: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

Standard kernel driver don't work with this device.

After some experiment with usbsnoop log it seems that ch341.c starts working if comment out

// r = ch341_control_out(dev, 0x9a, 0x2518, 0x0050);

windows driver usbsnoop
000007: 000003 ms 000398 ms c0 95 18 25 00 00 02 00 <<< c3 00
000036: 000004 ms 000620 ms 40 9a 18 25 c2 00 00 00 >>>
000075: 000003 ms 011673 ms 40 9a 18 25 c3 00 00 00 >>>

So it seems that windows driver read 2518 registry...
it mask some byte and write back
finally it restore it back to original value before communication starts..

please note that my device after following command
r = ch341_control_in(dev, 0x5f, 0, 0, buffer, size);
answer 0x3000, so it should be a more recent hardware version.

Please note that you may need to replug the adapter after insmod

Locked