I'm currently using wireshark to sniff USB serial packets from a program that sends data to FPGA boards. So far I'm able to acquire the packets and data, but I'm not sure how to test each command I find. I want to develop my own program that can do the same thing on a different platform than the one the original program operates on.


Would I get another program to connect to the USB serial connection and then test sending each command? What program would be good for testing?

How would I go about figuring out the serial connection specifications? Baudrate, data bits, stop bits, parity, flow control, and forward?

  • 1
    Building something that could re-play what you have seen could be a good start. But first you'll need to decide if you want to speak raw USB operations to it, or go through an operating system Serial port driver. You should be able to determine the line settings either by looking at the USB control transfers used to configure them and recognizing the chip via cross referencing likely data sheets, or by using a scope or logic analyzer on the serial signals between the USB chip and the FPGA. – Chris Stratton Sep 24 '17 at 20:18

Well for starters you are going to want an in Kernel USB monitor like Linux has, a pass through USB analyzer (more expensive, but more flexible) or something like a logic analyzer.

Here is a video that goes into great detail of doing the latter far more than anyone will here https://www.youtube.com/watch?v=4FOkJLp_PUw Note from the video https://opentechlab.org.uk/videos:011:notes

To summarize you'll need a logic analyzer, potentially a way of getting the device to tell you it is about to send a packet in some manner (otherwise you will have better luck with a USB analyzer or in kernel USB monitor). Sigrok is software used there... but there are others.

Here is a little python code the guy in the video uses which will probably be of use to you. Which is just a basic example of using pyusb he was using it to talk to whatever micro controller board he was debugging you could use it to talk to your FPGA perhaps as you figure out what it's protocol is doing.

#! /usr/bin/env python3

import usb.core
import time

dev = usb.core.find(idVendor=0x0925, idProduct=0xD100)
if dev is None:
  raise ValueError('Device not found')

res = dev.ctrl_transfer(
  bmRequestType=0x40,                       # OUT, VENDOR, DEVICE request
  bRequest=1,                               # Request #1
  data_or_wLength=[0x01, 0x23, 0x45, 0x67])

The method you choose largely depends on what you need to know, if the device is functioning properly and you don't need to make changes to it, perhaps a software monitor is good enough. If it is indeed USB serial is it a dedicated chip? If so find it's datasheet... and investigate the circuit that may tell you some things. Common USB to serial chips are the the following which either use a standard USB CDC ACM protocol (check if chip in question is this then you can just grap the spec for it here ) or custom driver.

Note that the USB end of the protocol itself is probably baud rate independent but you may need to tell the USB serial convert what rate to run at... it depends alot on how it was designed. Probing the Uart output pints of the controller would allow you to figure out the correct baud rate if you can't figure it out from the circuit itself.

Another way to go about this would be to figure out at least one command that will give you a response... then exhaustively try different baud rates and configurations until you get the expected response.

  1. Silicon Labs CP2102 and variants. https://www.silabs.com/documents/public/data-sheets/CP2102-9.pdf

  2. MicroChip MCP2200 http://www.microchip.com/wwwproducts/en/en546923

  3. FT232R http://www.ftdichip.com/Products/ICs/FT232R.htm
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.