USB CDC ACM (Serial) SDK middlewere: DCD (Carrier) update of host

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

USB CDC ACM (Serial) SDK middlewere: DCD (Carrier) update of host

跳至解决方案
673 次查看
alonbl
Contributor III

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

标记 (5)
0 项奖励
回复
1 解答
593 次查看
alonbl
Contributor III

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, &param);
}
}

 

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.

 

在原帖中查看解决方案

0 项奖励
回复
4 回复数
651 次查看
Gavin_Jia
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复
647 次查看
Gavin_Jia
NXP TechSupport
NXP TechSupport

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

 

 

 

0 项奖励
回复
594 次查看
alonbl
Contributor III

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, &param);
}
}

 

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.

 

0 项奖励
回复
622 次查看
alonbl
Contributor III

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,

0 项奖励
回复