• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef SERIAL_ASYNC_CONTEXT_H
16 #define SERIAL_ASYNC_CONTEXT_H
17 
18 #include "napi/native_api.h"
19 #include "napi/native_node_api.h"
20 
21 namespace OHOS {
22 namespace USB {
23 const int32_t BAUDRATE_50 = 50;
24 const int32_t BAUDRATE_75 = 75;
25 const int32_t BAUDRATE_110 = 110;
26 const int32_t BAUDRATE_134 = 134;
27 const int32_t BAUDRATE_150 = 150;
28 const int32_t BAUDRATE_200 = 200;
29 const int32_t BAUDRATE_300 = 300;
30 const int32_t BAUDRATE_600 = 600;
31 const int32_t BAUDRATE_1200 = 1200;
32 const int32_t BAUDRATE_1800 = 1800;
33 const int32_t BAUDRATE_2400 = 2400;
34 const int32_t BAUDRATE_4800 = 4800;
35 const int32_t BAUDRATE_9600 = 9600;
36 const int32_t BAUDRATE_19200 = 19200;
37 const int32_t BAUDRATE_38400 = 38400;
38 const int32_t BAUDRATE_57600 = 57600;
39 const int32_t BAUDRATE_115200 = 115200;
40 const int32_t BAUDRATE_230400 = 230400;
41 const int32_t BAUDRATE_460800 = 460800;
42 const int32_t BAUDRATE_500000 = 500000;
43 const int32_t BAUDRATE_576000 = 576000;
44 const int32_t BAUDRATE_921600 = 921600;
45 const int32_t BAUDRATE_1000000 = 1000000;
46 const int32_t BAUDRATE_1152000 = 1152000;
47 const int32_t BAUDRATE_1500000 = 1500000;
48 const int32_t BAUDRATE_2000000 = 2000000;
49 const int32_t BAUDRATE_2500000 = 2500000;
50 const int32_t BAUDRATE_3000000 = 3000000;
51 const int32_t BAUDRATE_3500000 = 3500000;
52 const int32_t BAUDRATE_4000000 = 4000000;
53 
54 const int32_t DATABIT_8 = 8;
55 const int32_t DATABIT_7 = 7;
56 const int32_t DATABIT_6 = 6;
57 const int32_t DATABIT_5 = 5;
58 const int32_t DATABIT_4 = 4;
59 
60 const int32_t PARITY_NONE = 0;
61 const int32_t PARITY_ODD = 1;
62 const int32_t PARITY_EVEN = 2;
63 const int32_t PARITY_MARK = 3;
64 const int32_t PARITY_SPACE = 4;
65 
66 const int32_t STOPBIT_1 = 0;
67 const int32_t STOPBIT_1P5 = 1;
68 const int32_t STOPBIT_2 = 2;
69 
70 typedef struct SerialWriteAsyncContext {
71     int contextErrno;
72     int ret;
73     napi_deferred deferred;
74     napi_async_work work;
75     int32_t portId;
76     uint32_t size;
77     uint32_t timeout;
78     void* pData;
79 } SerialWriteAsyncContext;
80 
81 typedef struct SerialReadAsyncContext {
82     int contextErrno;
83     int ret;
84     napi_deferred deferred;
85     napi_async_work work;
86     int32_t portId;
87     uint32_t size;
88     uint32_t timeout;
89     void* pData;
90 } SerialReadAsyncContext;
91 
92 typedef struct SerialRequestRightAsyncContext {
93     int contextErrno;
94     bool hasRight;
95     napi_async_work work;
96     napi_deferred deferred;
97     int32_t portIdValue;
98 } SerialRequestRightAsyncContext;
99 } // namespace USB
100 } // namespace OHOS
101 #endif // SERIAL_ASYNC_CONTEXT_H