Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import {webusb} from 'usb'; import {getNodeUsbSiDeviceDriver} from 'sportident-node-usb/lib'; import {Shell, getSiShellCommands} from 'sportident-testbench-shell/lib'; import {SiExternalApplication} from './SiExternalApplication'; const nodeUsbDriver = getNodeUsbSiDeviceDriver(webusb); nodeUsbDriver.detect() .then((device) => { console.log('We have a device:', device); const getCharBuffer: number[] = []; process.stdin.setRawMode(true); process.stdin.setEncoding('utf-8'); process.stdin.on('data', (char: string) => { const charCode = char.charCodeAt(0); Iif (charCode === 127) { getCharBuffer.push(8); getCharBuffer.push(32); getCharBuffer.push(8); return; } getCharBuffer.push(charCode); }); const siShell = new Shell( { getChar: () => { Iif (getCharBuffer.length === 0) { return undefined; } return getCharBuffer.shift(); }, putChar: (char: number) => process.stdout.write(String.fromCharCode(char)), }, getSiShellCommands(), { initialEnv: { device: device, externalApplication: SiExternalApplication, }, }, ); siShell.run().then(() => { process.exit(); }); }) .catch((err) => { console.log(`Error: ${err}`); }); |