{"id":20280015,"url":"https://github.com/yesbotics/simple-serial-protocol-node","last_synced_at":"2025-09-04T05:37:49.193Z","repository":{"id":75142272,"uuid":"580470683","full_name":"yesbotics/simple-serial-protocol-node","owner":"yesbotics","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-11T11:01:36.000Z","size":192,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-01-14T07:13:56.881Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/yesbotics.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":"2022-12-20T16:35:03.000Z","updated_at":"2024-05-11T11:01:39.000Z","dependencies_parsed_at":"2024-05-11T11:30:03.169Z","dependency_job_id":"acbb01a1-7b0e-49f9-b024-9f9726e8ab19","html_url":"https://github.com/yesbotics/simple-serial-protocol-node","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yesbotics","download_url":"https://codeload.github.com/yesbotics/simple-serial-protocol-node/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241773256,"owners_count":20018064,"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":[],"created_at":"2024-11-14T13:34:04.801Z","updated_at":"2025-03-04T02:42:05.855Z","avatar_url":"https://github.com/yesbotics.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Serial Protocol for Node.js written in Typescript\n\nEasy and robust General Purpose Library for the communication between Node.js applications and Arduino devices.\nPowered by the usage of resource-efficient and microcontroller-friendly Primitive Dataypes.\nThis package covers the Node.js implementation of [Simple Serial Protocol].\n\n## NPM registry\nThis package is distributed as [simple-serial-protocol-node npm package].\n\n## Requirements\n* Node.js \u003e= 12.0.0 \n\n## Install\n```npm\nnpm install --save @yesbotics/simple-serial-protocol-node\n```\n \n## Usage example (echo-example written in TypeScript)\nThis example sends values of each supported datatype and listen for them sent back. \nThis example can be found as npm application in the `simple-serial-protocol-node/examples/echo-example` folder.\nIt corresponds with the Arduino sketch at [Simple Serial Protocol for Arduino].\n\n\u003c!-- embedme examples/echo-example/echo-example.ts --\u003e\n\n```ts\n/// don't remove this line!\nimport {\n    Baudrate,\n    SimpleSerialProtocol,\n    WriteCommandConfig,\n    ReadCommandConfig\n} from '@yesbotics/simple-serial-protocol-node';\n\nexport class EchoExampleApp {\n\n    public run(portname: string, baudrate: Baudrate): void {\n\n        // create instance\n        const arduino: SimpleSerialProtocol = new SimpleSerialProtocol(portname, baudrate);\n\n        // define command id and callback function\n        const readConfig: ReadCommandConfig = new ReadCommandConfig(\n            's',\n            (\n                byteValue: number,\n                booleanValue: boolean,\n                int8Value: number,\n                uint8Value: number,\n                int16Value: number,\n                uint16Value: number,\n                int32Value: number,\n                uint32Value: number,\n                int64Value: bigint,\n                uint64Value: bigint,\n                floatValue: number,\n                charValue: string,\n                stringValue1: string,\n                stringValue2: string,\n                stringValue3: string,\n            ) =\u003e {\n                console.log('Received several values from Arduino:');\n                console.log('byteValue', byteValue);\n                console.log('booleanValue', booleanValue);\n                console.log('int8Value', int8Value);\n                console.log('uint8Value', uint8Value);\n                console.log('int16Value', int16Value);\n                console.log('uint16Value', uint16Value);\n                console.log('int32Value', int32Value);\n                console.log('uint32Value', uint32Value);\n                console.log('int64Value', int64Value);\n                console.log('uint64Value', uint64Value);\n                console.log('floatValue', floatValue);\n                console.log('charValue', charValue);\n                console.log('stringValue1', stringValue1);\n                console.log('stringValue2', stringValue2);\n                console.log('stringValue3', stringValue3);\n\n                //gracefully close the connection\n                arduino.dispose().catch((err) =\u003e {\n                    console.error('Could not dispose. reason:', err);\n                });\n            }\n        );\n\n        // define expected dataytpes\n        readConfig\n            .addByteParam()\n            .addBooleanParam()\n            .addInt8Param()\n            .addUInt8Param()\n            .addInt16Param()\n            .addUInt16Param()\n            .addInt32Param()\n            .addUInt32Param()\n            .addInt64Param()\n            .addUInt64Param()\n            .addFloatParam()\n            .addCharParam()\n            .addStringParam()\n            .addStringParam()\n            .addStringParam();\n\n        // register command with prepared config\n        arduino.registerCommand(readConfig);\n\n        // establish connection to arduino and wait 2 seconds\n        // give arduino time to start after getting connected (and resetted too)\n        arduino.init(2000)\n            .catch((err) =\u003e {\n                console.error('Could not init connection. reason:', err);\n            })\n            .then(() =\u003e {\n                console.log('Arduino connected.');\n                console.log('Send several values to Arduino');\n\n                const command: WriteCommandConfig = new WriteCommandConfig('r');\n                command\n                    .addByteValue(0xff)\n                    .addBooleanValue(true)\n                    .addInt8Value(-128)\n                    .addUInt8Value(255)\n                    .addInt16Value(-32768)\n                    .addUInt16Value(65523)\n                    .addInt32Value(-2147483648)\n                    .addUInt32Value(4294967295)\n\n                    // For BigInt Support add `esnext` to your tsconfig lib section\n                    .addInt64Value(BigInt(-2147483648000999))\n                    .addUInt64Value(BigInt(7294967295000999))\n\n                    .addFloatValue(-1.23456789101112)\n                    .addCharValue('J')\n\n                    .addStringValue(\"text1: Hey, I'm text one!\")\n                    .addStringValue(\"text2: And I am his brother text two!\")\n                    .addStringValue(\"text3: Nice!\");\n\n                arduino.writeCommand(command);\n            });\n    }\n}\n\n// entry point\n\nconst MY_PORTNAME: string = 'undefinedPortname'; // change this to your serial port name\nconst MY_BAUDRATE: Baudrate = 9600; // change this to your partner device's baudrate\n\nconst usedPortname: string = (MY_PORTNAME !== 'undefinedPortname' ? MY_PORTNAME : null) || process.argv[2];\nconst usedBaudrate: Baudrate = parseInt(process.argv[3]) || MY_BAUDRATE || 9600;\n\nconsole.log('running echo example');\nconsole.log('use portname:', usedPortname);\nconsole.log('use baudrate:', usedBaudrate);\n\nconst echoExampleApp = new EchoExampleApp();\nechoExampleApp.run(usedPortname, usedBaudrate);\n\n```\n\n## Links\n[Simple Serial Protocol]:https://github.com/yesbotics/simple-serial-protocol-docs\n[simple-serial-protocol-node npm package]:https://www.npmjs.com/package/@yesbotics/simple-serial-protocol-node\n[Simple Serial Protocol for Arduino]:https://github.com/yesbotics/simple-serial-protocol-arduino\n[Arduino IDE]:https://www.arduino.cc/en/main/software\n[Arduino-CLI]:https://github.com/arduino/arduino-cli\n[IntervalCallback]:https://github.com/yesbotics/interval-callback\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyesbotics%2Fsimple-serial-protocol-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyesbotics%2Fsimple-serial-protocol-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyesbotics%2Fsimple-serial-protocol-node/lists"}