0

I'm currently using a SBC (a Raspberry Pi Zero 2W) to receive data from a device (let's call it Sensor). Sensor is connected to the micro USB port on the SBC through an adaptor with FTDI FT232R USB UART (part of the Sensor accessories). Sensor is proprietary and scarcely documented, but once every minute it sends a series of bits which I read with a Python script listening on the serial port (using the pyserial library).

These are the communication settings:

baudrate=19200, bytesize=8, parity='N', stopbits=1, timeout=None, xonxoff=False, rtscts=False

Now I also connected another device, a 4G module, to the same USB port of the SBC using a USB hub. I distinguish the two devices in the Python code by looking at the interface properties, so the script only records data from Sensor.

What happens in case of concurrent data transmission, since both Sensor and the 4G module go into the same USB port? Could data from Sensor be lost? I am running tests which seem fine, but since I still worry that there could be issues down the line.

Edit: This is an an excerpt from the code I use to read data (in a loop):

import serial
from serial.tools import list_ports

available_ports =  list(list_ports.comports())
for i, tmp in enumerate(available_ports):
    if tmp.interface == "FT232R USB UART":
        port = available_ports[i].device

ser = serial.Serial(
    port,
    baudrate=19200,
    bytesize=8,
    parity='N',
    stopbits=1,
    timeout=None,
    xonxoff=False,
    rtscts=False,
)

sensor_data = ser.read(1)
time.sleep(1)
data_left = ser.inWaiting()
sensor_data += ser.read(data_left)

It's using pyserial 3.5.

5
  • 1
    You aren't asking about RS232 to USB, but what happens when multiple devices are connected to the same USB port. They just work. That already happens on all computers and hubs. USB allows multiple devices on the same channel, and the ports on your computer are provided by the motherboard's internal hub. The host (your computer, RPi etc) exchanges USB packets with the devices. Commented Oct 13, 2025 at 7:44
  • 2
    FTDI on the other hand has a long history of quirks when it comes to USB-serial devices. They provide the chips and bare-bones reference drivers, that may miss functionality. When I used them (a long time ago, before SO) they didn't handle RTS/CTS automatically. I was surprised to find similar SO questions some years ago. I see you use both rtscts=False and xonxoff=False. How will the device know the RPI isn't ready to read yet? You could use a large input buffer so you don't miss anything until you check the port again, but what if the buffer is full? Commented Oct 13, 2025 at 7:56
  • 1
    Thank you for the information! One of the few things the device maker says in the documentation is that there is no flow control. I added to the question the code I'm using to read data (without some loops and tries), but I admit I built it out of other people's examples, because it was my first time. From what I understand, it uses the buffer and, for now, I never missed any data (because I more or less know what to expect). If I understood your comments correctly, does this mean that I can treat the two issues (reading from the device and using the hub) as separate? Sorry if I'm being dense. Commented Oct 13, 2025 at 10:52
  • 1
    USB is a bus. That's what the B in its name/acronym stands for. This bus is a data & control path for multiple (USB) devices to connect to a (USB) host. A (USB) hub is merely a (USB) device to provide more than one (USB) port to the host. Typically the host itself has a hub, aka the root hub. Commented Oct 14, 2025 at 1:56
  • Thank you for the explanation! I really need to do some reading. Commented Oct 14, 2025 at 7:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.