You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Has anybody got this working with deno. i tried but app exits without error.
Sample code:
import"jsr:@std/dotenv/load";// to get debug messages from npm package// .env file contains 'DEBUG=serialport*'import{SerialPort,ReadlineParser}from'npm:serialport'constports=awaitSerialPort.list()constserial_port_path="COM4"letfound_port=falsefor(constportofports){// @ts-ignore: linter complains about friendlyName, disable errorconsole.log(port.path+" ("+port.friendlyName+")")if(serial_port_path==port.path){found_port=true}}if(found_port==false){console.error("did not find PORT: "+serial_port_path+"")}constcurrent_port=newSerialPort({path: serial_port_path,baudRate: 115200,autoOpen: false})current_port.open(function(err){if(err){returnconsole.log('Error opening port: ',err.message)}})// The open event is always emittedcurrent_port.on('open',function(){// open logicconsole.log("Port open")})// const parser = new ReadlineParser()// current_port.pipe(parser)// parser.on('data', (data)=>{// console.log(data)// })setTimeout(()=>{current_port.write('main screen turn on\r\n',function(err){if(err){returnconsole.log('Error on write: ',err.message)}console.log('message written')})},500)console.log("Exiting in 5seconds")setTimeout(()=>{console.log("Exiting")Deno.exit()},5000)Deno.addSignalListener("SIGINT",()=>{current_port.close()console.log("SIGINT!");Deno.exit();});Deno.addSignalListener("SIGBREAK",()=>{current_port.close()console.log("SIGBREAK!");Deno.exit();});
outputs:
deno run -A .\deno_serialport.ts
serialport/bindings-cpp loading WindowsBinding +0ms
COM3 (Original Prusa i3 MK2 (COM3))
COM1 (Communications Port (COM1))
COM4 (USB-SERIAL CH340 (COM4))
COM5 (USB Serial Port (COM5))
serialport/stream opening path: COM4 +0ms
serialport/bindings-cpp open +0ms
Exiting in 5seconds
serialport/stream opened path: COM4 +4ms
Port open
serialport/stream _write 21 bytes of data +503ms
serialport/bindings-cpp write 21 bytes +507ms
PS O:\OneDrive\Programming\deno\location_commander>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Has anybody got this working with deno. i tried but app exits without error.
Sample code:
outputs:
Beta Was this translation helpful? Give feedback.
All reactions