From 450d95e8df63f7169e3ae7c203ce89851b148332 Mon Sep 17 00:00:00 2001 From: bigA2021 Date: Fri, 8 Oct 2021 14:14:06 +0800 Subject: [PATCH] usb 1008 commit Signed-off-by: bigA2021 Change-Id: Id48821a37b18ac6143eb36e083bdfb01513c90b9 --- .../include/usb_device_lite_cdcacm_test.h | 4 ++-- .../device/src/usb_device_lite_cdcacm_test.c | 13 ++++++---- .../device/src/usb_device_lite_sdk_if_test.c | 4 +--- .../device/src/usb_device_lite_sdk_io_test.c | 4 ++++ .../model/usb/host/include/usb_raw_test.h | 2 +- .../model/usb/host/include/usb_test.h | 2 +- .../model/usb/host/src/usb_raw_test.c | 24 +++++++++---------- test/unittest/model/usb/host/src/usb_test.c | 12 +++++----- 8 files changed, 35 insertions(+), 30 deletions(-) diff --git a/test/unittest/model/usb/device/include/usb_device_lite_cdcacm_test.h b/test/unittest/model/usb/device/include/usb_device_lite_cdcacm_test.h index 95b004948..cb2b2f65f 100755 --- a/test/unittest/model/usb/device/include/usb_device_lite_cdcacm_test.h +++ b/test/unittest/model/usb/device/include/usb_device_lite_cdcacm_test.h @@ -31,9 +31,9 @@ #define WAIT_100MS 100 #define SYNC_5000MS 5000 #define CDC_ACM -#define QUEUE_SIZE 8 +#define QUEUE_SIZE 8 #define PORT_RATE 9600 -#define CHAR_FORMAT 8 +#define DATA_BIT 8 #define SS_MAX_PACKET_SIZE 1024 #define MAX_PACKET_SIZE 512 diff --git a/test/unittest/model/usb/device/src/usb_device_lite_cdcacm_test.c b/test/unittest/model/usb/device/src/usb_device_lite_cdcacm_test.c index 616660e89..d68c4e951 100755 --- a/test/unittest/model/usb/device/src/usb_device_lite_cdcacm_test.c +++ b/test/unittest/model/usb/device/src/usb_device_lite_cdcacm_test.c @@ -329,9 +329,9 @@ static struct Serial *SerialAlloc(void) DListHeadInit(&port->writePool); port->lineCoding.dwDTERate = CpuToLe32(PORT_RATE); - port->lineCoding.bCharFormat = CHAR_FORMAT; + port->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS; port->lineCoding.bParityType = USB_CDC_NO_PARITY; - port->lineCoding.bDataBits = USB_CDC_1_STOP_BITS; + port->lineCoding.bDataBits = DATA_BIT; return port; } @@ -440,12 +440,12 @@ static int AllocCtrlRequests(struct AcmDevice *acmDevice) } static int32_t SendNotifyRequest(struct AcmDevice *acm, uint8_t type, - uint16_t value, void *data, uint32_t length) + uint16_t value, const uint16_t *data, uint32_t length) { struct UsbFnRequest *req = acm->notifyReq; struct UsbCdcNotification *notify = NULL; int ret; - if ((acm == NULL) || (req == NULL) || (req->buf == NULL) || (data == NULL)) { + if ((acm == NULL) || (acm->ctrlIface.fn == NULL) || (req == NULL) || (req->buf == NULL) || (data == NULL)) { return -1; } acm->notifyReq = NULL; @@ -458,7 +458,10 @@ static int32_t SendNotifyRequest(struct AcmDevice *acm, uint8_t type, notify->wValue = CpuToLe16(value); notify->wIndex = CpuToLe16(acm->ctrlIface.fn->info.index); notify->wLength = CpuToLe16(length); - memcpy_s((void *)(notify + 1), length, data, length); + ret = memcpy_s((void *)(notify + 1), length, data, length); + if (ret != EOK) { + HDF_LOGE("%s: memcpy_s fail, ret=%d", __func__, ret); + } ret = UsbFnSubmitRequestAsync(req); return ret; diff --git a/test/unittest/model/usb/device/src/usb_device_lite_sdk_if_test.c b/test/unittest/model/usb/device/src/usb_device_lite_sdk_if_test.c index aa33cb215..e5a159437 100755 --- a/test/unittest/model/usb/device/src/usb_device_lite_sdk_if_test.c +++ b/test/unittest/model/usb/device/src/usb_device_lite_sdk_if_test.c @@ -17,11 +17,9 @@ #define HDF_LOG_TAG usb_device_sdk_test -static struct AcmDevice *g_acmDevice = NULL; +struct AcmDevice *g_acmDevice = NULL; extern struct UsbFnDeviceDesc g_acmFnDevice; -#include "usb_device_lite_sdk_io_test.c" - int32_t UsbFnDviceTestCreate(void) { dprintf("%s: start\n", __func__); diff --git a/test/unittest/model/usb/device/src/usb_device_lite_sdk_io_test.c b/test/unittest/model/usb/device/src/usb_device_lite_sdk_io_test.c index 7efc23b48..4bed92c13 100755 --- a/test/unittest/model/usb/device/src/usb_device_lite_sdk_io_test.c +++ b/test/unittest/model/usb/device/src/usb_device_lite_sdk_io_test.c @@ -12,6 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "usb_device_lite_cdcacm_test.h" + +#define HDF_LOG_TAG usb_device_sdk_test +extern struct AcmDevice *g_acmDevice; static void ReadComplete(uint8_t pipe, struct UsbFnRequest *req) { diff --git a/test/unittest/model/usb/host/include/usb_raw_test.h b/test/unittest/model/usb/host/include/usb_raw_test.h index de9c6ac37..d4871a7f8 100755 --- a/test/unittest/model/usb/host/include/usb_raw_test.h +++ b/test/unittest/model/usb/host/include/usb_raw_test.h @@ -161,7 +161,7 @@ enum UsbRawTestCmd { #define USB_CTRL_REQ_SIZE 256 #define DATARATE 9600 -#define CHARFORMAT 8 +#define DATA_BITS_LENGTH 8 #define ACM_NW 16 #define ACM_NR 16 #define READ_BUF_SIZE 8192 diff --git a/test/unittest/model/usb/host/include/usb_test.h b/test/unittest/model/usb/host/include/usb_test.h index d3188fad8..99da33d8b 100755 --- a/test/unittest/model/usb/host/include/usb_test.h +++ b/test/unittest/model/usb/host/include/usb_test.h @@ -120,7 +120,7 @@ enum UsbTestCmd { #define REQUEST_TYPE_MASK 0x3 #define DATARATE 9600 -#define CHARFORMAT 8 +#define DATA_BITS_LENGTH 8 #define ACM_NW 16 #define ACM_NR 16 #define READ_BUF_SIZE 8192 diff --git a/test/unittest/model/usb/host/src/usb_raw_test.c b/test/unittest/model/usb/host/src/usb_raw_test.c index 59cac2687..8f19fb97e 100755 --- a/test/unittest/model/usb/host/src/usb_raw_test.c +++ b/test/unittest/model/usb/host/src/usb_raw_test.c @@ -1269,9 +1269,9 @@ int32_t CheckRawSdkIfFillControlSetup001(void) struct AcmRawDevice *rawAcm = UsbGetIoAcm(); rawAcm->lineCoding.dwDTERate = CpuToLe32(DATARATE); - rawAcm->lineCoding.bCharFormat = CHARFORMAT; + rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS; rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY; - rawAcm->lineCoding.bDataBits = USB_CDC_1_STOP_BITS; + rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH; ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE; ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING; @@ -1337,9 +1337,9 @@ int32_t CheckRawSdkIfFillControlSetup004(void) struct AcmRawDevice *rawAcm = UsbGetIoAcm(); rawAcm->lineCoding.dwDTERate = CpuToLe32(DATARATE); - rawAcm->lineCoding.bCharFormat = CHARFORMAT; + rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS; rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY; - rawAcm->lineCoding.bDataBits = USB_CDC_1_STOP_BITS; + rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH; ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE; ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING; @@ -1377,9 +1377,9 @@ int32_t CheckRawSdkIfSendControlRequest001(void) struct AcmRawDevice *rawAcm = UsbGetIoAcm(); rawAcm->lineCoding.dwDTERate = CpuToLe32(DATARATE); - rawAcm->lineCoding.bCharFormat = CHARFORMAT; + rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS; rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY; - rawAcm->lineCoding.bDataBits = USB_CDC_1_STOP_BITS; + rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH; ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE; ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING; ctrlReq.value = CpuToLe16(0); @@ -1404,9 +1404,9 @@ int32_t CheckRawSdkIfSendControlRequest002(void) struct AcmRawDevice *rawAcm = UsbGetIoAcm(); rawAcm->lineCoding.dwDTERate = CpuToLe32(DATARATE); - rawAcm->lineCoding.bCharFormat = CHARFORMAT; + rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS; rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY; - rawAcm->lineCoding.bDataBits = USB_CDC_1_STOP_BITS; + rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH; ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE; ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING; ctrlReq.value = CpuToLe16(0); @@ -1444,9 +1444,9 @@ int32_t CheckRawSdkIfSendControlRequest004(void) struct AcmRawDevice *rawAcm = UsbGetIoAcm(); rawAcm->lineCoding.dwDTERate = CpuToLe32(DATARATE); - rawAcm->lineCoding.bCharFormat = CHARFORMAT; + rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS; rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY; - rawAcm->lineCoding.bDataBits = USB_CDC_1_STOP_BITS; + rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH; ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE; ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING; ctrlReq.value = CpuToLe16(0); @@ -1471,9 +1471,9 @@ int32_t CheckRawSdkIfSendControlRequest005(void) struct AcmRawDevice *rawAcm = UsbGetIoAcm(); rawAcm->lineCoding.dwDTERate = CpuToLe32(DATARATE); - rawAcm->lineCoding.bCharFormat = CHARFORMAT; + rawAcm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS; rawAcm->lineCoding.bParityType = USB_CDC_NO_PARITY; - rawAcm->lineCoding.bDataBits = USB_CDC_1_STOP_BITS; + rawAcm->lineCoding.bDataBits = DATA_BITS_LENGTH; ctrlReq.requestType = USB_DDK_DIR_OUT | USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE; ctrlReq.requestCmd = USB_DDK_CDC_REQ_SET_LINE_CODING; ctrlReq.value = CpuToLe16(0); diff --git a/test/unittest/model/usb/host/src/usb_test.c b/test/unittest/model/usb/host/src/usb_test.c index 60ffe422c..0963e1365 100755 --- a/test/unittest/model/usb/host/src/usb_test.c +++ b/test/unittest/model/usb/host/src/usb_test.c @@ -84,11 +84,11 @@ static void AcmWriteIsoCallback(struct UsbRequest *requestArg) printf("%s:%d status:%d\n", __func__, __LINE__, req->compInfo.status); } -static int AcmWriteBufAllocHandle(struct AcmDevice *acm) +static int AcmWriteBufAllocHandle(const struct AcmDevice *acm) { int i; struct AcmWb *wb; - for (wb = &acm->wb[0], i = 0; i < ACM_NW; i++, wb++) { + for (wb = (struct AcmWb *)&acm->wb[0], i = 0; i < ACM_NW; i++, wb++) { wb->buf = (uint8_t *)OsalMemCalloc(acm->writeSize); if (!wb->buf) { while (i != 0) { @@ -1477,9 +1477,9 @@ static int32_t CheckHostSdkIfFillRequest004(void) parmas.requestType = USB_REQUEST_PARAMS_CTRL_TYPE; parmas.timeout = USB_CTRL_SET_TIMEOUT; g_acm->lineCoding.dwDTERate = CpuToLe32(DATARATE); - g_acm->lineCoding.bCharFormat = CHARFORMAT; + g_acm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS; g_acm->lineCoding.bParityType = USB_CDC_NO_PARITY; - g_acm->lineCoding.bDataBits = USB_CDC_1_STOP_BITS; + g_acm->lineCoding.bDataBits = DATA_BITS_LENGTH; msgData.request = USB_DDK_CDC_REQ_SET_LINE_CODING; msgData.requestType = USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE; msgData.value = value; @@ -1656,9 +1656,9 @@ static int32_t CheckHostSdkIfFillRequest008(void) parmas.requestType = USB_REQUEST_PARAMS_CTRL_TYPE; parmas.timeout = USB_CTRL_SET_TIMEOUT; g_acm->lineCoding.dwDTERate = CpuToLe32(DATARATE); - g_acm->lineCoding.bCharFormat = CHARFORMAT; + g_acm->lineCoding.bCharFormat = USB_CDC_1_STOP_BITS; g_acm->lineCoding.bParityType = USB_CDC_NO_PARITY; - g_acm->lineCoding.bDataBits = USB_CDC_1_STOP_BITS; + g_acm->lineCoding.bDataBits = DATA_BITS_LENGTH; msgData.request = USB_DDK_CDC_REQ_SET_LINE_CODING; msgData.requestType = USB_DDK_TYPE_CLASS | USB_DDK_RECIP_INTERFACE; msgData.value = value; -- Gitee