Compare commits

..

No commits in common. 'bfc1eb879608ba41c94cb53cff179377cfa4c0c5' and 'f74d79389d2bd368770868752a6367565dbc3d5d' have entirely different histories.

  1. 5
      .idea/.gitignore
  2. 8
      .idea/modules.xml
  3. 12
      .idea/roshano_boxModule.iml
  4. 6
      .idea/vcs.xml
  5. 4
      controller/serialPort.js
  6. 25
      services/serialPortService.js

5
.idea/.gitignore vendored

@ -1,5 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/roshano_boxModule.iml" filepath="$PROJECT_DIR$/.idea/roshano_boxModule.iml" />
</modules>
</component>
</project>

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

@ -1,10 +1,8 @@
import { Router } from 'express';
import serialPort from '../services/serialPortService.js';
import serialPortList from '../services/serialPortService.js';
const router = new Router()
router.get('/open/:id', serialPort);
router.get('/list', serialPortList);
router.get('/:id', serialPort);
export default router

@ -1,23 +1,10 @@
import { SerialPort } from 'serialport'
import res from "express/lib/response.js";
import { autoDetect } from '@serialport/bindings-cpp'
async function serialPortList(req, res) {
const data = autoDetect()
console.log('data', await data.open())
// .then((ports) => {
// console.log('Available serial ports:');
// ports.forEach((port) => {
// console.log(`- ${port.comName} (${port.pnpId})`);
// });
// })
// .catch((error) => {
// console.error('Error listing serial ports:', error);
// });
}
const serialport = new SerialPort({ path: 'COM3', baudRate: 9600, autoOpen: false, }, function (err) {
if (err) {
return console.log('Error: ', err.message);
}
})
async function serialPort(req, res) {
const buff = Buffer.allocUnsafe(4);
@ -49,4 +36,4 @@ async function serialPort(req, res) {
// })
}
export default serialPortList
export default serialPort
Loading…
Cancel
Save