{"id":20280007,"url":"https://github.com/yesbotics/simple-serial-protocol-go","last_synced_at":"2025-07-07T13:34:05.661Z","repository":{"id":240422163,"uuid":"779214685","full_name":"yesbotics/simple-serial-protocol-go","owner":"yesbotics","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-14T23:03:40.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-14T07:13:55.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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":"2024-03-29T09:54:57.000Z","updated_at":"2024-10-14T18:35:52.000Z","dependencies_parsed_at":"2024-05-20T23:35:19.555Z","dependency_job_id":null,"html_url":"https://github.com/yesbotics/simple-serial-protocol-go","commit_stats":null,"previous_names":["yesbotics/simple-serial-protocol-go"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yesbotics%2Fsimple-serial-protocol-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yesbotics","download_url":"https://codeload.github.com/yesbotics/simple-serial-protocol-go/tar.gz/refs/heads/main","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.022Z","updated_at":"2025-03-04T02:42:06.165Z","avatar_url":"https://github.com/yesbotics.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Serial Protocol for Go\n\nEasy and robust General Purpose Library for the communication between Go applications and Arduino devices.\nPowered by the usage of resource-efficient and microcontroller-friendly Primitive Dataypes.\nThis package covers the Go implementation of [Simple Serial Protocol]. See the [Simple Serial Protocol for Arduino] \nfor further informations about the usage of the protocol for Arduino used in the example.\n\n## Requirements\n\n- go \u003e= 1.22\n\n## Install\n\n```clonsole\ngo get -u github.com/yesbotics/simple-serial-protocol-go \n```\n\n## Usage example\n\nThis example sends values of each supported datatype and listen for them sent back. This example can be found \nas go application in the simple-serial-protocol-go/examples/echo-example folder. It corresponds with the \nArduino sketch at Simple Serial Protocol for Arduino. \n\n```go\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"github.com/yesbotics/simple-serial-protocol-go/pkg/config\"\n\t\"github.com/yesbotics/simple-serial-protocol-go/pkg/simple_serial_protocol\"\n\t\"os\"\n\t\"time\"\n)\n\nfunc main() {\n\n\t// Press ENTER key to exit\n\tstopChan := make(chan struct{})\n\tgo func() {\n\t\t_, err := bufio.NewReader(os.Stdin).ReadBytes('\\n')\n\t\tif err != nil {\n\n\t\t}\n\t\tstopChan \u003c- struct{}{}\n\t}()\n\n\tfmt.Println(\"Starting echo example.\")\n\n\t// Change this to your partner device's baudrate\n\tportname := \"/dev/ttyUSB0\"\n\n\t// Change this to your serial port name\n\tbaudrate := 9600\n\n\tfmt.Printf(\"Use portname: %s\\n\", portname)\n\tfmt.Printf(\"Use baudrate: %d\\n\", baudrate)\n\n\tarduino := simple_serial_protocol.NewSsp(portname, baudrate)\n\n\tfmt.Printf(\"Registering command.\\n\")\n\n\treadConfig := config.NewReadCommandConfig(byte('s'), onRead)\n\treadConfig.AddParam(config.ParamTypeByte)\n\treadConfig.AddParam(config.ParamTypeBool)\n\treadConfig.AddParam(config.ParamTypeInt8)\n\treadConfig.AddParam(config.ParamTypeUint8)\n\treadConfig.AddParam(config.ParamTypeInt16)\n\treadConfig.AddParam(config.ParamTypeUint16)\n\treadConfig.AddParam(config.ParamTypeInt32)\n\treadConfig.AddParam(config.ParamTypeUint32)\n\treadConfig.AddParam(config.ParamTypeInt64)\n\treadConfig.AddParam(config.ParamTypeUint64)\n\treadConfig.AddParam(config.ParamTypeFloat32)\n\treadConfig.AddParam(config.ParamTypeChar)\n\treadConfig.AddParam(config.ParamTypeString)\n\treadConfig.AddParam(config.ParamTypeString)\n\treadConfig.AddParam(config.ParamTypeString)\n\n\tarduino.RegisterCommand(readConfig)\n\terr := arduino.Open()\n\tif err != nil {\n\t\tfmt.Printf(\"Could not connect. Error %q\\n\", err)\n\t\treturn\n\t}\n\n\tfmt.Println(\"Connected. Listening for commands.\")\n\n\tfmt.Println(\"Give the arduino some time...\")\n\ttime.Sleep(3 * time.Second)\n\n\tfmt.Println(\"Writing command.\")\n\twrite := config.NewWriteCommandConfig(\n\t\tbyte('r'),\n\t\t[]any{\n\t\t\tbyte(0xff),\n\t\t\ttrue,\n\t\t\tint8(-128),\n\t\t\tuint8(255),\n\t\t\tint16(-32768),\n\t\t\tuint16(65535),\n\t\t\tint32(-2147483648),\n\t\t\tuint32(4294967295),\n\t\t\tint64(-9223372036854775808),\n\t\t\tuint64(18446744073709551615),\n\t\t\tfloat32(-1.2345678),\n\t\t\tbyte('J'),\n\t\t\t\"text1: Hey, I'm text one!\",\n\t\t\t\"text2: And I am his brother text two!\",\n\t\t\t\"text3: Nice!\",\n\t\t},\n\t)\n\terr = arduino.WriteCommand(write)\n\tif err != nil {\n\t\tfmt.Printf(\"Could not write command: %s\\n\", err)\n\t\treturn\n\t}\n\tfmt.Println(\"Command written.\")\n\n\tfmt.Println(\"Press ENTER to close application...\")\n\t\u003c-stopChan\n\tfmt.Println(\"Bye bye.\")\n}\n\nfunc onRead(params []any, err error) {\n\n\tif err != nil {\n\t\tfmt.Printf(\"Got an error: %s\\n\", err)\n\t\treturn\n\t}\n\n\tfmt.Printf(\"byteValue: %#x \\n\", params[0])\n\tfmt.Printf(\"booleanValue: %t \\n\", params[1])\n\tfmt.Printf(\"int8Value: %v \\n\", params[2])\n\tfmt.Printf(\"uint8Value: %d \\n\", params[3])\n\tfmt.Printf(\"int16Value: %d \\n\", params[4])\n\tfmt.Printf(\"uint16Value: %d \\n\", params[5])\n\tfmt.Printf(\"int32Value: %d \\n\", params[6])\n\tfmt.Printf(\"uint32Value: %d \\n\", params[7])\n\tfmt.Printf(\"int64Value: %d \\n\", params[8])\n\tfmt.Printf(\"uint64Value: %d \\n\", params[9])\n\tfmt.Printf(\"float32Value: %f \\n\", params[10])\n\tfmt.Printf(\"charValue: %#x / %s\\n\", params[11], string(params[11].(byte)))\n\tfmt.Printf(\"stringValue1: %s \\n\", params[12])\n\tfmt.Printf(\"stringValue2: %s \\n\", params[13])\n\tfmt.Printf(\"stringValue3: %s \\n\", params[14])\n\n\tfmt.Println(\"I have successfully received all the data from the Arduino. Press ENTER to exit.\")\n}\n``` \n\n[Simple Serial Protocol]:https://github.com/yesbotics/simple-serial-protocol-docs\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyesbotics%2Fsimple-serial-protocol-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyesbotics%2Fsimple-serial-protocol-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyesbotics%2Fsimple-serial-protocol-go/lists"}