{"id":16032729,"url":"https://github.com/threez/scprotocol","last_synced_at":"2025-06-15T07:03:44.479Z","repository":{"id":4188575,"uuid":"5306482","full_name":"threez/SCProtocol","owner":"threez","description":"Arduino libary for simple command based protocols","archived":false,"fork":false,"pushed_at":"2012-08-05T20:22:30.000Z","size":88,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-15T07:03:42.908Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/threez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-05T19:53:51.000Z","updated_at":"2018-05-20T01:35:21.000Z","dependencies_parsed_at":"2022-08-25T21:12:18.566Z","dependency_job_id":null,"html_url":"https://github.com/threez/SCProtocol","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/threez/SCProtocol","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threez%2FSCProtocol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threez%2FSCProtocol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threez%2FSCProtocol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threez%2FSCProtocol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/threez","download_url":"https://codeload.github.com/threez/SCProtocol/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threez%2FSCProtocol/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259935589,"owners_count":22934384,"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-10-08T21:40:26.563Z","updated_at":"2025-06-15T07:03:44.457Z","avatar_url":"https://github.com/threez.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SCProtocol (Simple Command Protocol)\n\nThis is a simple protocol helper to send commands to the arduino. It is much less complex and has much less code than other communication protocols for the arduino. It has this limitations:\n\n* The command is allways the first byte (max. 255 commands possible)\n* The length of the command must be known in advance\n* The command data are always passed as a char array (since the length is known before it is not passed to the method again)\n\n## Installation\n\nExtract a ZIP of the library in the arduinos library folder.\n\n## Example\n\n    #include \u003cSCProtocol.h\u003e\n\n    SCProtocol scProtocol = SCProtocol();\n\n    void checkCallback(char* data) {\n      Serial.println(\"OK AwesomeApp Version: 0.0.1\");\n    }\n\n    void addTwo(char* data) {\n      short a = data[0] - '0';\n      short b = data[1] - '0'; \n      Serial.print(\"OK \");\n      Serial.println(a + b);\n    }\n\n    void setup() {\n      Serial.begin(9600);\n      scProtocol.attach('C', checkCallback, 0);\n      scProtocol.attach('+', addTwo, 2);\n    }\n\n    void loop() {\n      while(Serial.available()) scProtocol.process(Serial.read());\n    }\n    \n### Adding a method\n\nThe following method should be called by the library.\n\t\n    void checkCallback(char* data) {\n      Serial.println(\"OK AwesomeApp Version: 0.0.1\");\n    }\n\nTo attach it, we specify a command name (first byte) the callback function we defined above and the number of bytes we expect. If there are no bytes (*0*). The passed data array will be *NULL* if the command has 0 bytes data length.\n\n    scProtocol.attach('C', checkCallback, 0);\n\n\n### Result in a SerialPort session:\n\nIf the code is uploaded to the arduino, one can use the serial console to test the interface. \n\n*(Take care, there are now new lines at the end of the command)*\n\n    -\u003e \"C\"\n    \u003c- \"OK AwesomeApp Version: 0.0.1\\n\"\n    -\u003e \"+12\"\n    \u003c- \"OK 3\\n\"\n    -\u003e \"+99\"\n    \u003c- \"OK 18\\n\"\n    -\u003e \"X\"\n    \u003c- \"BAD command unknown\\n\"\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreez%2Fscprotocol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreez%2Fscprotocol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreez%2Fscprotocol/lists"}