예제 #1
0
        private static async Task PrintReceiptImplementationAsync(ReceiptData receiptData)
        {
            if (!await SerialPortHelper.IsSerialPortPresentedAsync(ReceiptPrinterComPort))
            {
                return;
            }

            var deviceIoPortProvider = new UwpSerialPortProvider(new SerialPortSettings(ReceiptPrinterComPort, 115200, SerialStopBitCount.One, SerialParity.None));

            using (var devicePort = new DeviceIoPortDriver(deviceIoPortProvider))
            {
                await devicePort.OpenAsync();

                var messageBytes = GetReceiptBytes(receiptData);

                await devicePort.WriteAsync(messageBytes, CancellationToken.None);
            }
        }