доделали всё
This commit is contained in:
parent
7119c4a699
commit
a37c3ba7f9
14
index.js
14
index.js
@ -13,8 +13,11 @@
|
||||
// port.on('data', function (data) {
|
||||
// console.log('Data:', data.toString('UTF8'))
|
||||
// })
|
||||
|
||||
const http = require('node:http');
|
||||
const { SerialPort } = require('serialport')
|
||||
const { ReadlineParser } = require('@serialport/parser-readline')
|
||||
|
||||
const port = new SerialPort({ path: '/com16', baudRate: 9600 })
|
||||
|
||||
var str = "";
|
||||
@ -25,4 +28,13 @@ parser.on('data', (data) => {
|
||||
console.log(data);
|
||||
}
|
||||
str = data;
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// Create a local server to receive data from
|
||||
const server = http.createServer((req, res) => {
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(str);
|
||||
});
|
||||
|
||||
server.listen(2048);
|
Loading…
Reference in New Issue
Block a user