mirror of https://github.com/ARMmbed/mbed-os.git
Tests: USBHID: Handle variable driver setup time
Wait for the host driver to finish setup before sending any HID reports from the device. USBHID::wait_ready() blocks until the device reaches 'configured' state, but the state of the host HID driver remains unknown to the device.pull/10096/head
parent
4f880691fb
commit
36eb700ede
|
@ -69,7 +69,8 @@ HID_PROTOCOL_KEYBOARD = 1
|
|||
HID_PROTOCOL_MOUSE = 2
|
||||
|
||||
# Greentea message keys used for callbacks
|
||||
MSG_KEY_DEVICE_READY = 'ready'
|
||||
MSG_KEY_DEVICE_READY = 'dev_ready'
|
||||
MSG_KEY_HOST_READY = 'host_ready'
|
||||
MSG_KEY_SERIAL_NUMBER = 'usb_dev_sn'
|
||||
MSG_KEY_TEST_GET_DESCRIPTOR_HID = 'test_get_desc_hid'
|
||||
MSG_KEY_TEST_GET_DESCRIPTOR_CFG = 'test_get_desc_cfg'
|
||||
|
@ -495,6 +496,8 @@ class USBHIDTest(mbed_host_tests.BaseHostTest):
|
|||
except RetryError as exc:
|
||||
self.notify_error(exc)
|
||||
return
|
||||
# Notify the device it can send reports now.
|
||||
self.send_kv(MSG_KEY_HOST_READY, MSG_VALUE_DUMMY)
|
||||
try:
|
||||
for _ in range(RAW_IO_REPS):
|
||||
# There are no Report ID tags in the Report descriptor.
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#define MSG_VALUE_LEN 24
|
||||
#define MSG_KEY_LEN 24
|
||||
#define MSG_KEY_DEVICE_READY "ready"
|
||||
#define MSG_KEY_DEVICE_READY "dev_ready"
|
||||
#define MSG_KEY_HOST_READY "host_ready"
|
||||
#define MSG_KEY_SERIAL_NUMBER "usb_dev_sn"
|
||||
#define MSG_KEY_TEST_GET_DESCRIPTOR_HID "test_get_desc_hid"
|
||||
#define MSG_KEY_TEST_GET_DESCRIPTOR_CFG "test_get_desc_cfg"
|
||||
|
@ -307,6 +309,12 @@ void test_generic_raw_io()
|
|||
greentea_send_kv(MSG_KEY_TEST_RAW_IO, REPORT_SIZE);
|
||||
usb_hid.wait_ready();
|
||||
|
||||
// Wait for the host HID driver to complete setup.
|
||||
char key[MSG_KEY_LEN + 1] = { };
|
||||
char value[MSG_VALUE_LEN + 1] = { };
|
||||
greentea_parse_kv(key, value, MSG_KEY_LEN, MSG_VALUE_LEN);
|
||||
TEST_ASSERT_EQUAL_STRING(MSG_KEY_HOST_READY, key);
|
||||
|
||||
// Report ID omitted here. There are no Report ID tags in the Report descriptor.
|
||||
HID_REPORT input_report = {};
|
||||
HID_REPORT output_report = {};
|
||||
|
|
Loading…
Reference in New Issue