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
importiofrom'socket.io-client';importControllerfrom'cncjs-controller';constcontroller=newController(io);consthost='';// e.g. https://127.0.0.1:8000consttoken='<security-token>';constoptions={query: 'token='+token};controller.connect(host,options,()=>{constport='/dev/cu.wchusbserialfa130';controller.openPort(port,{controllerType: 'Grbl',// Grbl|Smoothie|TinyGbaudrate: 115200},(err)=>{if(err){console.error(err);return;}controller.writeln('$$');// View Grbl Settings});// Disconnect after 60 secondssetTimeout(()=>{// Close portcontroller.closePort();// Close connectioncontroller.disconnect();},60*1000);});controller.addListener('serialport:open',(options)=>{const{
port,
baudrate,
controllerType
}=options;console.log(`Connected to the port "${port}" with a baud rate of ${baudrate}.`,{ port, baudrate });});controller.addListener('serialport:close',(options)=>{const{ port }=options;console.log(`The port "${port}" is disconnected.`);});controller.addListener('serialport:write',(data,context)=>{console.log('>',data);});controller.addListener('serialport:read',(data)=>{console.log('<',data);});
License
MIT
About
A controller library for event-based communication between client and CNCjs server.