{"id":34207557,"url":"https://github.com/simonvetter/modbus","last_synced_at":"2026-04-08T15:31:00.221Z","repository":{"id":50737137,"uuid":"196266261","full_name":"simonvetter/modbus","owner":"simonvetter","description":"Go modbus stack (client and server)","archived":false,"fork":false,"pushed_at":"2025-12-05T10:40:02.000Z","size":93,"stargazers_count":402,"open_issues_count":20,"forks_count":126,"subscribers_count":15,"default_branch":"master","last_synced_at":"2026-02-02T07:35:44.898Z","etag":null,"topics":["client","go","golang","modbus","modbus-rtu","modbus-security","modbus-tcp","server"],"latest_commit_sha":null,"homepage":"","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/simonvetter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2019-07-10T19:49:14.000Z","updated_at":"2026-02-01T02:40:25.000Z","dependencies_parsed_at":"2024-06-18T13:52:53.323Z","dependency_job_id":"8d6a0a8f-45ce-42bc-9eaa-7a225c26ba61","html_url":"https://github.com/simonvetter/modbus","commit_stats":{"total_commits":39,"total_committers":2,"mean_commits":19.5,"dds":0.02564102564102566,"last_synced_commit":"4b0c5defc4ebb0ecf197003cc73260672fafc4d9"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/simonvetter/modbus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonvetter%2Fmodbus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonvetter%2Fmodbus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonvetter%2Fmodbus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonvetter%2Fmodbus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonvetter","download_url":"https://codeload.github.com/simonvetter/modbus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonvetter%2Fmodbus/sbom","scorecard":{"id":825133,"data":{"date":"2025-08-18","repo":{"name":"github.com/simonvetter/modbus","commit":"e3c15711a0b19df240123fb281329847121b7ea9"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":3.5,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T16:28:47.144Z","repository_id":50737137,"created_at":"2025-08-23T16:28:47.144Z","updated_at":"2025-08-23T16:28:47.144Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31562684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["client","go","golang","modbus","modbus-rtu","modbus-security","modbus-tcp","server"],"created_at":"2025-12-15T20:03:45.736Z","updated_at":"2026-04-08T15:31:00.213Z","avatar_url":"https://github.com/simonvetter.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"## Go modbus stack\n\n### Description\nThis package is a go implementation of the modbus protocol.\nIt aims to provide a simple-to-use, high-level API to interact with modbus\ndevices using native Go types.\n\nBoth client and server components are available.\n\nThe client supports the following modes:\n- modbus RTU (serial, over both RS-232 and RS-485),\n- modbus TCP (a.k.a. MBAP),\n- modbus TCP over TLS (a.k.a. MBAPS or Modbus Security),\n- modbus TCP over UDP (a.k.a. MBAP over UDP),\n- modbus RTU over TCP (RTU tunneled in TCP for use with e.g. remote serial\n  ports or cheap TCP to serial bridges),\n- modbus RTU over UDP (RTU tunneled in UDP).\n\nPlease note that UDP transports are not part of the Modbus specification.\nSome devices expect MBAP (modbus TCP) framing in UDP packets while others\nuse RTU frames instead. The client support both so if unsure, try with\nboth udp:// and rtuoverudp:// schemes.\n\nThe server supports:\n- modbus TCP (a.k.a. MBAP),\n- modbus TCP over TLS (a.k.a. MBAPS or Modbus Security).\n\nA CLI client is available in cmd/modbus-cli.go and can be built with\n```bash\n$ go build -o modbus-cli cmd/modbus-cli.go\n$ ./modbus-cli --help\n```\n\n### Getting started\n```bash\n$ go get github.com/simonvetter/modbus\n```\n\n### Using the client\n\n```golang\nimport (\n    \"github.com/simonvetter/modbus\"\n)\n\nfunc main() {\n    var client  *modbus.ModbusClient\n    var err      error\n\n    // for a TCP endpoint\n    // (see examples/tls_client.go for TLS usage and options)\n    client, err = modbus.NewClient(\u0026modbus.ClientConfiguration{\n        URL:      \"tcp://hostname-or-ip-address:502\",\n        Timeout:  1 * time.Second,\n    })\n    // note: use udp:// for modbus TCP over UDP\n\n    // for an RTU (serial) device/bus\n    client, err = modbus.NewClient(\u0026modbus.ClientConfiguration{\n        URL:      \"rtu:///dev/ttyUSB0\",\n        Speed:    19200,                   // default\n        DataBits: 8,                       // default, optional\n        Parity:   modbus.PARITY_NONE,      // default, optional\n        StopBits: 2,                       // default if no parity, optional\n        Timeout:  300 * time.Millisecond,\n    })\n\n    // for an RTU over TCP device/bus (remote serial port or\n    // simple TCP-to-serial bridge)\n    client, err = modbus.NewClient(\u0026modbus.ClientConfiguration{\n        URL:      \"rtuovertcp://hostname-or-ip-address:502\",\n        Speed:    19200,                   // serial link speed\n        Timeout:  1 * time.Second,\n    })\n    // note: use rtuoverudp:// for modbus RTU over UDP\n\n    if err != nil {\n        // error out if client creation failed\n    }\n\n    // now that the client is created and configured, attempt to connect\n    err = client.Open()\n    if err != nil {\n        // error out if we failed to connect/open the device\n        // note: multiple Open() attempts can be made on the same client until\n        // the connection succeeds (i.e. err == nil), calling the constructor again\n        // is unnecessary.\n        // likewise, a client can be opened and closed as many times as needed.\n    }\n\n    // read a single 16-bit holding register at address 100\n    var reg16   uint16\n    reg16, err  = client.ReadRegister(100, modbus.HOLDING_REGISTER)\n    if err != nil {\n      // error out\n    } else {\n      // use value\n      fmt.Printf(\"value: %v\", reg16)        // as unsigned integer\n      fmt.Printf(\"value: %v\", int16(reg16)) // as signed integer\n    }\n\n    // read 4 consecutive 16-bit input registers starting at address 100\n    var reg16s  []uint16\n    reg16s, err = client.ReadRegisters(100, 4, modbus.INPUT_REGISTER)\n\n    // read the same 4 consecutive 16-bit input registers as 2 32-bit integers\n    var reg32s  []uint32\n    reg32s, err = client.ReadUint32s(100, 2, modbus.INPUT_REGISTER)\n\n    // read the same 4 consecutive 16-bit registers as a single 64-bit integer\n    var reg64   uint64\n    reg64, err  = client.ReadUint64(100, modbus.INPUT_REGISTER)\n\n    // read the same 4 consecutive 16-bit registers as a slice of bytes\n    var regBs   []byte\n    regBs, err  = client.ReadBytes(100, 8, modbus.INPUT_REGISTER)\n\n    // by default, 16-bit integers are decoded as big-endian and 32/64-bit values as\n    // big-endian with the high word first.\n    // change the byte/word ordering of subsequent requests to little endian, with\n    // the low word first (note that the second argument only affects 32/64-bit values)\n    client.SetEncoding(modbus.LITTLE_ENDIAN, modbus.LOW_WORD_FIRST)\n\n    // read the same 4 consecutive 16-bit input registers as 2 32-bit floats\n    var fl32s   []float32\n    fl32s, err  = client.ReadFloat32s(100, 2, modbus.INPUT_REGISTER)\n\n    // write -200 to 16-bit (holding) register 100, as a signed integer\n    var s int16 = -200\n    err         = client.WriteRegister(100, uint16(s))\n\n    // Switch to unit ID (a.k.a. slave ID) #4\n    client.SetUnitId(4)\n\n    // write 3 floats to registers 100 to 105\n    err         = client.WriteFloat32s(100, []float32{\n        3.14,\n        1.1,\n        -783.22,\n    })\n\n    // write 0x0102030405060708 to 16-bit (holding) registers 10 through 13\n    // (8 bytes i.e. 4 consecutive modbus registers)\n    err         = client.WriteBytes(10, []byte{\n        0x01, 0x02, 0x03, 0x04,\n        0x05, 0x06, 0x07, 0x08,\n    })\n\n    // close the TCP connection/serial port\n    client.Close()\n}\n```\n### Using the server component\nSee:\n* [examples/tcp_server.go](examples/tcp_server.go) for a modbus TCP example\n* [examples/tls_server.go](examples/tls_server.go) for TLS and Modbus Security features\n\n### Supported function codes, golang object types and endianness/word ordering\nFunction codes:\n* Read coils (0x01)\n* Read discrete inputs (0x02)\n* Read holding registers (0x03)\n* Read input registers (0x04)\n* Write single coil (0x05)\n* Write single register (0x06)\n* Write multiple coils (0x0f)\n* Write multiple registers (0x10)\n\nGo object types:\n* Booleans (coils and discrete inputs)\n* Bytes (input and holding registers)\n* Signed/Unisgned 16-bit integers (input and holding registers)\n* Signed/Unsigned 32-bit integers (input and holding registers)\n* 32-bit floating point numbers (input and holding registers)\n* Signed/Unsigned 64-bit integers (input and holding registers)\n* 64-bit floating point numbers (input and holding registers)\n\nByte encoding/endianness/word ordering:\n* Little and Big endian for byte slices and 16-bit integers\n* Little and Big endian, with and without word swap for 32 and 64-bit\n  integers and floating point numbers.\n\n### Logging ###\nBoth client and server objects will log to stdout by default.\nThis behavior can be overriden by passing a log.Logger object\nthrough the Logger property of ClientConfiguration/ServerConfiguration.\n\n### TODO (in no particular order)\n* Add RTU (serial) support to the server\n* Add more tests\n* Add diagnostics register support\n* Add fifo register support\n* Add file register support\n\n### Dependencies\n* [github.com/goburrow/serial](https://github.com/goburrow/serial) for access to the serial port (thanks!)\n\n### License\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonvetter%2Fmodbus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonvetter%2Fmodbus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonvetter%2Fmodbus/lists"}