Skip to content

Commit b50aca0

Browse files
committed
device cdc acm support break request
- Implements handling of UX_SLAVE_CLASS_CDC_ACM_SEND_BREAK in the CDC ACM control request path. - Ensures break state is cleared on class deactivation to avoid carrying state across disconnect/reset cycles. - Minor comment/whitespace cleanups in touched headers/sources. - Testing: Build-only / compilation sanity/send break request. (no new automated tests added).
1 parent 515c9a4 commit b50aca0

6 files changed

Lines changed: 339 additions & 266 deletions

common/usbx_device_classes/inc/ux_device_class_cdc_acm.h

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
11
/***************************************************************************
2-
* Copyright (c) 2024 Microsoft Corporation
3-
*
2+
* Copyright (c) 2024 Microsoft Corporation
3+
*
44
* This program and the accompanying materials are made available under the
55
* terms of the MIT License which is available at
66
* https://opensource.org/licenses/MIT.
7-
*
7+
*
88
* SPDX-License-Identifier: MIT
99
**************************************************************************/
1010

11+
1112
/**************************************************************************/
1213
/**************************************************************************/
13-
/** */
14-
/** USBX Component */
1514
/** */
16-
/** CDC Class */
15+
/** USBX Component */
16+
/** */
17+
/** Device CDC ACM Class */
1718
/** */
1819
/**************************************************************************/
1920
/**************************************************************************/
2021

21-
/**************************************************************************/
22-
/* */
23-
/* COMPONENT DEFINITION RELEASE */
24-
/* */
25-
/* ux_device_class_cdc_acm.h PORTABLE C */
26-
/* 6.3.0 */
22+
23+
/**************************************************************************/
24+
/**************************************************************************/
25+
/* */
26+
/* COMPONENT DEFINITION RELEASE */
27+
/* */
28+
/* ux_device_class_cdc_acm.h PORTABLE C */
29+
/* 6.4.6 */
2730
/* AUTHOR */
2831
/* */
2932
/* Chaoqiong Xiao, Microsoft Corporation */
3033
/* */
3134
/* DESCRIPTION */
32-
/* */
33-
/* This file defines the equivalences for the USBX Device Class CDC */
34-
/* ACM component. */
35-
/* */
36-
/* RELEASE HISTORY */
37-
/* */
38-
/* DATE NAME DESCRIPTION */
39-
/* */
35+
/* */
36+
/* This file defines the equivalences for the USBX Device Class CDC */
37+
/* ACM component. */
38+
/* */
39+
/* RELEASE HISTORY */
40+
/* */
41+
/* DATE NAME DESCRIPTION */
42+
/* */
4043
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
4144
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
4245
/* used UX prefix to refer to */
@@ -63,21 +66,24 @@
6366
/* endpoint buffer in classes, */
6467
/* added error checks support, */
6568
/* resulting in version 6.3.0 */
69+
/* 01-28-2026 Mohamed AYED Modified comment(s), */
70+
/* support send break request */
71+
/* resulting in version 6.4.6 */
6672
/* */
6773
/**************************************************************************/
6874

6975
#ifndef UX_DEVICE_CLASS_CDC_ACM_H
7076
#define UX_DEVICE_CLASS_CDC_ACM_H
7177

72-
/* Determine if a C++ compiler is being used. If so, ensure that standard
73-
C is used to process the API information. */
78+
/* Determine if a C++ compiler is being used. If so, ensure that standard
79+
C is used to process the API information. */
7480

75-
#ifdef __cplusplus
81+
#ifdef __cplusplus
7682

77-
/* Yes, C++ compiler is present. Use standard C. */
78-
extern "C" {
83+
/* Yes, C++ compiler is present. Use standard C. */
84+
extern "C" {
7985

80-
#endif
86+
#endif
8187

8288
/* Internal option: enable the basic USBX error checking. This define is typically used
8389
while debugging application. */
@@ -251,6 +257,7 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_STRUCT
251257
UCHAR ux_slave_class_cdc_acm_data_bit;
252258
UCHAR ux_slave_class_cdc_acm_data_dtr_state;
253259
UCHAR ux_slave_class_cdc_acm_data_rts_state;
260+
USHORT ux_slave_class_cdc_acm_break_duration;
254261
UCHAR reserved[3];
255262

256263
#ifndef UX_DEVICE_CLASS_CDC_ACM_TRANSMISSION_DISABLE
@@ -289,23 +296,29 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_STRUCT
289296

290297
/* Define some CDC Class structures */
291298

292-
typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARAMETER_STRUCT
299+
typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARAMETER_STRUCT
293300
{
294301
ULONG ux_slave_class_cdc_acm_parameter_baudrate;
295302
UCHAR ux_slave_class_cdc_acm_parameter_stop_bit;
296303
UCHAR ux_slave_class_cdc_acm_parameter_parity;
297304
UCHAR ux_slave_class_cdc_acm_parameter_data_bit;
298-
305+
299306
} UX_SLAVE_CLASS_CDC_ACM_LINE_CODING_PARAMETER;
300307

301-
typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER_STRUCT
308+
typedef struct UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER_STRUCT
302309
{
303310
UCHAR ux_slave_class_cdc_acm_parameter_rts;
304311
UCHAR ux_slave_class_cdc_acm_parameter_dtr;
305-
312+
306313
} UX_SLAVE_CLASS_CDC_ACM_LINE_STATE_PARAMETER;
307314

308-
typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
315+
typedef struct UX_SLAVE_CLASS_CDC_ACM_BREAK_PARAMETER_STRUCT
316+
{
317+
USHORT ux_slave_class_cdc_acm_parameter_break_duration;
318+
319+
} UX_SLAVE_CLASS_CDC_ACM_BREAK_PARAMETER;
320+
321+
typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
309322
{
310323
UINT (*ux_device_class_cdc_acm_parameter_write_callback)(struct UX_SLAVE_CLASS_CDC_ACM_STRUCT *cdc_acm, UINT status, ULONG length);
311324
UINT (*ux_device_class_cdc_acm_parameter_read_callback)(struct UX_SLAVE_CLASS_CDC_ACM_STRUCT *cdc_acm, UINT status, UCHAR *data_pointer, ULONG length);
@@ -316,22 +329,22 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
316329

317330
/* Requests - Ethernet Networking Control Model */
318331

319-
#define UX_SLAVE_CLASS_CDC_ACM_SEND_ENCAPSULATED_COMMAND 0x00
332+
#define UX_SLAVE_CLASS_CDC_ACM_SEND_ENCAPSULATED_COMMAND 0x00
320333
/* Issues a command in the format of the supported control
321334
protocol. The intent of this mechanism is to support
322335
networking devices (e.g., host-based cable modems)
323336
that require an additional vendor-defined interface for
324337
media specific hardware configuration and
325338
management. */
326-
#define UX_SLAVE_CLASS_CDC_ACM_GET_ENCAPSULATED_RESPONSE 0x01
339+
#define UX_SLAVE_CLASS_CDC_ACM_GET_ENCAPSULATED_RESPONSE 0x01
327340
/* Requests a response in the format of the supported
328341
control protocol. */
329-
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_MULTICAST_FILTERS 0x40
342+
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_MULTICAST_FILTERS 0x40
330343
/* As applications are loaded and unloaded on the host,
331344
the networking transport will instruct the device's MAC
332345
driver to change settings of the Networking device's
333346
multicast filters. */
334-
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
347+
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
335348
/* Some hosts are able to conserve energy and stay quiet
336349
in a 'sleeping' state while not being used. USB
337350
Networking devices may provide special pattern filtering
@@ -340,13 +353,13 @@ typedef struct UX_SLAVE_CLASS_CDC_ACM_CALLBACK_PARAMETER_STRUCT
340353
host (e.g., an incoming web browser connection).
341354
Primitives are needed in management plane to negotiate
342355
the setting of these special filters */
343-
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
356+
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
344357
/* Retrieves the status of the above power management
345358
pattern filter setting */
346-
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_PACKET_FILTER 0x43
359+
#define UX_SLAVE_CLASS_CDC_ACM_SET_ETHERNET_PACKET_FILTER 0x43
347360
/* Sets device filter for running a network analyzer
348361
application on the host machine */
349-
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_STATISTIC 0x44
362+
#define UX_SLAVE_CLASS_CDC_ACM_GET_ETHERNET_STATISTIC 0x44
350363
/* Retrieves Ethernet device statistics such as frames
351364
transmitted, frames received, and bad frames received. */
352365

@@ -363,20 +376,20 @@ UINT _ux_device_class_cdc_acm_deactivate(UX_SLAVE_CLASS_COMMAND *command);
363376
UINT _ux_device_class_cdc_acm_entry(UX_SLAVE_CLASS_COMMAND *command);
364377
UINT _ux_device_class_cdc_acm_initialize(UX_SLAVE_CLASS_COMMAND *command);
365378
UINT _ux_device_class_cdc_acm_uninitialize(UX_SLAVE_CLASS_COMMAND *command);
366-
UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
379+
UINT _ux_device_class_cdc_acm_write(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
367380
ULONG requested_length, ULONG *actual_length);
368-
UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
381+
UINT _ux_device_class_cdc_acm_read(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
369382
ULONG requested_length, ULONG *actual_length);
370383
UINT _ux_device_class_cdc_acm_ioctl(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, ULONG ioctl_function,
371384
VOID *parameter);
372385
VOID _ux_device_class_cdc_acm_bulkin_thread(ULONG class_pointer);
373386
VOID _ux_device_class_cdc_acm_bulkout_thread(ULONG class_pointer);
374-
UINT _ux_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
387+
UINT _ux_device_class_cdc_acm_write_with_callback(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
375388
ULONG requested_length);
376389

377-
UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
390+
UINT _ux_device_class_cdc_acm_write_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
378391
ULONG requested_length, ULONG *actual_length);
379-
UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
392+
UINT _ux_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR *buffer,
380393
ULONG requested_length, ULONG *actual_length);
381394

382395
UINT _ux_device_class_cdc_acm_tasks_run(VOID *instance);
@@ -419,10 +432,10 @@ UINT _uxe_device_class_cdc_acm_read_run(UX_SLAVE_CLASS_CDC_ACM *cdc_acm, UCHAR
419432

420433
#endif
421434

422-
/* Determine if a C++ compiler is being used. If so, complete the standard
423-
C conditional started above. */
435+
/* Determine if a C++ compiler is being used. If so, complete the standard
436+
C conditional started above. */
424437
#ifdef __cplusplus
425-
}
426-
#endif
438+
}
439+
#endif
427440

428441
#endif /* UX_DEVICE_CLASS_CDC_ACM_H */

0 commit comments

Comments
 (0)