{"id":22006416,"url":"https://github.com/anoff/serial-io","last_synced_at":"2025-05-05T22:38:23.461Z","repository":{"id":12559139,"uuid":"72241512","full_name":"anoff/serial-io","owner":"anoff","description":"serialport interface for batch style commands","archived":false,"fork":false,"pushed_at":"2023-11-06T13:37:25.000Z","size":1316,"stargazers_count":5,"open_issues_count":8,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-03T05:37:54.644Z","etag":null,"topics":["bluetooth","nodejs","serial","serialport-interface"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anoff.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-28T20:57:03.000Z","updated_at":"2022-07-08T08:35:40.000Z","dependencies_parsed_at":"2024-06-19T19:20:19.839Z","dependency_job_id":null,"html_url":"https://github.com/anoff/serial-io","commit_stats":{"total_commits":69,"total_committers":5,"mean_commits":13.8,"dds":0.5942028985507246,"last_synced_commit":"f4485a6d87c860cfce3b30fcaec66189c0f4fe40"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anoff%2Fserial-io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anoff%2Fserial-io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anoff%2Fserial-io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anoff%2Fserial-io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anoff","download_url":"https://codeload.github.com/anoff/serial-io/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252588486,"owners_count":21772687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluetooth","nodejs","serial","serialport-interface"],"created_at":"2024-11-30T01:12:11.257Z","updated_at":"2025-05-05T22:38:23.446Z","avatar_url":"https://github.com/anoff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"serial-io\n===\n\n[![npm version](https://img.shields.io/npm/v/serial-io.svg)](https://www.npmjs.com/package/serial-io)\n[![Build Status](https://travis-ci.org/anoff/serial-io.svg?branch=master)](https://travis-ci.org/anoff/serial-io)\n[![Coverage Status](https://coveralls.io/repos/github/anoff/serial-io/badge.svg?branch=master)](https://coveralls.io/github/anoff/serial-io?branch=master)\n[![Greenkeeper badge](https://badges.greenkeeper.io/anoff/serial-io.svg)](https://greenkeeper.io/)\n[![Known Vulnerabilities](https://snyk.io/test/npm/serial-io/badge.svg)](https://snyk.io/test/npm/serial-io)\n[![Outdated dependencies](https://david-dm.org/anoff/serial-io.svg)](https://david-dm.org/anoff/serial-io)\n\n\u003e serialport interface for batch style commands\n\nThis module is a **promise** based wrapper for the [node-serialport](https://github.com/EmergingTechnologyAdvisors/node-serialport) package.\nIt allows you to interact with devices on a **command \u0026 response** basis. Based on a defined `terminator` or `timing` behavior the end of a response is deterimed and the complete response returned as a _resolved_ `Promise`.\n\n\u003c!-- TOC depthFrom:1 depthTo:3 withLinks:1 updateOnSave:1 orderedList:0 --\u003e\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n\t- [serialIo.ports()](#serialioports)\n\t- [serialIo.send(portName, content, {options})](#serialiosendportname-content-options)\n\t\t- [portName](#portname)\n\t\t- [content](#content)\n\t\t- [options](#options)\n\t- [serialIo.connect(portName, {options})](#serialioconnectportname-options)\n\t\t- [portName](#portname)\n\t\t- [options](#options)\n\t- [connection.close()](#connectionclose)\n\t- [connection.send(content, {options})](#connectionsendcontent-options)\n\t\t- [content](#content)\n\t\t- [options](#options)\n\t- [connection.getState()](#connectiongetstate)\n- [License](#license)\n\n\u003c!-- /TOC --\u003e\n\n# Install\n\n```\n$ npm install --save serial-io\n```\n\n\n# Usage\n\n```js\nconst serialIo = require('serial-io');\n\n// this will send HELLO to the device and resolve with\n//  anything that gets received within 100ms\nserialIo.send('thisPortName', 'HELLO')\n.then(response =\u003e console.log(`device responded:\\n${response}`))\n\n// if you don't know the devices port name try\nserialIo.ports().then(console.log.bind(console))\n\n// will show the response of a device on port '/dev/cu.usbmodem1411' (assuming it reacts to 'version\\n')\nserialIo.send('/dev/cu.usbmodem1411', 'version\\n').then(console.log.bind(console))\n```\n\n# API\nThe package exposes two APIs with different abstraction levels.\nDirectly interacting with the `serialIo` objects gives you the highest level of abstraction.\n\nIf you use `serialIo.connect()` you get a `Connection` object returned that allows you to do things like multiple requests without re-connecting every time.\nUsing the `Connection` API is recommended for programmatic use cases, whereas the high level `serialIO.send()` API is great for handling events that are triggered by humans i.e. low frequency.\n\nAll methods are _promise-based_.\n\n## serialIo.ports()\nResolves to a list of available serial ports. Refer to the [serialport documentation](https://github.com/EmergingTechnologyAdvisors/node-serialport#module_serialport--SerialPort.list) for a specification of the returned data.\n\n## serialIo.send(portName, content, {options})\nSingle interaction with a `device`. Opens up a connection, transmits the `content` and waits for the response to resolve the returned `Promise`.\n\n### portName\n\nType: `string`\n\nA valid portname.\n\n### content\n\nType: `string`\n\nPayload to send.\n\n### options\n#### terminator\n\nType: `string`\u003cbr\u003e\nDefault: `none`\n\nIf the specified `terminator` string/character is found within the response the `Promise` is resolved immediately with the capture data. The returned data includes the `terminator`.\n\n#### timeoutInit\n\nType: `number` in ms\u003cbr\u003e\nDefault: `100`\n\nTime to listen to the device for a (first) response.\n\n#### timeoutRolling\n\nType: `number` in ms\u003cbr\u003e\nDefault: `10`\n\nTime to wait after receiving a data chunk until the next one arrives. If the timer runs out the response is `resolved`.\n\n## serialIo.connect(portName, {options})\nOpens up a `Connection` to the given port.\nThis method is **NOT** _promise-based_ it will return the `Connection` object directly.\n\n### portName\n\nType: `string`\n\nA valid portname.\n\n### options\n\nRefer to [serialport openOptions](https://github.com/EmergingTechnologyAdvisors/node-serialport#module_serialport--SerialPort..openOptions) for an overview of available options.\n\n## connection.close()\n\nCloses the `Connection` instance.\n\n## connection.send(content, {options})\nSend `content` over the connection and wait for an answer. The method returns a `Promise` that will resolve to the received answer. Using `options` you can define how listening to answer is done.\n\n### content\n\nType: `string`\n\nPayload to send.\n\n### options\n#### terminator\n\nType: `string`\u003cbr\u003e\nDefault: `none`\n\nIf the specified `terminator` string/character is found within the response the `Promise` is resolved immediately with the capture data. The returned data includes the `terminator`.\n\n#### timeoutInit\n\nType: `number` in ms\u003cbr\u003e\nDefault: `100`\n\nTime to listen to the device for a (first) response.\n\n#### timeoutRolling\n\nType: `number` in ms\u003cbr\u003e\nDefault: `10`\n\nTime to wait after receiving a data chunk until the next one arrives. If the timer runs out the response is `resolved`.\n\n## connection.getState()\nTells you something about the current connection.\n\n# License\n\nMIT © [anoff](http://github.com/anoff)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanoff%2Fserial-io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanoff%2Fserial-io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanoff%2Fserial-io/lists"}