PORTS Forum

Ports and Interfaces => USB => Topic started by: Antonio Cabral on April 09, 2020, 01:37:44 pm

Title: DCD pin Handle over USB
Post by: Antonio Cabral on April 09, 2020, 01:37:44 pm
I am developing an application that I did not find any information regarding how to generate the DCD info to the USB.
 It happens that in my application I need to send to the PC the change information of the "DCD" pin of the connected serial port, but I have not found any information on how to implement this command from the USB side.
 I know that there are some USB chips like FTDI and CP2102 that have the "DCD" pin ready to be used and so I think there must be a specific "frame" that the chip sends to the PC to inform the change of that pin.
 I did several tests using RealTerm using a chip that has the DCD pin.
 When I change the state of this pin, RealTerm identifies this change in the panel, but I would like to know what information the chip sends to the PC so that this function is signaled. I appreciate your help. Thanks a lot!!
Title: Re: DCD pin Handle over USB
Post by: Jan Axelson on April 09, 2020, 02:09:18 pm
The SerialPort class's CDHolding property can read the state of the CD pin:

https://docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.cdholding?view=netframework-4.8

Also see SerialPort.PinChanged event:

https://docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.pinchanged?view=netframework-4.8
Title: Re: DCD pin Handle over USB
Post by: Renate on April 15, 2020, 08:12:05 pm
If I understand what you are asking, for the FTDI, it sends two bytes at the start of every UART received data transmission.
From the Linux kernel source code:
https://elixir.bootlin.com/linux/latest/source/drivers/usb/serial/ftdi_sio.h
Code: [Select]
* IN Endpoint
 *
 * The device reserves the first two bytes of data on this endpoint to contain
 * the current values of the modem and line status registers. In the absence of
 * data, the device generates a message consisting of these two status bytes
 * every 40 ms
 *
 * Byte 0: Modem Status
 *
 * Offset Description
 * B0 Reserved - must be 1
 * B1 Reserved - must be 0
 * B2 Reserved - must be 0
 * B3 Reserved - must be 0
 * B4 Clear to Send (CTS)
 * B5 Data Set Ready (DSR)
 * B6 Ring Indicator (RI)
 * B7 Receive Line Signal Detect (RLSD)
 *
 * Byte 1: Line Status
 *
 * Offset Description
 * B0 Data Ready (DR)
 * B1 Overrun Error (OE)
 * B2 Parity Error (PE)
 * B3 Framing Error (FE)
 * B4 Break Interrupt (BI)
 * B5 Transmitter Holding Register (THRE)
 * B6 Transmitter Empty (TEMT)
 * B7 Error in RCVR FIFO