• 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 
59 const int32_t PARITY_NONE = 0;
60 const int32_t PARITY_ODD = 1;
61 const int32_t PARITY_EVEN = 2;
62 const int32_t PARITY_MARK = 3;
63 const int32_t PARITY_SPACE = 4;
64 
65 const int32_t STOPBIT_1 = 0;
66 const int32_t STOPBIT_2 = 1;
67 
68 typedef struct SerialWriteAsyncContext {
69     int contextErrno;
70     int ret;
71     napi_deferred deferred;
72     napi_async_work work;
73     int32_t portId;
74     uint32_t size;
75     uint32_t timeout;
76     void* pData;
77 } SerialWriteAsyncContext;
78 
79 typedef struct SerialReadAsyncContext {
80     int contextErrno;
81     int ret;
82     napi_deferred deferred;
83     napi_async_work work;
84     int32_t portId;
85     uint32_t size;
86     uint32_t timeout;
87     void* pData;
88 } SerialReadAsyncContext;
89 
90 typedef struct SerialRequestRightAsyncContext {
91     int contextErrno;
92     bool hasRight;
93     napi_async_work work;
94     napi_deferred deferred;
95     int32_t portIdValue;
96 } SerialRequestRightAsyncContext;
97 } // namespace USB
98 } // namespace OHOS
99 #endif // SERIAL_ASYNC_CONTEXT_H