1/* 2 * Copyright (c) 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 16/** 17 * @file 18 * @kit BasicServicesKit 19 */ 20 21/** 22 * Provides APIs for managing USB-to-virtual serial ports and implementing USB-to-virtual serial port communication. 23 * @namespace serialManager 24 * @syscap SystemCapability.USB.USBManager.Serial 25 * @since arkts {'1.1':'19', '1.2':'20'} 26 * @arkts 1.1&1.2 27 */ 28declare namespace serialManager { 29 30 /** 31 * Obtains the serial port device list. 32 * @returns { Readonly<SerialPort>[]} Returns the list of serial port devices obtained. 33 * @syscap SystemCapability.USB.USBManager.Serial 34 * @since arkts {'1.1':'19', '1.2':'20'} 35 * @arkts 1.1&1.2 36 */ 37 function getPortList(): Readonly<SerialPort>[]; 38 39 /** 40 * Checks whether a serial port device has the access right. The system applications have the access right by default. 41 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 42 * @returns {boolean} Returns <b class="+ topic/ph hi-d/b " id="b48481049115520">true</b> if the device has the right; returns <b class="+ topic/ph hi-d/b " id="b192241323195610">false</b> otherwise. 43 * @throws { BusinessError } 401 Parameter error. Possible causes: 44 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 45 * @throws { BusinessError } 14400005 Database operation exception. 46 * @throws { BusinessError } 31400001 Serial port management exception. 47 * @throws { BusinessError } 31400003 PortId does not exist. 48 * @syscap SystemCapability.USB.USBManager.Serial 49 * @since arkts{ '1.1':'19','1.2':'20'} 50 * @arkts 1.1&1.2 51 */ 52 function hasSerialRight(portId: int): boolean; 53 54 /** 55 * Requests the right for accessing a serial port device from the user. The system applications do not need to call this API. 56 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 57 * @returns { Promise<boolean>} Promise used to return the result. 58 * The value <b class="+ topic/ph hi-d/b " id="b529434412284">true</b> means the user allows the access; 59 * the value <b class="+ topic/ph hi-d/b " id="b89755211297">false</b> means the opposite. 60 * @throws { BusinessError } 401 Parameter error. Possible causes: 61 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 62 * @throws { BusinessError } 14400005 Database operation exception. 63 * @throws { BusinessError } 31400001 Serial port management exception. 64 * @throws { BusinessError } 31400003 PortId does not exist. 65 * @syscap SystemCapability.USB.USBManager.Serial 66 * @since arkts{ '1.1':'19','1.2':'20'} 67 * @arkts 1.1&1.2 68 */ 69 function requestSerialRight(portId: int): Promise<boolean>; 70 71 /** 72 * Adds the access right for a serial port device. 73 * @permission ohos.permission.MANAGE_USB_CONFIG 74 * @param { int } tokenId Token ID of the target application. 75 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 76 * @throws { BusinessError } 201 Permission verification failed. The application does not have the permission required to call the API. 77 * @throws { BusinessError } 202 Permission verification failed. A non-system application calls a system API. 78 * @throws { BusinessError } 401 Parameter error. Possible causes: 79 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 80 * @throws { BusinessError } 14400005 Database operation exception. 81 * @throws { BusinessError } 31400001 Serial port management exception. 82 * @throws { BusinessError } 31400003 PortId does not exist. 83 * @syscap SystemCapability.USB.USBManager.Serial 84 * @systemapi 85 * @since arkts{ '1.1':'19','1.2':'20'} 86 * @arkts 1.1&1.2 87 */ 88 function addSerialRight(tokenId: int, portId: int): void; 89 90 /** 91 * Cancels the access right for a serial port device. This API will not cancel the default access right of system applications. 92 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 93 * @throws { BusinessError } 401 Parameter error. Possible causes: 94 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 95 * @throws { BusinessError } 14400005 Database operation exception. 96 * @throws { BusinessError } 31400001 Serial port management exception. 97 * @throws { BusinessError } 31400002 Access denied. Call requestSerialRight to request user authorization first. 98 * @throws { BusinessError } 31400003 PortId does not exist. 99 * @syscap SystemCapability.USB.USBManager.Serial 100 * @since arkts{ '1.1':'19','1.2':'20'} 101 * @arkts 1.1&1.2 102 */ 103 function cancelSerialRight(portId: int): void; 104 105 /** 106 * Opens a serial port device. 107 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 108 * @throws { BusinessError } 401 Parameter error. Possible causes: 109 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 110 * @throws { BusinessError } 31400001 Serial port management exception. 111 * @throws { BusinessError } 31400002 Access denied. Call requestSerialRight to request user authorization first. 112 * @throws { BusinessError } 31400003 PortId does not exist. 113 * @throws { BusinessError } 31400004 The serial port device is occupied. 114 * @syscap SystemCapability.USB.USBManager.Serial 115 * @since arkts{ '1.1':'19','1.2':'20'} 116 * @arkts 1.1&1.2 117 */ 118 function open(portId: int): void; 119 120 /** 121 * Closes a serial port device. 122 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 123 * @throws { BusinessError } 401 Parameter error. Possible causes: 124 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 125 * @throws { BusinessError } 31400001 Serial port management exception. 126 * @throws { BusinessError } 31400003 PortId does not exist. 127 * @throws { BusinessError } 31400005 The serial port device is not opened. Call the open API first. 128 * @syscap SystemCapability.USB.USBManager.Serial 129 * @since arkts{ '1.1':'19','1.2':'20'} 130 * @arkts 1.1&1.2 131 */ 132 function close(portId: int): void; 133 134 /** 135 * Obtains the communication parameters of a serial port device. 136 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 137 * @returns { Readonly<SerialAttribute>} Communication parameters obtained, which are read-only. 138 * @throws { BusinessError } 401 Parameter error. Possible causes: 139 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 140 * @throws { BusinessError } 31400001 Serial port management exception. 141 * @throws { BusinessError } 31400003 PortId does not exist. 142 * @throws { BusinessError } 31400005 The serial port device is not opened. Call the open API first. 143 * @syscap SystemCapability.USB.USBManager.Serial 144 * @since arkts{ '1.1':'19','1.2':'20'} 145 * @arkts 1.1&1.2 146 */ 147 function getAttribute(portId: int): Readonly<SerialAttribute>; 148 149 /** 150 * Sets the communication parameters for a serial port device. 151 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 152 * @param { SerialAttribute} attribute Communication parameters to set. 153 * @throws { BusinessError } 401 Parameter error. Possible causes: 154 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 155 * @throws { BusinessError } 31400001 Serial port management exception. 156 * @throws { BusinessError } 31400003 PortId does not exist. 157 * @throws { BusinessError } 31400005 The serial port device is not opened. Call the open API first. 158 * @syscap SystemCapability.USB.USBManager.Serial 159 * @since arkts{ '1.1':'19','1.2':'20'} 160 * @arkts 1.1&1.2 161 */ 162 function setAttribute(portId: int, attribute: SerialAttribute): void; 163 164 /** 165 * Reads data from a serial port device. This API uses a promise to return the result. 166 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 167 * @param { Uint8Array } buffer Buffer for storing the data read, with a maximum length of 8192 bytes. 168 * @param { int } timeout Timeout duration for reading data. The value is a non-negative number. 169 * The default value <b class="+ topic/ph hi-d/b " id="b98612056312">0</b> indicates that there is no time limit for data reading. 170 * @returns { Promise<int> } Promise used to return the length of the data read. 171 * @throws { BusinessError } 401 Parameter error. Possible causes: 172 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 173 * @throws { BusinessError } 31400001 Serial port management exception. 174 * @throws { BusinessError } 31400003 PortId does not exist. 175 * @throws { BusinessError } 31400005 The serial port device is not opened. Call the open API first. 176 * @throws { BusinessError } 31400006 Data transfer timed out. 177 * @throws { BusinessError } 31400007 I/O exception. Possible causes: 178 * <br>1. The transfer was canceled. 179 * <br>2. The device offered more data than allowed. 180 * @syscap SystemCapability.USB.USBManager.Serial 181 * @since arkts{ '1.1':'19','1.2':'20'} 182 * @arkts 1.1&1.2 183 */ 184 function read(portId: int, buffer: Uint8Array, timeout?: int): Promise<int>; 185 186 /** 187 * Reads data from a serial port device. This API returns the result synchronously. 188 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 189 * @param { Uint8Array } buffer Buffer for storing the data read, with a maximum length of 8192 bytes. 190 * @param { int } timeout Timeout duration for reading data. The value is a non-negative number. 191 * The default value <b class="+ topic/ph hi-d/b " id="b25229382302">0</b> indicates that there is no time limit for data reading. 192 * @returns {int} Length of the data read. 193 * @throws { BusinessError } 401 Parameter error. Possible causes: 194 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 195 * @throws { BusinessError } 31400001 Serial port management exception. 196 * @throws { BusinessError } 31400003 PortId does not exist. 197 * @throws { BusinessError } 31400005 The serial port device is not opened. Call the open API first. 198 * @throws { BusinessError } 31400006 Data transfer timed out. 199 * @throws { BusinessError } 31400007 I/O exception. Possible causes: 200 * <br>1. The transfer was canceled. 201 * <br>2. The device offered more data than allowed. 202 * @syscap SystemCapability.USB.USBManager.Serial 203 * @since arkts{ '1.1':'19','1.2':'20'} 204 * @arkts 1.1&1.2 205 */ 206 function readSync(portId: int, buffer: Uint8Array, timeout?: int): int; 207 208 /** 209 * Writes data to a serial port device. This API uses a promise to return the result. 210 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 211 * @param { Uint8Array } buffer Buffer for storing the data written, with a maximum length of 128 KB. 212 * @param { int } timeout Timeout duration for writing data. The value is a non-negative number. 213 * The default value <b class="+ topic/ph hi-d/b " id="b2661577365">0</b> indicates that there is no time limit for data writing. 214 * @returns { Promise<int> } Promise used to return the length of the data written. 215 * @throws { BusinessError } 401 Parameter error. Possible causes: 216 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 217 * @throws { BusinessError } 31400001 Serial port management exception. 218 * @throws { BusinessError } 31400003 PortId does not exist. 219 * @throws { BusinessError } 31400005 The serial port device is not opened. Call the open API first. 220 * @throws { BusinessError } 31400006 Data transfer timed out. 221 * @throws { BusinessError } 31400007 I/O exception. Possible causes: 222 * <br>1. The transfer was canceled. 223 * <br>2. The device offered more data than allowed. 224 * @syscap SystemCapability.USB.USBManager.Serial 225 * @since arkts{ '1.1':'19','1.2':'20'} 226 * @arkts 1.1&1.2 227 */ 228 function write(portId: int, buffer: Uint8Array, timeout?: int): Promise<int>; 229 230 /** 231 * Writes data to a serial port device. This API returns the result synchronously. 232 * @param { int} portId ID of the target device. For details, see <b>SerialPort.portId</b>. 233 * @param { Uint8Array } buffer Buffer for storing the data written, with a maximum length of 128 KB. 234 * @param { int } timeout Timeout duration for writing data. The value is a non-negative number. 235 * The default value <b class="+ topic/ph hi-d/b " id="b45639213380">0</b> indicates that there is no time limit for data writing. 236 * @returns { int } Length of the data written. 237 * @throws { BusinessError } 401 Parameter error. Possible causes: 238 * 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. 239 * @throws { BusinessError } 31400001 Serial port management exception. 240 * @throws { BusinessError } 31400003 PortId does not exist. 241 * @throws { BusinessError } 31400005 The serial port device is not opened. Call the open API first. 242 * @throws { BusinessError } 31400006 Data transfer timed out. 243 * @throws { BusinessError } 31400007 I/O exception. Possible causes: 244 * <br>1. The transfer was canceled. 245 * <br>2. The device offered more data than allowed. 246 * @syscap SystemCapability.USB.USBManager.Serial 247 * @since arkts{ '1.1':'19','1.2':'20'} 248 * @arkts 1.1&1.2 249 */ 250 function writeSync(portId: int, buffer: Uint8Array, timeout?: int): int; 251 252 /** 253 * Represents a serial port device. 254 * @typedef SerialPort 255 * @syscap SystemCapability.USB.USBManager.Serial 256 * @since arkts {'1.1':'19', '1.2':'20'} 257 * @arkts 1.1&1.2 258 */ 259 interface SerialPort { 260 261 /** 262 * Serial port device ID. 263 * @type { int } 264 * @syscap SystemCapability.USB.USBManager.Serial 265 * @since arkts {'1.1':'19', '1.2':'20'} 266 * @arkts 1.1&1.2 267 */ 268 portId: int; 269 270 /** 271 * Serial port device name. 272 * @type { string } 273 * @syscap SystemCapability.USB.USBManager.Serial 274 * @since arkts {'1.1':'19', '1.2':'20'} 275 * @arkts 1.1&1.2 276 */ 277 deviceName: string; 278 } 279 /** 280 * Represents the communication parameters of a serial port device. 281 * @typedef SerialAttribute 282 * @syscap SystemCapability.USB.USBManager.Serial 283 * @since arkts {'1.1':'19', '1.2':'20'} 284 * @arkts 1.1&1.2 285 */ 286 interface SerialAttribute { 287 288 /** 289 * Baud rate. 290 * @type { BaudRates } 291 * @syscap SystemCapability.USB.USBManager.Serial 292 * @since arkts {'1.1':'19', '1.2':'20'} 293 * @arkts 1.1&1.2 294 */ 295 baudRate: BaudRates; 296 297 /** 298 * Data bits. 299 * @type { DataBits } 300 * @default DATABIT_8 301 * @syscap SystemCapability.USB.USBManager.Serial 302 * @since arkts {'1.1':'19', '1.2':'20'} 303 * @arkts 1.1&1.2 304 */ 305 dataBits?: DataBits; 306 307 /** 308 * Parity bit. 309 * @type { Parity } 310 * @default NONE 311 * @syscap SystemCapability.USB.USBManager.Serial 312 * @since arkts {'1.1':'19', '1.2':'20'} 313 * @arkts 1.1&1.2 314 */ 315 parity?: Parity; 316 317 /** 318 * Stop bits. 319 * @type { StopBits } 320 * @default STOPBIT_1 321 * @syscap SystemCapability.USB.USBManager.Serial 322 * @since arkts {'1.1':'19', '1.2':'20'} 323 * @arkts 1.1&1.2 324 */ 325 stopBits?: StopBits; 326 } 327 /** 328 * Enumerates the baud rates of a serial port device, in bit/s. 329 * @enum { int } 330 * @syscap SystemCapability.USB.USBManager.Serial 331 * @since arkts {'1.1':'19', '1.2':'20'} 332 * @arkts 1.1&1.2 333 */ 334 enum BaudRates { 335 336 /** 337 * The baud rate is 50 bit/s. 338 * @syscap SystemCapability.USB.USBManager.Serial 339 * @since arkts {'1.1':'19', '1.2':'20'} 340 * @arkts 1.1&1.2 341 */ 342 BAUDRATE_50 = 50, 343 344 /** 345 * The baud rate is 75 bit/s. 346 * @syscap SystemCapability.USB.USBManager.Serial 347 * @since arkts {'1.1':'19', '1.2':'20'} 348 * @arkts 1.1&1.2 349 */ 350 BAUDRATE_75 = 75, 351 352 /** 353 * The baud rate is 110 bit/s. 354 * @syscap SystemCapability.USB.USBManager.Serial 355 * @since arkts {'1.1':'19', '1.2':'20'} 356 * @arkts 1.1&1.2 357 */ 358 BAUDRATE_110 = 110, 359 360 /** 361 * The baud rate is 134 bit/s. 362 * @syscap SystemCapability.USB.USBManager.Serial 363 * @since arkts {'1.1':'19', '1.2':'20'} 364 * @arkts 1.1&1.2 365 */ 366 BAUDRATE_134 = 134, 367 368 /** 369 * The baud rate is 150 bit/s. 370 * 371 * @syscap SystemCapability.USB.USBManager.Serial 372 * @since arkts {'1.1':'19', '1.2':'20'} 373 * @arkts 1.1&1.2 374 */ 375 BAUDRATE_150 = 150, 376 377 /** 378 * The baud rate is 200 bit/s. 379 * @syscap SystemCapability.USB.USBManager.Serial 380 * @since arkts {'1.1':'19', '1.2':'20'} 381 * @arkts 1.1&1.2 382 */ 383 BAUDRATE_200 = 200, 384 385 /** 386 * The baud rate is 300 bit/s. 387 * @syscap SystemCapability.USB.USBManager.Serial 388 * @since arkts {'1.1':'19', '1.2':'20'} 389 * @arkts 1.1&1.2 390 */ 391 BAUDRATE_300 = 300, 392 393 /** 394 * The baud rate is 600 bit/s. 395 * @syscap SystemCapability.USB.USBManager.Serial 396 * @since arkts {'1.1':'19', '1.2':'20'} 397 * @arkts 1.1&1.2 398 */ 399 BAUDRATE_600 = 600, 400 401 /** 402 * The baud rate is 1200 bit/s. 403 * @syscap SystemCapability.USB.USBManager.Serial 404 * @since arkts {'1.1':'19', '1.2':'20'} 405 * @arkts 1.1&1.2 406 */ 407 BAUDRATE_1200 = 1200, 408 409 /** 410 * The baud rate is 1800 bit/s. 411 * @syscap SystemCapability.USB.USBManager.Serial 412 * @since arkts {'1.1':'19', '1.2':'20'} 413 * @arkts 1.1&1.2 414 */ 415 BAUDRATE_1800 = 1800, 416 417 /** 418 * The baud rate is 2400 bit/s. 419 * @syscap SystemCapability.USB.USBManager.Serial 420 * @since arkts {'1.1':'19', '1.2':'20'} 421 * @arkts 1.1&1.2 422 */ 423 BAUDRATE_2400 = 2400, 424 425 /** 426 * The baud rate is 4800 bit/s. 427 * @syscap SystemCapability.USB.USBManager.Serial 428 * @since arkts {'1.1':'19', '1.2':'20'} 429 * @arkts 1.1&1.2 430 */ 431 BAUDRATE_4800 = 4800, 432 433 /** 434 * The baud rate is 9600 bit/s. 435 * @syscap SystemCapability.USB.USBManager.Serial 436 * @since arkts {'1.1':'19', '1.2':'20'} 437 * @arkts 1.1&1.2 438 */ 439 BAUDRATE_9600 = 9600, 440 441 /** 442 * The baud rate is 19200 bit/s. 443 * @syscap SystemCapability.USB.USBManager.Serial 444 * @since arkts {'1.1':'19', '1.2':'20'} 445 * @arkts 1.1&1.2 446 */ 447 BAUDRATE_19200 = 19200, 448 449 /** 450 * The baud rate is 38400 bit/s. 451 * @syscap SystemCapability.USB.USBManager.Serial 452 * @since arkts {'1.1':'19', '1.2':'20'} 453 * @arkts 1.1&1.2 454 */ 455 BAUDRATE_38400 = 38400, 456 457 /** 458 * The baud rate is 57600 bit/s. 459 * @syscap SystemCapability.USB.USBManager.Serial 460 * @since arkts {'1.1':'19', '1.2':'20'} 461 * @arkts 1.1&1.2 462 */ 463 BAUDRATE_57600 = 57600, 464 465 /** 466 * The baud rate is 115200 bit/s. 467 * @syscap SystemCapability.USB.USBManager.Serial 468 * @since arkts {'1.1':'19', '1.2':'20'} 469 * @arkts 1.1&1.2 470 */ 471 BAUDRATE_115200 = 115200, 472 473 /** 474 * The baud rate is 230400 bit/s. 475 * @syscap SystemCapability.USB.USBManager.Serial 476 * @since arkts {'1.1':'19', '1.2':'20'} 477 * @arkts 1.1&1.2 478 */ 479 BAUDRATE_230400 = 230400, 480 481 /** 482 * The baud rate is 460800 bit/s. 483 * @syscap SystemCapability.USB.USBManager.Serial 484 * @since arkts {'1.1':'19', '1.2':'20'} 485 * @arkts 1.1&1.2 486 */ 487 BAUDRATE_460800 = 460800, 488 489 /** 490 * The baud rate is 500000 bit/s. 491 * @syscap SystemCapability.USB.USBManager.Serial 492 * @since arkts {'1.1':'19', '1.2':'20'} 493 * @arkts 1.1&1.2 494 */ 495 BAUDRATE_500000 = 500000, 496 497 /** 498 * The baud rate is 576000 bit/s. 499 * @syscap SystemCapability.USB.USBManager.Serial 500 * @since arkts {'1.1':'19', '1.2':'20'} 501 * @arkts 1.1&1.2 502 */ 503 BAUDRATE_576000 = 576000, 504 505 /** 506 * The baud rate is 921600 bit/s. 507 * @syscap SystemCapability.USB.USBManager.Serial 508 * @since arkts {'1.1':'19', '1.2':'20'} 509 * @arkts 1.1&1.2 510 */ 511 BAUDRATE_921600 = 921600, 512 513 /** 514 * The baud rate is 1000000 bit/s. 515 * @syscap SystemCapability.USB.USBManager.Serial 516 * @since arkts {'1.1':'19', '1.2':'20'} 517 * @arkts 1.1&1.2 518 */ 519 BAUDRATE_1000000 = 1000000, 520 521 /** 522 * The baud rate is 1152000 bit/s. 523 * @syscap SystemCapability.USB.USBManager.Serial 524 * @since arkts {'1.1':'19', '1.2':'20'} 525 * @arkts 1.1&1.2 526 */ 527 BAUDRATE_1152000 = 1152000, 528 529 /** 530 * The baud rate is 1500000 bit/s. 531 * @syscap SystemCapability.USB.USBManager.Serial 532 * @since arkts {'1.1':'19', '1.2':'20'} 533 * @arkts 1.1&1.2 534 */ 535 BAUDRATE_1500000 = 1500000, 536 537 /** 538 * The baud rate is 2000000 bit/s. 539 * @syscap SystemCapability.USB.USBManager.Serial 540 * @since arkts {'1.1':'19', '1.2':'20'} 541 * @arkts 1.1&1.2 542 */ 543 BAUDRATE_2000000 = 2000000, 544 545 /** 546 * The baud rate is 2500000 bit/s. 547 * @syscap SystemCapability.USB.USBManager.Serial 548 * @since arkts {'1.1':'19', '1.2':'20'} 549 * @arkts 1.1&1.2 550 */ 551 BAUDRATE_2500000 = 2500000, 552 553 /** 554 * The baud rate is 3000000 bit/s. 555 * @syscap SystemCapability.USB.USBManager.Serial 556 * @since arkts {'1.1':'19', '1.2':'20'} 557 * @arkts 1.1&1.2 558 */ 559 BAUDRATE_3000000 = 3000000, 560 561 /** 562 * The baud rate is 3500000 bit/s. 563 * @syscap SystemCapability.USB.USBManager.Serial 564 * @since arkts {'1.1':'19', '1.2':'20'} 565 * @arkts 1.1&1.2 566 */ 567 BAUDRATE_3500000 = 3500000, 568 569 /** 570 * The baud rate is 4000000 bit/s. 571 * @syscap SystemCapability.USB.USBManager.Serial 572 * @since arkts {'1.1':'19', '1.2':'20'} 573 * @arkts 1.1&1.2 574 */ 575 BAUDRATE_4000000 = 4000000 576 } 577 /** 578 * Enumerates the data bits of a serial port device. 579 * @enum { int } 580 * @syscap SystemCapability.USB.USBManager.Serial 581 * @since arkts {'1.1':'19', '1.2':'20'} 582 * @arkts 1.1&1.2 583 */ 584 enum DataBits { 585 586 /** 587 * The number of data bits is 8. 588 * @syscap SystemCapability.USB.USBManager.Serial 589 * @since arkts {'1.1':'19', '1.2':'20'} 590 * @arkts 1.1&1.2 591 */ 592 DATABIT_8 = 8, 593 594 /** 595 * The number of data bits is 7. 596 * @syscap SystemCapability.USB.USBManager.Serial 597 * @since arkts {'1.1':'19', '1.2':'20'} 598 * @arkts 1.1&1.2 599 */ 600 DATABIT_7 = 7, 601 602 /** 603 * The number of data bits is 6. 604 * @syscap SystemCapability.USB.USBManager.Serial 605 * @since arkts {'1.1':'19', '1.2':'20'} 606 * @arkts 1.1&1.2 607 */ 608 DATABIT_6 = 6, 609 610 /** 611 * The number of data bits is 5. 612 * @syscap SystemCapability.USB.USBManager.Serial 613 * @since arkts {'1.1':'19', '1.2':'20'} 614 * @arkts 1.1&1.2 615 */ 616 DATABIT_5 = 5 617 } 618 /** 619 * Enumerates the parity bits of a serial port device. 620 * @enum { int } 621 * @syscap SystemCapability.USB.USBManager.Serial 622 * @since arkts {'1.1':'19', '1.2':'20'} 623 * @arkts 1.1&1.2 624 */ 625 enum Parity { 626 627 /** 628 * No parity. 629 * @syscap SystemCapability.USB.USBManager.Serial 630 * @since arkts {'1.1':'19', '1.2':'20'} 631 * @arkts 1.1&1.2 632 */ 633 PARITY_NONE = 0, 634 635 /** 636 * Odd parity. 637 * @syscap SystemCapability.USB.USBManager.Serial 638 * @since arkts {'1.1':'19', '1.2':'20'} 639 * @arkts 1.1&1.2 640 */ 641 PARITY_ODD = 1, 642 643 /** 644 * Even parity. 645 * @syscap SystemCapability.USB.USBManager.Serial 646 * @since arkts {'1.1':'19', '1.2':'20'} 647 * @arkts 1.1&1.2 648 */ 649 PARITY_EVEN = 2, 650 651 /** 652 * Mark parity, whose parity bit is always <b class="+ topic/ph hi-d/b " id="b1627884485115">1</b>. 653 * @syscap SystemCapability.USB.USBManager.Serial 654 * @since arkts {'1.1':'19', '1.2':'20'} 655 * @arkts 1.1&1.2 656 */ 657 PARITY_MARK = 3, 658 659 /** 660 * Space parity, whose parity bit is always <b class="+ topic/ph hi-d/b " id="b1551818484291">0</b>. 661 * @syscap SystemCapability.USB.USBManager.Serial 662 * @since arkts {'1.1':'19', '1.2':'20'} 663 * @arkts 1.1&1.2 664 */ 665 PARITY_SPACE = 4 666 } 667 /** 668 * Enumerates the stop bits for serial port communication. 669 * @enum { int } 670 * @syscap SystemCapability.USB.USBManager.Serial 671 * @since arkts {'1.1':'19', '1.2':'20'} 672 * @arkts 1.1&1.2 673 */ 674 enum StopBits { 675 676 /** 677 * The number of stop bits is 1. 678 * @syscap SystemCapability.USB.USBManager.Serial 679 * @since arkts {'1.1':'19', '1.2':'20'} 680 * @arkts 1.1&1.2 681 */ 682 STOPBIT_1 = 0, 683 684 /** 685 * The number of stop bits is 2. 686 * @syscap SystemCapability.USB.USBManager.Serial 687 * @since arkts {'1.1':'19', '1.2':'20'} 688 * @arkts 1.1&1.2 689 */ 690 STOPBIT_2 = 1 691 } 692} 693 694export default serialManager;