{"_id":"@bulletlogic/socket.io-serialport","_rev":"1-6ef9d7cde5b0d092e7d94e9645cf8a34","name":"@bulletlogic/socket.io-serialport","dist-tags":{"latest":"2.1.0"},"versions":{"2.1.0":{"name":"@bulletlogic/socket.io-serialport","version":"2.1.0","description":"Expose a serial port over a socket.io instance","main":"index.js","repository":{"type":"git","url":"git+https://github.com/bulletlogic/socket.io-serialport.git"},"keywords":["websocket","socket.io","serialport"],"author":{"name":"Peter Halliday","email":"pghalliday@gmail.com","url":"http://pghalliday.com"},"license":"ISC","bugs":{"url":"https://github.com/bulletlogic/socket.io-serialport/issues"},"homepage":"https://github.com/bulletlogic/socket.io-serialport#readme","dependencies":{"mkdirp":"^1.0.4","socket.io-stream":"^0.9.1"},"peerDependencies":{"serialport":"9.x"},"devDependencies":{"socket.io":"^4.1.3"},"gitHead":"b2432dad7289aa966a32a5f93d0f918b93cbcd4b","_id":"@bulletlogic/socket.io-serialport@2.1.0","_nodeVersion":"14.16.1","_npmVersion":"7.8.0","dist":{"integrity":"sha512-CBAtrz7n9AohbIBEVwMIFvQcbr3phZQcSY2m+Oo4T/cgEg0tVPZf7Aq4WVO92yquMJ0OmlZT6m4XCJsAFqj8Fg==","shasum":"5e85366e1a1c4ff0b6fd2b32a39969b67b77f5f2","tarball":"https://registry.npmjs.org/@bulletlogic/socket.io-serialport/-/socket.io-serialport-2.1.0.tgz","fileCount":4,"unpackedSize":7536,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhHGB1CRA9TVsSAnZWagAA3KsP/2aU3TNJbUp3W2q86jWA\nekik8nlww0Ehmqu64OEUhUCjXzOp8TmWFpIPfotmhxl/t/Kw0V4gmz+fYFFm\nMACw5q2nSk2ilnCt1iTHbTwA0AQOsx0q8MPeiHF7nfHwTJX4n55v/KZFVNMn\nx3sWrblfLP8JsrhZ7A0NBR8Vfyjkhip+NrlBtIf8SCpo2HrNZ8h71unBEPv8\nYwAF6a/Mj6k2/bk1rwLyMeXBYYigr7KrOoAbbA1DDKXP99dQGbF7NzM/xYJs\nsEfw5V8K3I8+agyG6H/JYD+UEJTGrS5VOFVyp33lSmZT6VJkqovQXvpmg8gS\naDUwet5aFp2nhG12BSQSefP/HgJ6nmkT+9n++8FGbixBsAK8cH/qygFHgGrD\nrhmZcoYtBMfvme4BedFYstbkyRZ8M2aF0zb1c+T55a3KIwE/ait6C1+npJTX\nB5BglRHJhdZBH2ubfMR1xwXhI07DVOzU6Qlzm8X6epS68wsHOklamqC4OoV3\nFJG6y0V7qB4uYXsZgdam85o9oWRuyZ+IRuFpn4NZ/6dHePoNSxG1QdVXNVMx\nhAwSt1VP6FKKUzFTe/lNvpUho+GVB82CWq0/2ME26PYHcj7jyREt53WTRk0S\nYbFNoveD4ih1f0im2mU0gmxVM++41E8IcfxGFF01tlSc2DneCVfmE41dMmK8\nbXSO\r\n=yMsM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAKHvzwRh7/ZPW1uXb/NgeB3cqM5v+ToRtVGFvK16U50AiAvc4ChuZBCggz5xUmAVFU1nHCfLSx9hivFdOJcKm40wg=="}]},"_npmUser":{"name":"ayan4m1","email":"andrew@bulletlogic.com"},"directories":{},"maintainers":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/socket.io-serialport_2.1.0_1629249653756_0.9497843595294702"},"_hasShrinkwrap":false}},"time":{"created":"2021-08-18T01:20:53.682Z","2.1.0":"2021-08-18T01:20:53.916Z","modified":"2022-04-04T21:04:35.951Z"},"maintainers":[{"name":"ayan4m1","email":"andrew@bulletlogic.com"}],"description":"Expose a serial port over a socket.io instance","homepage":"https://github.com/bulletlogic/socket.io-serialport#readme","keywords":["websocket","socket.io","serialport"],"repository":{"type":"git","url":"git+https://github.com/bulletlogic/socket.io-serialport.git"},"author":{"name":"Peter Halliday","email":"pghalliday@gmail.com","url":"http://pghalliday.com"},"bugs":{"url":"https://github.com/bulletlogic/socket.io-serialport/issues"},"license":"ISC","readme":"# socket.io-serialport\n\nExpose a serial port over a socket.io instance. Particular thanks go to the [serialport](https://github.com/EmergingTechnologyAdvisors/node-serialport), [socket.io-stream](https://github.com/nkzawa/socket.io-stream) and [hterm](https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm) projects.\n\n## Usage\n\n```\nnpm install --save socket.io\nnpm install --save socket.io-serialport\n```\n\nThen to connect to a serial port and open it (note that the `options` field is passed directly to the `serialport` instance, however the `autoOpen` option will always be forced to false)\n\n```javascript\nconst Server = require('socket.io');\nconst SerialPort = require('socket.io-serialport');\n\nconst io = new Server(8080);\n\nconst serialport = new SerialPort({\n  io: io,\n  route: '/port/ttyS0',\n  captureFile: '/var/log/serialport/ttyS0',\n  retryPeriod: 1000,\n  device: '/dev/ttyS0',\n  options: {\n    baudrate: 115200\n  }\n});\n\nserialport.open()\n.then(() => {\n  console.log('port opened');\n\n  // And when done (shutting down, etc)\n  serialport.close()\n  .then(() => {\n    console.log('port closed');\n  });\n});\n```\n\nThen connect `socket.io` clients to the following endpoint\n\n```javascript\nvar io = require('socket.io-client');\n\nvar ttyS0 = io('http://localhost:8080/port/ttyS0');\n```\n\nwith the `socket.io` instance you can just use `data` events\n\n```javascript\n// listen for data from the serial port\nttyS0.on('data', function(data) {\n  console.log(data);\n});\n\n// Send some data to the serial port\nttyS0.emit('data', 'pwd\\n');\n```\n\nOr connect `socket.io-stream` clients to use streams\n\n```javascript\n// Create a duplex stream\nvar ttyS0Stream = ss.createStream();\n\n// listen for data from the serial port\nttyS0Stream.on('data', function(data) {\n  console.log(data);\n});\n\n// Notify the server with a `stream` event to setup\n// a duplex stream at the other end which will\n// pipe to and from the serial port\nss(ttyS0).emit('stream', ttyS0Stream);\n\n// Send some data to the serial port\nttyS0Stream.write('pwd\\n');\n```\n\nor both :)\n\n### Handling serial port disconnects, etc\n\nEvents will be emitted when the state of the remote serial port changes. You can use these events to notify a user, etc.\n\nAlso on initial connection of the socket an event should be received giving the current status of the port.\n\n```\nttyS0.on('status', function(status) {\n  console.log(status);\n});\n```\n\nwhere `status` will be one of\n\n- `{status: 'open'}` - the port is open\n- `{status: 'closing'}` - the port is closing after calling `#close`\n- `{status: 'closed'}` - the port is closed after calling `#close`\n- `{status: 'disconnected', error: error}` - the port disconnected and should be reopened after the `retryPeriod`\n- `{status: 'opening', error: error}` - the port is opening, the `error` field will be set if it is reopening after an error\n","readmeFilename":"README.md"}