Hello,
I am trying to understand how I update the host when carrier is updated.
As far as I can see the host gets the last value from `kUSB_DeviceCdcEventSetControlLineState` from `acmInfo->uartState` if `~USB_DEVICE_CDC_UART_STATE_RX_CARRIER` is unset.
When device looses carrier and wish to update the host, how is this done? I guess there should be some notification, but I could not find how to initiate this notification in the SDK.
I am using `SDK_25_03_00_MIMXRT1171xxxxx`.
Thank you
Alon
解決済! 解決策の投稿を見る。
Thank you @Gavin_Jia for the hint!
I successfully manage to update the host and reuse the callback logic using the following code:
void update_host(void) {
if (s_usbCdcAcmInfo.dtePresent) {
usb_device_cdc_acm_request_param_struct_t param = {
.setupValue = s_usbCdcAcmInfo.dteStatus,
.interfaceIndex = ((usb_device_cdc_acm_struct_t *)s_UsbInterface4XXXCicVcom.cdcAcmHandle)->interfaceNumber,
};
USB_DeviceInterface4XXXCicVcomCallback(s_UsbInterface4XXXCicVcom.cdcAcmHandle, kUSB_DeviceCdcEventSetControlLineState, ¶m);
}
}
Explanation for future reference:
1. The device can send serial state notifications at any time using the CIC vcom input endpoint.
2. The host can query status, this is triggered by kUSB_DeviceCdcEventSetControlLineState, as response (1) is sent.
3. kUSB_DeviceCdcEventSerialStateNotif is triggered after notification was sent.
Hi @alonbl ,
Thanks for your interest in NXP MIMXRT series!
Using the USB_DeviceCdcVcomCallback() function in virtual_com.c in the SDK as an example, I don't think it accomplishes the scenario you describe. It may be necessary to consider calling USB_DeviceCdcAcmSend() for this scenario.
Best regards,
Gavin
Hi @alonbl ,
Sorry for the misunderstanding of kUSB_DeviceCdcEventSerialStateNotif in my previous reply:
This event is the signal from the USB stack that informs you that sending is complete after the call to USB_DeviceCdcAcmSend has completed successfully.
The CDC ACM driver on the host polls the interrupt IN endpoint. After the device has sent a new serial state notification via USB_DeviceCdcAcmSend, the next poll of the host takes this notification and updates what it considers to be the state of the serial port .
And it is possible to send notifications usingUSB_DeviceCdcAcmSend, the key is the difference in the second parameter, the bulk IN endpoint is used to transmit packets and the interrupt IN endpoint is used to transmit status information or control notifications.
But the key point remains that you need to write your own logic and serial State buffer in the application.
Hope it helps!
Best regards,
Gavin
Thank you @Gavin_Jia for the hint!
I successfully manage to update the host and reuse the callback logic using the following code:
void update_host(void) {
if (s_usbCdcAcmInfo.dtePresent) {
usb_device_cdc_acm_request_param_struct_t param = {
.setupValue = s_usbCdcAcmInfo.dteStatus,
.interfaceIndex = ((usb_device_cdc_acm_struct_t *)s_UsbInterface4XXXCicVcom.cdcAcmHandle)->interfaceNumber,
};
USB_DeviceInterface4XXXCicVcomCallback(s_UsbInterface4XXXCicVcom.cdcAcmHandle, kUSB_DeviceCdcEventSetControlLineState, ¶m);
}
}
Explanation for future reference:
1. The device can send serial state notifications at any time using the CIC vcom input endpoint.
2. The host can query status, this is triggered by kUSB_DeviceCdcEventSetControlLineState, as response (1) is sent.
3. kUSB_DeviceCdcEventSerialStateNotif is triggered after notification was sent.
Hello @Gavin_Jia ,
Thank you so much for assisting.
I cannot find how to use the callback when I have an event in the device side.
The scenario is the device loses connectivity and requires to notify the host which is pulling dcd signal in a loop.
When the host pulls dcd, I cannot see callback being called.
I saw the `kUSB_DeviceCdcEventSerialStateNotif` but as this is event at the device side, I do not understand how to trigger the host in order to update state. Let's say I call `USB_DeviceCdcAcmEvent(,kUSB_DeviceCdcEventSerialStateNotif,)` what do I do in the callback?
I guess I need to send some packet to host, but not via `USB_DeviceCdcAcmSend` as this sends regular data.
Regards,