{"id":13496049,"url":"https://github.com/serialport/serialport-rs","last_synced_at":"2025-05-13T20:22:05.120Z","repository":{"id":37494788,"uuid":"456655985","full_name":"serialport/serialport-rs","owner":"serialport","description":"A cross-platform serial port library in Rust. Provides a blocking I/O interface and port enumeration including USB device information.","archived":false,"fork":false,"pushed_at":"2025-03-26T11:29:32.000Z","size":731,"stargazers_count":578,"open_issues_count":80,"forks_count":139,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-27T07:38:22.074Z","etag":null,"topics":["rust","serial","serialport"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serialport.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2022-02-07T19:56:13.000Z","updated_at":"2025-04-24T22:56:27.000Z","dependencies_parsed_at":"2023-09-24T03:50:48.168Z","dependency_job_id":"2fb54fb4-aeae-4073-ae63-d195111906ee","html_url":"https://github.com/serialport/serialport-rs","commit_stats":{"total_commits":647,"total_committers":71,"mean_commits":9.112676056338028,"dds":"0.43740340030911906","last_synced_commit":"eca70a71144487668b5468d83fe94c2a1d894040"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serialport%2Fserialport-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serialport%2Fserialport-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serialport%2Fserialport-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serialport%2Fserialport-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serialport","download_url":"https://codeload.github.com/serialport/serialport-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251302769,"owners_count":21567601,"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":["rust","serial","serialport"],"created_at":"2024-07-31T19:01:41.532Z","updated_at":"2025-04-28T11:59:12.600Z","avatar_url":"https://github.com/serialport.png","language":"Rust","funding_links":[],"categories":["Rust","Libraries","Sensor and Communication Protocol"],"sub_categories":["Peripherals"],"readme":"[![crates.io version badge](https://img.shields.io/crates/v/serialport.svg)](https://crates.io/crates/serialport)\n[![Documentation](https://docs.rs/serialport/badge.svg)](https://docs.rs/serialport)\n[![GitHub workflow status](https://img.shields.io/github/actions/workflow/status/serialport/serialport-rs/ci.yaml?branch=main\u0026logo=github)](https://github.com/serialport/serialport-rs/actions)\n[![Minimum Stable Rust Version](https://img.shields.io/badge/Rust-1.59.0-blue?logo=rust)](https://blog.rust-lang.org/2022/02/24/Rust-1.59.0.html)\n\n# Introduction\n\n`serialport-rs` is a general-purpose cross-platform serial port library for Rust. It provides a\nblocking I/O interface and port enumeration on POSIX and Windows systems.\n\nFor async I/O functionality, see the [mio-serial](https://github.com/berkowski/mio-serial) and\n[tokio-serial](https://github.com/berkowski/tokio-serial) crates.\n\nJoin the discussion on Matrix!\n[#serialport-rs:matrix.org](https://matrix.to/#/#serialport-rs:matrix.org)\n\n**This project is looking for maintainers! Especially for Windows. If you are interested please let\nus know on Matrix, or by [creating a\ndiscussion](https://github.com/serialport/serialport-rs/discussions/new).**\n\n# Overview\n\nThe library exposes cross-platform serial port functionality through the `SerialPort` trait. This\nlibrary is structured to make this the simplest API to use to encourage cross-platform development\nby default. Working with the resultant `Box\u003cdyn SerialPort\u003e` type is therefore recommended. To\nexpose additional platform-specific functionality use the platform-specific structs directly:\n`TTYPort` for POSIX systems and `COMPort` for Windows.\n\nSerial enumeration is provided on most platforms. The implementation on Linux using `glibc` relies\non `libudev` (unless you disable the default `libudev` feature), an external dynamic library that\nwill need to be available on the system the final binary is running on. Enumeration will still be\navailable if this feature is disabled, but won't expose as much information and may return ports\nthat don't exist physically. However this dependency can be removed by disabling the default\n`libudev` feature:\n\n```shell\n$ cargo build --no-default-features\n```\n\nIt should also be noted that on macOS, both the Callout (`/dev/cu.*`) and Dial-in ports\n(`/dev/tty.*`) ports are enumerated, resulting in two available ports per connected serial device.\n\n# Usage\n\nListing available ports:\n\n```rust\nlet ports = serialport::available_ports().expect(\"No ports found!\");\nfor p in ports {\n    println!(\"{}\", p.port_name);\n}\n\n```\n\nOpening and configuring a port:\n\n```rust\nlet port = serialport::new(\"/dev/ttyUSB0\", 115_200)\n    .timeout(Duration::from_millis(10))\n    .open().expect(\"Failed to open port\");\n```\n\nWriting to a port:\n\n```rust\nlet output = \"This is a test. This is only a test.\".as_bytes();\nport.write(output).expect(\"Write failed!\");\n```\n\nReading from a port (default is blocking with a 0ms timeout):\n\n```rust\nlet mut serial_buf: Vec\u003cu8\u003e = vec![0; 32];\nport.read(serial_buf.as_mut_slice()).expect(\"Found no data!\");\n```\n\nSome platforms expose additional functionality, which is opened using the `open_native()` method:\n\n```rust\nlet port = serialport::new(\"/dev/ttyUSB0\", 115_200)\n    .open_native().expect(\"Failed to open port\");\n```\n\nClosing a port:\n\n`serialport-rs` uses the Resource Acquisition Is Initialization (RAII) paradigm and so closing a\nport is done when the `SerialPort` object is `Drop`ed either implicitly or explicitly using\n`std::mem::drop` (`std::mem::drop(port)`).\n\n# Examples\n\nThere are several included examples, which help demonstrate the functionality of this library and\ncan help debug software or hardware errors.\n\n- _clear_input_buffer_ - Demonstrates querying and clearing the driver input buffer.\n- _clear_output_buffer_ - Demonstrates querying and clearing the driver output buffer.\n- _duplex_ - Tests that a port can be successfully cloned.\n- _hardware_check_ - Checks port/driver functionality for a single port or a pair of ports connected\n  to each other.\n- _list_ports_ - Lists available serial ports.\n- _pseudo_terminal_ - Unix only. Tests that a pseudo-terminal pair can be created.\n- _receive_data_ - Output data received on a port.\n- _transmit_ - Transmits data regularly on a port with various port configurations. Useful for\n  debugging.\n\n# Dependencies\n\nRust versions 1.59.0 and higher are supported by the library itself. There are\nexamples requiring newer versions of Rust.\n\nFor GNU/Linux `pkg-config` headers are required:\n\n- Ubuntu: `sudo apt install pkg-config`\n- Fedora: `sudo dnf install pkgconf-pkg-config`\n\nFor other distros they may provide `pkg-config` through the `pkgconf` package instead.\n\nFor GNU/Linux `libudev` headers are required as well (unless you disable the default `libudev`\nfeature):\n\n- Ubuntu: `sudo apt install libudev-dev`\n- Fedora: `sudo dnf install systemd-devel`\n\n# Platform Support\n\nBuilds and some tests (not requiring actual hardware) for major targets are run\nin CI. Failures of either block the inclusion of new code. This library should\nbe compatible with additional targets not listed below, but no guarantees are\nmade. Additional platforms may be added in the future if there is a need and/or\ndemand.\n\n- Android\n  - `arm-linux-androideabi` (no serial enumeration)\n  - `armv7-linux-androideabi` (no serial enumeration)\n- FreeBSD\n  - `x86_64-unknown-freebsd`\n- Linux\n  - `aarch64-unknown-linux-gnu`\n  - `aarch64-unknown-linux-musl`\n  - `i686-unknown-linux-gnu`\n  - `i686-unknown-linux-musl`\n  - `x86_64-unknown-linux-gnu`\n  - `x86_64-unknown-linux-musl`\n- macOS/iOS\n  - `aarch64-apple-darwin`\n  - `aarch64-apple-ios`\n  - `x86_64-apple-darwin`\n- NetBSD\n  - `x86_64-unknown-netbsd` (no serial enumeration)\n- Windows\n  - `i686-pc-windows-gnu`\n  - `i686-pc-windows-msvc`\n  - `x86_64-pc-windows-gnu`\n  - `x86_64-pc-windows-msvc`\n\n# Hardware Support\n\nThis library has been developed to support all serial port devices across all supported platforms.\nTo determine how well your platform is supported, please run the `hardware_check` example provided\nwith this library. It will test the driver to confirm that all possible settings are supported for a\nport. Additionally, it will test that data transmission is correct for those settings if you have\ntwo ports physically configured to communicate. If you experience problems with your devices, please\nfile a bug and identify the hardware, OS, and driver in use.\n\nKnown issues:\n\n| Hardware      | OS    | Driver                  | Issues                                                                             |\n| ------------- | ----- | ----------------------- | ---------------------------------------------------------------------------------- |\n| FTDI TTL-232R | Linux | ftdi_sio, Linux 4.14.11 | Hardware doesn't support 5 or 6 data bits, but the driver lies about supporting 5. |\n\n# Licensing\n\nLicensed under the [Mozilla Public License, version 2.0](https://www.mozilla.org/en-US/MPL/2.0/).\n\n# Contributing\n\nPlease open an issue or pull request on GitHub to contribute. Code contributions submitted for\ninclusion in the work by you, as defined in the MPL2.0 license, shall be licensed as the above\nwithout any additional terms or conditions.\n\n# Acknowledgments\n\nThis is the continuation of the development at \u003chttps://gitlab.com/susurrus/serialport-rs\u003e. Thanks\nto susurrus and all other contributors to the original project on GitLab.\n\nSpecial thanks to dcuddeback, willem66745, and apoloval who wrote the original serial-rs library\nwhich this library heavily borrows from.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserialport%2Fserialport-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserialport%2Fserialport-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserialport%2Fserialport-rs/lists"}