• AVR Freaks

Helpful ReplyHot!USB CDC control RTC/CTS Pin

Author
mvollmer
Junior Member
  • Total Posts : 88
  • Reward points : 0
  • Joined: 2013/08/20 22:58:04
  • Location: Germany
  • Status: offline
2015/10/26 06:57:44 (permalink)
0

USB CDC control RTC/CTS Pin

Harmony Version 1.06
PIC32MX250F128B
Optimazation 1
XC32 1.40
MPLAB IDE v3.10
 
Hello folks,
im using a pic as a usb slave. sometimes the host must wait before sending the next data. now i want to use the rts/cts of cdc to make a control flow.
 
I've tried to change the carrier bit in the control line state and use control send. But when im doing this, the usb communication stucks for a minute.
    
        app.controlLineStateData.carrier = 1;
        USB_DEVICE_ControlSend(app.usbDeviceHandle, &app.getLineCodingData, sizeof(USB_CDC_LINE_CODING));

 
I've searched for it in the harmony help, but couldt find anything. How can i change the RTS/CTS Lines, so the host can wait for it? // How can i trigger a USB_DEVICE_CDC_EVENT_GET_LINE_CODING Event?
 
thanks in advance
post edited by mvollmer - 2015/10/26 06:58:52

with kind regards
mvolllmer
 
PIC Experience with PIC24FJ256GB110 and PIC32MX3XX_4XX Family
#1
flopez
New Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2015/09/29 00:07:42
  • Location: 0
  • Status: offline
Re: USB CDC control RTC/CTS Pin 2015/10/26 08:28:44 (permalink)
0
Hi mvollmer,

I'm trying to run a 32MX470 as device with CDC USB.

As I haven't found many info for PIC32 USB, I'm adapting project example cdc_com_port_single but I don't achieve that it works. 


How have you done to get PIC32 working as a usb slave? 
Could you send me your project or some info by mail?
 
I'm using Harmony Version 1.06 and XC32 1.40 too

email:
 
Thanks in advance,
Fco.
#2
mvollmer
Junior Member
  • Total Posts : 88
  • Reward points : 0
  • Joined: 2013/08/20 22:58:04
  • Location: Germany
  • Status: offline
Re: USB CDC control RTC/CTS Pin 2015/10/27 00:25:54 (permalink)
0
Hello flopez,
 
i've just used the HCM to create the Project and the "cdc_serial_emulator" Example.
 
flopez but I don't achieve that it works.

Please open a new Thread and write down what doenst work and what you did. The more information, the better we can help you.
 
Back 2 Topic:
 
Now I did the following:

        case USB_DEVICE_CDC_EVENT_SET_CONTROL_LINE_STATE:

            /* This means the host is setting the control line state.
             * Read the control line state. We will accept this request
             * for now. */

            controlLineStateData = (USB_CDC_CONTROL_LINE_STATE *)pData;

            if(appObject->IsBusy) {
                USB_DEVICE_ControlStatus(appObject->usbDeviceHandle, USB_DEVICE_CONTROL_STATUS_ERROR);
            } else {
                appObject->controlLineStateData.dtr = controlLineStateData->dtr;
                appObject->controlLineStateData.carrier =
                        controlLineStateData->carrier;
                USB_DEVICE_ControlStatus(appObject->usbDeviceHandle, USB_DEVICE_CONTROL_STATUS_OK);
            }
            

            break;

Is this the right way to tell the host that the device isnt ready?
post edited by mvollmer - 2015/10/27 00:47:37

with kind regards
mvolllmer
 
PIC Experience with PIC24FJ256GB110 and PIC32MX3XX_4XX Family
#3
newfound
Super Member
  • Total Posts : 1849
  • Reward points : 0
  • Joined: 2003/11/07 12:35:49
  • Status: offline
Re: USB CDC control RTC/CTS Pin 2015/10/27 01:38:07 (permalink) ☄ Helpfulby mvollmer 2015/10/27 03:23:24
4.5 (2)
mvollmer
 
Now I did the following:

        case USB_DEVICE_CDC_EVENT_SET_CONTROL_LINE_STATE:

            /* This means the host is setting the control line state.
             * Read the control line state. We will accept this request
             * for now. */

            controlLineStateData = (USB_CDC_CONTROL_LINE_STATE *)pData;

            if(appObject->IsBusy) {
                USB_DEVICE_ControlStatus(appObject->usbDeviceHandle, USB_DEVICE_CONTROL_STATUS_ERROR);
            } else {
                appObject->controlLineStateData.dtr = controlLineStateData->dtr;
                appObject->controlLineStateData.carrier =
                        controlLineStateData->carrier;
                USB_DEVICE_ControlStatus(appObject->usbDeviceHandle, USB_DEVICE_CONTROL_STATUS_OK);
            }
            

            break;

Is this the right way to tell the host that the device isnt ready?




No it isn't.
 
If you don't want the host to send more data then don't arm the CDC data OUT endpoint.
 
If you want to send some status information to the host then use the INTERRUPT endpoint and the line notification structure. The host will typically poll this once per frame. No good if your device become busy after the host has polled for line notification already that frame...
 
There is no CTS signal available with USB CDC at all and RTS should only ever be generated from the host but the reality is that it is rarely used and it's implementation on windows is so bugged that is it near worthless anyway. 
 
RTS and CTS do not make any sense at all to the control of CDC data over the USB transport. They only make sense when you have external peripherals connected to the UART of the PIC chip and then RTS is generated locally by the PIC chip for the external peripheral and CTS is read locally but no information is passed back to the host. There is no mechanism to do so.  
 
If you don't want the host to send more data then don't arm the CDC data OUT endpoint, it's that simple.
post edited by newfound - 2015/10/27 01:40:34
#4
mvollmer
Junior Member
  • Total Posts : 88
  • Reward points : 0
  • Joined: 2013/08/20 22:58:04
  • Location: Germany
  • Status: offline
Re: USB CDC control RTC/CTS Pin 2015/10/27 03:39:41 (permalink)
3 (1)
Hello newfound,
thanks for you reply!
 
I've done this now:
    USB_CDC_SERIAL_STATE state;
    state.bTxCarrier = app.IsBusy;
    USB_DEVICE_CDC_SerialStateNotificationSend(app.cdcInstance,
            &app.writeTransferHandle, &state);

 
I can see another Interrupt Transfer with this :)

007226: Bulk or Interrupt Transfer (UP), 27.10.2015 11:28:23.726 +0.0. (1. Device: USB to Serial (COM18)) Status: 0x00000000
Pipe Handle: 0x177dcd08 (Endpoint Address: 0x81)
Get 0x2 bytes from the device
 02 00

Now i have to handle it on the Host side.
 
To disable the enpoint i would use this :
USB_DEVICE_EndpointDisable(app.usbDevHandle, appData.endpointRx);

post edited by mvollmer - 2015/10/27 03:41:52

with kind regards
mvolllmer
 
PIC Experience with PIC24FJ256GB110 and PIC32MX3XX_4XX Family
#5
louis111135
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2015/09/01 18:29:11
  • Location: 0
  • Status: offline
Re: USB CDC control RTC/CTS Pin 2019/12/31 01:14:26 (permalink)
0
Can I get your example?
Beause, I try pic32mz in harmony 2.6 and harmony 3.0. 
I try this function, it still can not control.
 USB_DEVICE_CDC_SerialStateNotificationSend(app.cdcInstance,
            &app.writeTransferHandle, &state);
21 22 02 00 00 00 00 00!"......
Recipient: Interface
Request Type: Class
Direction: Host->Device
Request: 0x22 (Unknown)
Value: 0x2
Index: 0x0
Length: 0x0
#6
Jump to:
© 2020 APG vNext Commercial Version 4.5