Re: [Ftdi-usb-sio-devel] Data corruption on serial link using FTDI USB to serial driver and RS232
Brought to you by:
bryder
From: Mats J. <mat...@te...> - 2018-03-20 18:07:48
|
Apparently I have been using a USB to TTL converter cabel and not an USB to RS232. I did not know there was a difference. I will test with a USB to RS232 tomorrow. It will most likely work right away. My boss who gave me the cable did obvioulsy not know the difference either. He has joked about me not setting the serial parameters correct the last couple of days. Now I can nag him about giving me the wrong cable :) /Mats 20 mars 2018 kl. 17:31, "Michael Plante" <mic...@gm... (mailto:%22Michael%20Plante%22%20<mic...@gm...>)> skrev: Sorry, I meant to write to the list, but was on my phone. -----Original Message----- From: Michael Plante [mailto:mic...@gm...] Sent: Tuesday, March 20, 2018 12:30 PM To: Mats Jansson Subject: Re: [Ftdi-usb-sio-devel] Data corruption on serial link using FTDI USB to serial driver and RS232 Is your converter TTL levels instead of RS232? On Tue, Mar 20, 2018, 12:05 Mats Jansson <mat...@te... (mailto:mat...@te...)> wrote: Hi, I think I am closing in on this issue a bit. I have noticed using a logical analyzer (digview) that the FTDI is normally high (+3.3V) between ground and TX/RX, while on the PC the signal is normally low. So on the FTDI output the startbit makes the line go low, while on the PC the startbit makes the line go high. If I in tell the DigiView software to interpret the signal inverted from the PC it will read the bytes as 30 31 32 33 34 35 36 37 38 39. I don’t see why it is this way? Is there something that needs to be configured in our driver in our embedded system to make it invert the signals, so that the PC can recogize it correctly? /Mats Med vänlig hälsning, Mats mailto:mat...@te... (mailto:mat...@te...) den 19 mars 2018, skrev du till mig: Hej Bill and Michael, As I said two ports on my embedded system. These are both USB ports. I have now tried out connecting an FTDI USB-Serial converter to both of these and connnected them to each other. This way I can echo to one of the ports e.g /dev/ttyUSB0 and I get the correct data sent to the other port, i.e. /dev/tty/USB1. It also works like a charm when I send the other way, i.e. from /dev/ttyUSB1 to /dev/ttyUSB0. It works both if use the default settings of the ports, and also if i use the stty command to set the parameters to raw. When connecting to my Windows machine I still get the same error. I am trying to set up so that my virtual machine with Ubuntu 16.04 running under Windows and Virtual box to use the serial port COM1 of my computer, but without any luck so far. I get access denied when I try to access it, using echo. Med vänlig hälsning, Mats mailto:mat...@te... (mailto:mat...@te...) den 17 mars 2018, skrev du till mig: Good call Michael. The pattern in the bytes is indicative of mismatched serial parameters. Re the different byte counts you are getting - that completely depends on when the data is available on the interface - there's no guarantee that the blocks of data you are sending will be delivered in the same chunks you have put them on the interface unless you make extra system calls. I see you are missing the last little chunk of data which suggests there was still that data in the buffers to be read. Your expected output should include a newline because echo puts a newline on the output stream if you don't use the -n option In ubuntu 1604 (and probably most linuxes) you can use this to check the serial settings sudo stty -a --file=/dev/ttyUSB0 speed 9600 baud; rows 0; columns 0; line = 0; intr = ^C; quit = ^; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0; -parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts -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 -flusho -extproc man stty will tell you what the settings are. You can change them with stty as well - but - at least in the old days - you have to hold that device open, or the settings will reset when the file is closed. I suggest you use the tool screen to talk to the serial interface, you can set parity etc and everything you type should go to the port and you'll have proper control over the serial parameters. screen isn't necessarily installed by default so you may have to install it. On 17 March 2018 at 12:14, Michael Plante <mic...@gm... (mailto:mic...@gm...)> wrote: Mats, I don't know the answer, but I see patterns in the data. I suggest carefully checking parity, 1vs2 stop bits, and 7vs8 bits/char and reporting what you see. I can't remember the chipset, but I've seen some converters don't respect all those settings, so you might try 8n1 if you can. Buffering with usb to serial is hit or miss in my experience. I assume the converter is COTS, not custom, and it's a plain serial cable. An oscope would make this easier. Maybe also try sending other patterns involving 5,A,3,C. Michael On Mar 16, 2018 10:33, "Mats Jansson" <mat...@te... (mailto:mat...@te...)> wrote: Hi, I have a problem with the FTDI USB Serial port driver in an embedded system. The embedded system is a running Linux kernel 4.4, and we have an atmel processor. The FTDI USB Serial port driver is built into the kernel. I attach an the USB end of an FTDI USB to RS232 adapter to the linux unit and connect the RS232 connector to a PC. In a terminal window on my linux unit I do the following $ echo 01234567899876543210 > /dev/ttyUSB0 $ echo 01234567899876543210 > /dev/ttyUSB0 $ echo 01234567899876543210 > /dev/ttyUSB0 $ echo 01234567899876543210 > /dev/ttyUSB0 $ echo 01234567899876543210 > /dev/ttyUSB0 In the other end I have connected a PC and built a very simple program that opens the COM port, reads data and prints it out. I was expecting to get the data as (printed in hex values): Read 20 bytes [30 31 32 33 34 35 36 37 38 39 39 38 37 36 35 34 33 32 31 30] Read 20 bytes [30 31 32 33 34 35 36 37 38 39 39 38 37 36 35 34 33 32 31 30] Read 20 bytes [30 31 32 33 34 35 36 37 38 39 39 38 37 36 35 34 33 32 31 30] Read 20 bytes [30 31 32 33 34 35 36 37 38 39 39 38 37 36 35 34 33 32 31 30] Read 20 bytes [30 31 32 33 34 35 36 37 38 39 39 38 37 36 35 34 33 32 31 30] But the resulting data on the PC from the three lines of echo above is: Read 14 bytes [D6 B6 96 76 56 36 16 F6 D6 D6 F6 16 36 56 ] Read 28 bytes [76 96 B6 D6 F6 B6 00 D6 B6 96 76 56 36 16 F6 D6 D6 F6 16 36 56 76 96 B6 D6 F6 B6 00 ] Read 14 bytes [D6 B6 96 76 56 36 16 F6 D6 D6 F6 16 36 56 ] Read 15 bytes [76 96 B6 D6 F6 B6 00 D6 B6 96 76 56 36 16 F6 ] Read 29 bytes [D6 D6 F6 16 36 56 76 96 B6 D6 F6 B6 00 D6 B6 96 76 56 36 16 F6 D6 D6 F6 16 36 56 76 96 ] Not only the data is not all what I suspected, there seems to be some buffering issue. I have tested with different speeds on the line, 2400, 9600, 57600 and 115200 and the result is the same in all cases. I have also tested to send data the other way, and the result is similar. Does anyone have any idea what could be wrong here? Why is the data corrupted? Best Regards, Mats mailto:mat...@te... (mailto:mat...@te...) ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot (http://sdm.link/slashdot) _______________________________________________ Ftdi-usb-sio-devel mailing list Ftd...@li... (mailto:Ftd...@li...) https://lists.sourceforge.net/lists/listinfo/ftdi-usb-sio-devel (https://lists.sourceforge.net/lists/listinfo/ftdi-usb-sio-devel) ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot (http://sdm.link/slashdot) _______________________________________________ Ftdi-usb-sio-devel mailing list Ftd...@li... (mailto:Ftd...@li...) https://lists.sourceforge.net/lists/listinfo/ftdi-usb-sio-devel (https://lists.sourceforge.net/lists/listinfo/ftdi-usb-sio-devel) |