{"id":30722660,"url":"https://github.com/offerrall/pygrbl_streamer","last_synced_at":"2025-10-11T11:34:11.252Z","repository":{"id":311216945,"uuid":"1041965732","full_name":"offerrall/PyGrbl_Streamer","owner":"offerrall","description":"A simple and minimalist library for controlling CNC machines with GRBL firmware from Python. (250 lines of code)","archived":false,"fork":false,"pushed_at":"2025-08-22T19:56:33.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-22T21:56:50.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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/offerrall.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,"zenodo":null}},"created_at":"2025-08-21T09:25:34.000Z","updated_at":"2025-08-22T19:56:37.000Z","dependencies_parsed_at":"2025-08-22T22:08:20.419Z","dependency_job_id":null,"html_url":"https://github.com/offerrall/PyGrbl_Streamer","commit_stats":null,"previous_names":["offerrall/pygrbl_streamer"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/offerrall/PyGrbl_Streamer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FPyGrbl_Streamer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FPyGrbl_Streamer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FPyGrbl_Streamer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FPyGrbl_Streamer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/offerrall","download_url":"https://codeload.github.com/offerrall/PyGrbl_Streamer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/offerrall%2FPyGrbl_Streamer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273431490,"owners_count":25104512,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-09-03T11:10:13.046Z","updated_at":"2025-10-11T11:34:06.216Z","avatar_url":"https://github.com/offerrall.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pygrbl_streamer\n\nA simple and minimalist library for controlling CNC machines with GRBL firmware from Python. (250 lines of code)\n\n## Features\n\n- **Simple**: Just inherit the class and override the callbacks you need\n- **Non-blocking**: Callbacks execute in separate threads without affecting laser control\n- **Safe**: Intelligent GRBL buffer management and automatic alarm recovery\n- **Efficient**: Low CPU and memory consumption\n- **Flexible**: Callbacks for progress, alarms, and errors\n\n## Installation\n\n```bash\ngit clone https://github.com/offerrall/pygrbl_streamer.git\ncd pygrbl_streamer\npip install .\n```\n\n## Basic Usage\n\n### Simple example\n```python\nfrom pygrbl_streamer import GrblStreamer\n\n# Direct usage\nstreamer = GrblStreamer('/dev/ttyUSB0')  # Or 'COM3' on Windows\nstreamer.open()\nstreamer.send_file('my_file.gcode') # or 'my_file.nc'\nstreamer.close()\n```\n\n### With custom callbacks\n```python\nfrom pygrbl_streamer import GrblStreamer\n\nclass MyStreamer(GrblStreamer):\n    \n    def progress_callback(self, percent: int, command: str):\n        print(f\"Progress: {percent}% - {command}\")\n    \n    def alarm_callback(self, line: str):\n        print(f\"ALARM: {line}\")\n    \n    def error_callback(self, line: str):\n        print(f\"ERROR: {line}\")\n\nstreamer = MyStreamer('/dev/ttyUSB0')\nstreamer.open()\nstreamer.send_file('project.gcode')\nstreamer.close()\n```\n\n## API Reference\n\n### Constructor\n```python\nGrblStreamer(port='/dev/Laser4', baudrate=115200)\n```\n\n### Main methods\n- `open()` - Opens serial connection and initializes GRBL\n- `send_file(filename)` - Sends a G-code file to the machine\n- `close()` - Closes connection and cleans up resources\n- `write_line(text)` - Sends an individual command to GRBL\n- `read_line_blocking()` - Reads a response from GRBL (5s timeout)\n\n### Callbacks (override as needed)\n\n#### `progress_callback(percent: int, command: str)`\nExecuted every 10 commands during file sending.\n- `percent`: Completion percentage (0-100)\n- `command`: Last command sent\n\n#### `alarm_callback(line: str)`\nExecuted when GRBL reports an alarm.\n- `line`: Complete alarm line from GRBL\n\n#### `error_callback(line: str)`\nExecuted when GRBL reports an error.\n- `line`: Complete error line from GRBL\n\n## Technical Features\n\n- **Intelligent buffer management**: Respects GRBL's 127-byte limit\n- **Automatic recovery**: Auto-recovery from alarms with `$X`\n- **Non-blocking threads**: Callbacks execute in separate threads\n- **Fault tolerant**: Callback errors do not affect machine control\n- **Automatic cleanup**: Daemon threads close automatically\n\n## Slow callbacks\nCallbacks execute in separate threads, but if they are very slow they may accumulate events in the queue. The queue has a limit of 100 events and automatically discards if it fills up.\n\n## Contributing\n\nFound a bug or want to add a feature? Pull requests welcome!\n\n## License\n\nMIT License - use the library freely in commercial and personal projects.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofferrall%2Fpygrbl_streamer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fofferrall%2Fpygrbl_streamer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofferrall%2Fpygrbl_streamer/lists"}