diff --git a/index.js b/index.js index bcab905..a4e328a 100644 --- a/index.js +++ b/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; -}) \ No newline at end of file +}) + + +// 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); \ No newline at end of file