Though some might argue that Serial port are things in the past, it is still the most popular port for those who are into electronic DIY. Building electronic device with serial port interface is cheaper than buiding one that uses USB.
Nov 29, 2013 Apologies in advance for posting a libusb question here, but I'm not getting much help on StackOverflow. [SOLVED] Serial communication with USB CDC device (libusb/termios) Apologies in advance for posting a libusb question here, but I'm not getting much help on StackOverflow. On the other hand, libusb0.sys and libusb-win32 API will still be supported (bug fix mode) even though no new features will be added. Libusb-0.1 is widely supported by operating systems like Linux, FreeBSD, NetBSD, OpenBSD, Darwin/MacOS X and Solaris. Libusb-win32 is API compatible with libusb 0.1.
That is the reason why people still sell USB-Serial adapter to those electronic DIY enthusiast. Here’s how to enable USB-Serial port adapter in Ubuntu Linux (with credit to from ) First plug in the USB-Serial Port adaptor to one of your USB port. Wait for a couple of second, then run “dmesg”. You should see these message at the end of dmesg output. Usb 1-1: new full speed USB device using uhciand address 2 usb 1-1: configuration #1 chosen from 1 choice After that, unplug the device and type “lsusb”.
You will see a list of output similar to this. Bus 003 Device 001: ID 0000:0000 Bus 002 Device 007: ID 03f0:4f11 Hewlett-Packard Bus 002 Device 006: ID 05e3:1205 Genesys Logic, Inc. Afilias Optical Mouse H3003 Bus 002 Device 004: ID 15d9:0a33 Plug in the USB-Serial Port converter back, and run “lsusb” again, and you shall see an additional line, like this. Bus 003 Device 001: ID 0000:0000 Bus 002 Device 007: ID 03f0:4f11 Hewlett-Packard Bus 001 Device 002: ID 4348:5523 - - - ( notice the additional line!) Bus 002 Device 006: ID 05e3:1205 Genesys Logic, Inc.
![]()
Afilias Optical Mouse H3003 Bus 002 Device 004: ID 15d9:0a33 Now we know the vendor id and the product id of the USB-Serial Port converter, this will enable us to load the linux kernel module “usbserial” to activate the device, like this: sudo modprobe usbserial vendor=0x4348 product=0x5523 Run “dmesg” again and you shall see lines similar like this: usbserialgeneric 1-1:1.0: generic converter detected usb 1-1: generic converter now attached to ttyUSB0 usbcore: registered new interface driver usbserialgeneric As you can see, the new serial port device is mapped to /dev/ttyUSB0. You can instruct Ubuntu to load this module automatically by include the line: “usbserial vendor=0x4348 product=0x5523” inside “/etc/modules” file. Bonus: What application benefits from usb-serial port adaptor? For starters, there are modems which uses RS-232 serial port. Some home-made devices includes which also depends on the serial port. I use the adaptor to hook up my morse keyer in order to send morse code through the internet using. The site has to build such interface.
You can see my home-made morse code oscillator here: Where can I get USB to Serial port converter? You can get it from your local computer stores or order it online! Hola MyPapit, I am trying to interface an Icom AIS receiver with my Ubuntu 12.04 controlled plotter. The plotter program is OpenCPN. Your instructions are helpful and clear, but am still having problem. Apparently Ubuntu is recognizing the USB to RS232 converter.
Using your suggested command lsusb, I see the device. I’m just not getting a data stream from the Icom. So I still don’t know if the problem is in the hardware or the software. Can you offer any suggestions? I am N7NST and still have active license but inactive for years now. Writing to you from Puerto Armuelles, Panama and headed for Ecuador. Hi, I’m a newcomer and my eeepc doesn’t recognize when I plug my etrex (garmin gps) to the pc via a serial usb converter.
So I followed the instructions but I do not know the meaning of the last command: As you can see, the new serial port device is mapped to /dev/ttyUSB0. You can instruct Ubuntu to load this module automatically by include the line: “usbserial vendor=0×4348 product=0×5523? Inside “/etc/modules” file.
What should I exactly type? Sorry if the question may sound silly, but I’m really a newcomer and don’t know how to get it work. Thank you very much for any answer! If you’d like to take your videos along with you anywhere, make sure you first convert them to 3GP format so that they can be read on handheld devices including Mp3 players, iPhone and other cellphones Plato Video to 3GP Converter is software enabling you to convert your avi, mpeg, flv 3gp, rm, divx, xvid, wmv, asf, mov, qt, swf to 3GP format. It supports batch conversion and likewise provides the possible ways to convert merely a element of your video by setting a start point and a breakpoint around the source file. You can even customize the output quality of your 3GP file. Observe that the chosen parameters might be unspent in an account for future use.
I’m having trouble configuring arduinoBT I tried to do the same steps that this site but I had no success. Obs: I’m using Ubuntu 4.10 LTS 32bits and the following error appears: ubuntu32bits@ubuntu32bits-laptop:$ lsusb Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 003: ID 03eb:2104 Atmel Corp.
Hope someone can help me – how can one statically assign usb serial so they map to the ttyUSBX everytime. I have 4 of these usb serial dongles and I have configured ser2net for specific tcp port to ttyUSBX (so i can telnet to the console of switches) but once i restart PC; for eg usb serial dongle 1 which is ttyUSB0 may on next reboot may become ttyUSB1 and thus when i telnet to that port actually have consoled to another unit (as ser2net config file maps specific TCP port to ttyUSB). Thanks for your help in advance. “How to enable USB-Serial Port adapter (RS-232) in Ubuntu Linux” is very well written and enabled me (complete newcomer) to get COM2 recognised by the SeaClear.exe navigation program running under wine. Unfortunately the prog. Is not receiving and NMEA input from my GPS, and any advice on what I should do next would be appreciated.
![]()
Other problem – using nano I added the “usbserial vendor” line to the “/etc/modules” file, but couldn’t work out how to save the addition. Could you help, please? Thanks a million. Comments are closed. Post navigation.
Miguel Sosa wrote: Sorry, my example there had some errors on the values part of set pipe policy: timeout=400; retval = WinUsbSetPipePolicy(usbhandle, usbepinPIPETRANSFERTIMEOUT, sizeof(timeout)&timeout); opt=1; retval = WinUsbSetPipePolicy(usbhandle, usbepinALLOWPARTIALREADS, sizeof(opt), opt); I assume you mean '&opt', but it shouldn't matter. ALLOWPARTIALREADS should not be relevant for you, and I don't think it has any effect when you specify RAWIO. In any case, is winusb the right path to follow for this scenario or would a UMDF driver be more appropriate? UMDF drivers use WinUSB as their transport. It's a different API, but the same provider.
Could the PIPETRANSFERTIMEOUT be causing the issue with the dropped ACKs even with RAWIO? Should I move to use overlap in my reads? When you say 'dropped ACKs', do you mean a byte of data being returned on the pipe? The reason I ask is that 'ACK' has a very specific meaning in the USB world, and I'm guessing that's not what you mean.
Tim Roberts, [email protected] Providenza & Boekelheide, Inc. Tim Roberts wrote: Miguel Sosa wrote: Sorry, my example there had some errors on the values part of set pipe policy: timeout=400; retval = WinUsbSetPipePolicy(usbhandle, usbepinPIPETRANSFERTIMEOUT, sizeof(timeout)&timeout); opt=1; retval = WinUsbSetPipePolicy(usbhandle, usbepinALLOWPARTIALREADS, sizeof(opt), opt); I assume you mean '&opt', but it shouldn't matter. ALLOWPARTIALREADS should not be relevant for you, and I don't think it has any effect when you specify RAWIO. I have been trying as many option combinations as I can think of.
I previously had regular (non raw) IO, and believe I needed the allowpartialreads for packets longer than len. I didn't remove it.just in case.
In any case, is winusb the right path to follow for this scenario or would a UMDF driver be more appropriate? UMDF drivers use WinUSB as their transport. It's a different API, but the same provider. Could the PIPETRANSFERTIMEOUT be causing the issue with the dropped ACKs even with RAWIO? Should I move to use overlap in my reads? When you say 'dropped ACKs', do you mean a byte of data being returned on the pipe? The reason I ask is that 'ACK' has a very specific meaning in the USB world, and I'm guessing that's not what you mean.
Here I mean an actual 1 byte response form the device with 6 (ACK) or 15 (NAK). Miguel Sosa wrote: 3 devices use Bulk pipes; One uses interrupt (although it has one interrupt for reads and another for writes). Same with the bulk pipes, right? USB pipes are unidirectional (except the control pipe). The manufacturers do provide their own drivers. The ones that have bulk pipes have virtual COM drivers (so I can use them with the serial port code i already have).
The one that uses interrupts works like a HID device. I wrote a basic HID client for that one which seems to work well.
Having said that, for simplicity to our customers I would prefer to have just one way for all devices to communicate. I already use libusb in linux to talk to all 4 devices and wanted to do something similar in windows.
I am following the progress in the libusb list of the winusb port but I need something that can use right now. If it were me, I'd be tempted to write a wrapper DLL that hides the details underneath, then use the virtual COM driver where appropriate and the HID client where appropriate. I certainly do understand wanting to be able to control things at the lowest level, however. I am using sniffUSB, and have used Snoopy. It has been very helpfulexcept that I am still learning how to parse it. I can recognize the packets with read/write data, and some of the control requests, but most of the ones without data are still a mystery to me.
Any links that would help with learning how to parse the USB traffic? Remember that you see the whole exchange: request going down, response coming back. If you have a screenshot or dump output that confuses you, send it along and we can interpret.
Tim Roberts, [email protected] Providenza & Boekelheide, Inc. Tim Roberts wrote: Miguel Sosa wrote: 3 devices use Bulk pipes; One uses interrupt (although it has one interrupt for reads and another for writes). Same with the bulk pipes, right? USB pipes are unidirectional (except the control pipe). If it were me, I'd be tempted to write a wrapper DLL that hides the details underneath, then use the virtual COM driver where appropriate and the HID client where appropriate. I certainly do understand wanting to be able to control things at the lowest level, however.
Well, the other part is that it is also easier to maintain if I have just one winusb code base that I can use for everything.:-) I am using sniffUSB, and have used Snoopy. It has been very helpfulexcept that I am still learning how to parse it. I can recognize the packets with read/write data, and some of the control requests, but most of the ones without data are still a mystery to me. Any links that would help with learning how to parse the USB traffic? Remember that you see the whole exchange: request going down, response coming back. If you have a screenshot or dump output that confuses yousend it along and we can interpret.
I noticed I have two entries (up/down) for each URB. A couple of questions, between the BULKORINTERRUPTTRANSFERS I see: 1621871 ms UsbSnoop - MyInternalIOCTLCompletion(b75e8126): fido=00000000, Irp=89d96568, Context=896d4f80, IRQL=2 Which seems to be the result of the bulk write operation.
I also see: 1621877 ms UsbSnoop - FilterDispatchAny(b75e7fd2): IRPMJINTERNALDEVICECONTROL 1621879 ms UsbSnoop - FdoHookDispatchInternalIoctl(b75e81ea): fdo=8978e8b8, Irp=89d96568, IRQL=0 Which I believe is the actual read request to the device. (it's followed by BULKORINTERRUPTTRANSFERS with the IN endpoint.) Is there any guide to parse those messages? Miguel Sosa wrote: Yes. I noticed I have two entries (up/down) for each URB. A couple of questionsbetween the BULKORINTERRUPTTRANSFERS I see: 1621871 ms UsbSnoop - MyInternalIOCTLCompletion(b75e8126): fido=00000000, Irp=89d96568, Context=896d4f80, IRQL=2 Which seems to be the result of the bulk write operation. That tells you that a previous request has been completed and sent back to WinUSB.
The IRP will let you associate that with the request submission, earlier in the log. I also see: 1621877 ms UsbSnoop - FilterDispatchAny(b75e7fd2): IRPMJINTERNALDEVICECONTROL 1621879 ms UsbSnoop - FdoHookDispatchInternalIoctl(b75e81ea): fdo=8978e8b8, Irp=89d96568, IRQL=0 Which I believe is the actual read request to the device.
(it's followed by BULKORINTERRUPTTRANSFERS with the IN endpoint.) Is there any guide to parse those messages? There's not too much more to extract from that. Those are just trace messages through the driver.
USB requests (like BULKORINTERRUPTTRANSFER) are sent wrapped in an IRPMJINTERNALDEVICECONTROL IRP. Don't you get anything that indicates how many bytes were transferred? - Tim Roberts, [email protected] Providenza & Boekelheide, Inc. Tim Roberts wrote: Miguel Sosa wrote: Is there any guide to parse those messages?
There's not too much more to extract from that. Those are just trace messages through the driver.
USB requests (like BULKORINTERRUPTTRANSFER) are sent wrapped in an IRPMJINTERNALDEVICECONTROL IRP. Don't you get anything that indicates how many bytes were transferred?
I get some traffic with apparently empty transfers and one transfer with data. My test operation does the following: Every read requests is for 64 bytes since I don't know ahead of time how many bytes to request. read from device to see if there is anything. Nothing there so it times out. (io is canceled). write a command to device - read (expects 0x06 - gets nothing unless in RAWIO) Now my code is waiting for input from the user. While doing so, it periodically checks if there is something to read: - 1.N read (time passes, call times out since there is nothing on the pipe until there is input from the user) - User does something - there are 99 bytes to read - read (expects 99 bytes - gets 36).
With timeouts enabled, I only received the last 36 bytes. The first 63 bytes of the response are lost.
I only received the second packet of data. In linux, doing the same operation I get 3 responses: - ACK - 63 bytes - 36 bytes So something in winusb is either not requesting or canceling the request of the middle packet before the device sends the data. Makes no sense to me, but with all the reads/timeouts it could very well be happening.
With timeouts disabled, using overlap, and raw IO I get the 06, but I need to AbortPipe after any read with data or after some period of time with no data received. It seems to work but it looks very ugly with all the abort packets in there. I need to investigate this further. It is not apparent to me what I am doing incorrect in my code (maybe it's a windows developer newbie error) or why either winusb or the device would buffer data this way.
Thanks for all your help and hints.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |