Verify whether two usb devices are connected on the same hub - c

I have a microcontroller board which has a USB hub to which several CP2108 USB to serial modules are connected and one PIC Microcontroller is connected.
The USB hub is connected to Laptop USB Port..
The CP2108 devices are assigned /dev/ttyUSB0, /dev/ttyUSB1 ID's, whereas the PIC Microcontroller is assigned a /dev/usb/abc.
If I connect another USB device to Laptop USB Port, it will get /dev/ttyUSB2
I want to verify whether /dev/ttyUSB and /dev/usb/abc are on the same hub and not on different one..
Is there any way to find out through code.. I tried to look into sysfs , but I am unable to find out the difference

Related

How to detect when USB is disconnected?

I use a virtual com port for communication between the microcontroller and the computer.
I have mk. stm32h743 self-powered from its own 3.3V power supply. With the help of a cube, I raised a virtual com port. How can you understand that the USB is disconnected from the device ? When you connect Usb, it calls "CDC_Init_FS" and hUsbDeviceFS.dev_state is set to 3, which corresponds to "USBD_STATE_CONFIGURED". But when you disconnect the USB there is no callback "HAL_PCD_DisconnectCallback (PCD_HandleTypeDef * hpcd);"Why "HAL_PCD_DisconnectCallback (PCD_HandleTypeDef * hpcd);" not called when USB is disabled?
I have no way to track Vbus voltages. So I did it like this :
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef hpcd)
{
USBD_LL_Suspend((USBD_HandleTypeDef)hpcd->pData);
__HAL_PCD_GATE_PHYCLOCK(hpcd);
if (hpcd->Init.low_power_enable)
{
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk |
SCB_SCR_SLEEPONEXIT_Msk));
}
SBD_LL_DevDisconnected(&hUsbDeviceFS);
}
Hello.
I have a problem with USB working properly - USB CDC (Virtual Com Port) with CubeMX HAL after disconnecting the USB cable and connecting again.
For the test I created a project similar to the one presented here - https://www.youtube.com/watch?v=AYICE0gU-Sg using STM32CubeIDE and STM32CubeMX.
The program writes data in the while (1) loop to the USB port after uploading to STM32.
while(1)
{
CDC_Transmit_FS(buffer, sizeof(buffer));
HAL_Delay(1000);
}
The data is written out, visible in Windows 7 (Tera Term).
When I disconnect the USB cable (OTG FS port) and reconnect, Windows sends the message "USB device not recognized".
Data is not received.
In order for the data to be transferred and the cable to be recognized, I must do a Reset on the board.
Hardware:
MCU: STM32H743VIT
Software: STM32CubeIDE v1.2
Firmware package: STM32Cube_FW_H7_V1.7.0
How to make the USB device work all the time correctly (after disconnecting the cable and reconnecting it), so that it is recognized by Windows and data is transferred?

Microcontroller not recognized at USB port when connected via pins

Im having issues with my TI LAUNCHXL-F28379D. I have it connected to the laptop I am trying to send data to/from via pins P19 (SCIBRxD) and P18 (SCIBTxD), as well as GND and 5V via J16, using a USB Type B cord to which I sautered pin connectors. I'm sure power is being supplied to the board as when I plug the 5V cable of the USB cable, the RGB lights and 3 other small ones turn on. However, the Computer does not recognize ithe controller at the port - it only recognizes if if it is connected via the board's Mini-USB port. I've also written a C Program which opens the COM port and reads data - but this does not work without my knowledge of the COM port number, usually found in Device Manager. I cannot get any further in my project without the port number and it is very annoying. I will attempt to resauter a new USB cable, but if there are any other possible solutions, or if I'm doing something wrong, please let me know.
Absolutely all feedback is appreciated!
The SCIBRxD and SCIBTxD pins belong to the SCI peripheral in the microcontroller. This peripheral implements a UART port (a.k.a. COM port, a.k.a. TTL serial port). It is not a USB port. Nothing useful will happen if you connect it to a USB port, because it is not compatible with USB in any way.
USB-to-UART adapters (a.k.a. USB-to-serial adapters) do exist. There is one built into the LaunchPad. The UART side of the adapter is connected to the SCIB pins, and the USB side of the adapter is connected to the USB port.

Force connection on specific USB port/symlink

I am planning to use Dump1090 and I want to have 2 RTLSDR dongles on the same computer, always plugged into the same USB port. I am planning to assign a symlink "adsb" to the port for the RTL dongle that has an ADS-B antenna connected to it. Is there a way to force the connection on this specific USB port?
By default, the code takes the first device available.
Thank you
https://github.com/antirez/dump1090/blob/master/dump1090.c

Is client connected on XBee s6b

I have an XBee S6B setup in wireless access mode and physically connected to a Raspberry PI. I connect my laptop to the XBee WiFi access point and I can send data back and forth between the Raspberry PI and the XBee over WiFi.
Can someone tell me if there is a way for the Raspberry PI to know that the laptop has successfully connected or disconnected? Are there any commands the Raspberry PI can send to the XBee to establish if something has connected/disconnected?
There’s no Node Join frame, but if it’s in Access Point mode then you could just periodically ping the other device. You would know its address since there can’t be more than one external device in AP mode.

Linux Serial Device Server over USB?

I have an embedded Linux solution and want to create a command service over serial USB. The idea being that when a computer connects to my embedded via USB, they see a serial device and send serial commands to me through that port and I send responses back.
I need some help in the direction to proceed. Do I need to emulate a serial device so they see me as a COM port? Is there build in Linux solutions to broadcast my details as a serial device? Are there code examples? I can see block devices connect with my embedded solution like a USB storage device. When I plug into another computer, I would like it to see me as a serial COM port.
I just need help in the direction of which path I should go down to solve this.
Thanks in advance.
What you are looking for is the Linux USB serial gadget. The Linux USB gadgets framework allows devices to behave as a variety of standard USB devices, including serial devices, Ethernet adapters, and mass storage devices.
Note that USB gadgets will only work on targets with a USB controller that can be set to operate as a USB device. Not all USB controllers and target devices are compatible with this configuration. For instance, most PCs have a host-only USB controller, and the Raspberry Pi Model B is not compatible with gadgets because it contains an embedded USB hub upstream of the USB ports. (However, the Pi Zero is fully compatible with gadgets.)

Resources