import IPostMessage from '../IPostMessage'; import Led from './Led/Led'; import ISerialPortOptions from './ISerialPortOptions'; import ISerialPortDataMessage from './ISerialPortDataMessage'; import BarcodeScanner from './BarcodeScanner/BarcodeScanner'; import IBarcodeScannerDataMessage from './BarcodeScanner/IBarcodeScannerDataMessage'; import IHardware from './IHardware'; import ISerialPort from './ISerialPort'; /** * The `sos.hardware` API groups together methods for working with hardware. It allows opening serial ports, using bar scanner or controlling LEDs. * * :::warning * - Before using this API, ensure that the display [supports](/sdk/sos/display#supports) serial via `sos.display.supports("SERIAL")`. * - Samsung Kiosk serial connection only works over serial ports, not over USB ports. * ::: * *
* Device Hardware Capabilities * | Capability | Description | * |:------------|:-------------| * | `SERIAL` | If the device supports sending and receiving data via serial ports | * * If you want to check if the device supports this capability, use [`sos.display.supports()`](https://developers.signageos.io/sdk/sos/display#supports). *
* * ### List of supported serial ports * Bellow is example list of serial ports that can be used with `sos.hardware.openSerialPort()` method. * * | Device type | Default value | Other available values | * |:----|:-----|:------| * | RaspberryPi / Linux | `/dev/ttyS0` | `/dev/ttyS1`, `/dev/ttyUSB0`, `/dev/ttyUSB1` | * | Windows | `COM3` | `COM1`, `COM2`, `COM4` etc. Usually it's always `COM3` | * | Samsung Kiosk | `PORT1` | `PORT2`, `PORT3`, `PORT4` | * | Android | `/dev/ttyusb0` | `/dev/ttyusb1`, `/dev/ttyusb2` | * | BrightSign | `0` | `0` (Serial Jack as `/dev/ttyS0`), `1` (GPIO port as `/dev/ttyS1`), `USB:A/0` (USB-to-serial as `/dev/ttyUSB0`) | */ export default class Hardware implements IHardware { private messagePrefix; private postMessage; static MESSAGE_PREFIX: string; readonly led: Led; barcodeScanner: BarcodeScanner; private readonly eventEmitter; /** @internal */ constructor(messagePrefix: string, postMessage: IPostMessage); /** * The `openSerialPort()` method opens a serial port for reading/writing. After the port is opened the method returns {@link ISerialPort} interface. * * @param options.device Specifies the address of the external device, check the table above for ports. * @param options.baudRate Specifies the data transmission speed in bits per second. * @param options.parity Specifies the form of error checking, whether (or what) extra bits are added to a byte. * @param options.databits Specifies the number of bits in a byte. * @param options.stopbits Specifies the number of bits used to signal the end of a communication packet. * @param options.rtscts Enables or disables RTS/CTS handshaking over the serial port. Currently supported by selected models of BrightSign. * @returns Returns a promise that resolves to an instance of {@link ISerialPort} interface, which can be used to read/write data from/to the serial port. * @throws {Error} If the serial port cannot be opened. * @throws {Error} If the device address is not supported by the platform. * @throws {Error} If the device fails to process the data. * @throws {Error} If any other error occurs while opening the serial port. * @since 4.4.0 * * @example * // Open serial port on BrightSign with default settings * const serialPort = await sos.hardware.openSerialPort({ * device: '0', * baudRate: 9600, * }); * serialPort.write('68656c6c6f'); // Write "hello" in hexadecimal */ openSerialPort(options: ISerialPortOptions): Promise; /** @internal */ handleMessageData(data: ISerialPortDataMessage | IBarcodeScannerDataMessage): void; private getMessage; private getMessagePrefix; }