USB to Serial problem detecting RTS/DTR changes

17 views
Skip to first unread message

Fran H

unread,
Apr 7, 2020, 3:35:14 AM4/7/20
to LUFA Library Support List
Hi, first post here.
First i want to say kudos and thanks for such an amazing project (LUFA).
 

I want to make a USB to Serial converter that also has RTS and DTR signals exposed. I load succesfuly the CDC USB to Serial Demo from LUFA last version (as of 06/04/2020). Im using Atmel Studio7 with the LUFA extension, in windows 10. Ive burned it on to a atmega16u2.

The USB to Serial part worked great and i could also controll the DTR line. 

My problem is with the RTS line.

Im using a python script to toogle the lines. DTR lines toogle fine, but RTS doesnt.


/** Event handler for the CDC Class driver Host-to-Device Line Encoding Changed event.
 *
 *  \param[in] CDCInterfaceInfo  Pointer to the CDC class interface configuration structure being referenced
 */
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) {
  bool CurrentDTRState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR);
  bool CurrentRTSState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_RTS);

  if (CurrentDTRState)
    PORTB &= ~DTR_MASK;
  else
    PORTB |= DTR_MASK;

  if (CurrentRTSState)
    PORTB &= ~RTS_MASK;
  else
    PORTB |= RTS_MASK;
}
And, the DTR works ok, but the RTS it doenst.


The only time it works its when i change both lines (RTS and DTR) from my script. It seems that a single change on RTS alone it does nothing, but if i make a change on both line, then its gets to the device.


Ive debugged and get to this point
static inline bool Endpoint_IsSETUPReceived(void)
{
    return ((UEINTX & (1 << RXSTPI)) ? true : false);
}
And doing some testing, i see that this returns true when the change is caused by a DTR change , but false when done from a RTS change. The bad thing is that RXSTPI 
writen by hardware, not by software, so i cannot debug it (i dont have a debugger such as ICE).

Ive teste this problem on MacOs also, with the same result.
Lastly, ive tested my script with others USB2Serial commercial chips, and i could controll their RTS and DTR lines, so i think my script is running fine and also, the OS is not doing something weird.
Does anyone know where could be this problem coming from?

Thanks in advance.
Franco

Fran H

unread,
Apr 7, 2020, 10:34:38 PM4/7/20
to LUFA Library Support List
Nevermind, its a driver problem. On Linux it works flawlessly. On Mac and on Windows it doesnt. Guess ill have to stick with linux or write my own driver :P
Reply all
Reply to author
Forward
0 new messages