{"id":15290497,"url":"https://github.com/cncjs/cncjs-controller","last_synced_at":"2025-10-15T04:05:42.727Z","repository":{"id":57201700,"uuid":"103044059","full_name":"cncjs/cncjs-controller","owner":"cncjs","description":"A controller library for event-based communication between client and CNCjs server.","archived":false,"fork":false,"pushed_at":"2024-11-22T14:52:52.000Z","size":113,"stargazers_count":9,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T01:40:27.930Z","etag":null,"topics":["client","cncjs","controller","events","socket-io"],"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/cncjs.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}},"created_at":"2017-09-10T16:25:13.000Z","updated_at":"2024-11-22T14:49:41.000Z","dependencies_parsed_at":"2022-09-17T06:31:11.579Z","dependency_job_id":null,"html_url":"https://github.com/cncjs/cncjs-controller","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cncjs%2Fcncjs-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cncjs%2Fcncjs-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cncjs%2Fcncjs-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cncjs%2Fcncjs-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cncjs","download_url":"https://codeload.github.com/cncjs/cncjs-controller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695481,"owners_count":21146956,"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":["client","cncjs","controller","events","socket-io"],"created_at":"2024-09-30T16:08:23.810Z","updated_at":"2025-10-15T04:05:37.697Z","avatar_url":"https://github.com/cncjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cncjs-controller [![codecov](https://codecov.io/gh/cncjs/cncjs-controller/graph/badge.svg?token=MNXPXFY33Z)](https://codecov.io/gh/cncjs/cncjs-controller)\n\n[![NPM](https://nodei.co/npm/cncjs-controller.png?downloads=true\u0026stars=true)](https://www.npmjs.com/package/cncjs-controller)\n\n**A controller library for event-based communication between client and CNCjs server**\n \n## Installation\n\n```sh\nnpm install --save cncjs-controller@1.x\nnpm install --save socket.io-client\n```\n\n## Usage\n\n```js\nimport io from 'socket.io-client';\nimport Controller from 'cncjs-controller';\n\nconst controller = new Controller(io);\nconst host = ''; // e.g. http://127.0.0.1:8000\nconst token = '\u003csecurity-token\u003e';\nconst options = {\n    query: 'token=' + token\n};\n\ncontroller.connect(host, options, () =\u003e {\n    const port = '/dev/cu.wchusbserialfa130';\n\n    controller.openPort(port, {\n        controllerType: 'Grbl', // Grbl|Smoothie|TinyG\n        baudrate: 115200\n    }, (err) =\u003e {\n        if (err) {\n            console.error(err);\n            return;\n        }\n\n        controller.writeln('$$'); // View Grbl Settings\n    });\n\n    // Disconnect after 60 seconds\n    setTimeout(() =\u003e {\n        // Close port\n        controller.closePort();\n\n        // Close connection\n        controller.disconnect();\n    }, 60 * 1000);\n});\n\ncontroller.addListener('serialport:open', (options) =\u003e {\n    const {\n        port,\n        baudrate,\n        controllerType\n    } = options;\n    console.log(`Connected to the port \"${port}\" with a baud rate of ${baudrate}.`, { port, baudrate });\n});\n\ncontroller.addListener('serialport:close', (options) =\u003e {\n    const { port } = options;\n    console.log(`The port \"${port}\" is disconnected.`);\n});\n\ncontroller.addListener('serialport:write', (data, context) =\u003e {\n    console.log('\u003e', data);\n});\n\ncontroller.addListener('serialport:read', (data) =\u003e {\n    console.log('\u003c', data);\n});\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcncjs%2Fcncjs-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcncjs%2Fcncjs-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcncjs%2Fcncjs-controller/lists"}