{"id":13602008,"url":"https://github.com/licheedev/Android-SerialPort-API","last_synced_at":"2025-04-11T08:31:18.072Z","repository":{"id":37451189,"uuid":"86285818","full_name":"licheedev/Android-SerialPort-API","owner":"licheedev","description":"Fork自Google开源的Android串口通信Demo，修改成Android Studio项目","archived":false,"fork":false,"pushed_at":"2024-09-06T03:27:13.000Z","size":145,"stargazers_count":1315,"open_issues_count":24,"forks_count":376,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-11-07T05:38:21.542Z","etag":null,"topics":["android","serialport"],"latest_commit_sha":null,"homepage":"https://code.google.com/archive/p/android-serialport-api/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/licheedev.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":"2017-03-27T03:09:47.000Z","updated_at":"2024-11-06T15:20:55.000Z","dependencies_parsed_at":"2024-11-07T05:32:53.006Z","dependency_job_id":"43690430-2d59-49b2-9f67-1ccba4de3efa","html_url":"https://github.com/licheedev/Android-SerialPort-API","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/licheedev%2FAndroid-SerialPort-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/licheedev%2FAndroid-SerialPort-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/licheedev%2FAndroid-SerialPort-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/licheedev%2FAndroid-SerialPort-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/licheedev","download_url":"https://codeload.github.com/licheedev/Android-SerialPort-API/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248361520,"owners_count":21090917,"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":["android","serialport"],"created_at":"2024-08-01T18:01:11.612Z","updated_at":"2025-04-11T08:31:17.616Z","avatar_url":"https://github.com/licheedev.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"# Android-SerialPort-API\n[Fork](https://code.google.com/archive/p/android-serialport-api/)自Google开源的Android串口通信Demo，修改成Android Studio项目 \n\nThis lib is a [fork](https://code.google.com/archive/p/android-serialport-api/) of the Android serial port communication Demo open sourced by Google.\n\n## Installation \u0026 Usage\n**Gradle**\n\n添加依赖:\n\nAdd the dependency:\n\n```\nallprojects {\n    repositories {\n        ...\n        jcenter()\n        mavenCentral() // since 2.1.3\n    }\n}\n\ndependencies {\n        // 传统4KB内存页面版本\n        implementation 'com.licheedev:android-serialport:2.1.4'\n        // 适配16KB页面版本，https://developer.android.google.cn/guide/practices/page-sizes?hl=zh-cn\n        implementation 'com.licheedev:android-serialport:2.1.5'\n}\n```\n\n**Import**\n\n```java\nimport android.serialport.SerialPort;\n```\n\n**`su` path**\n\nIn order to read/write to a serial port in Android you'll need `su` binary installed on device (this can be done by rooting the device). Usually Android devices that has the ability to communicate with serial ports have `su` installed on the default path `\"/system/bin/su\"`. To change this use:\n\n```java\n// su默认路径为 \"/system/bin/su\"\n// The default path of su is \"/system/bin/su\"\n// 可通过此方法修改\n// If the path is different then change it using this\nSerialPort.setSuPath(\"/system/xbin/su\");\n```\n\n**Usage**\n\n```java\n// 默认8N1(8数据位、无校验位、1停止位)\n// Default 8N1 (8 data bits, no parity bit, 1 stop bit)\nSerialPort serialPort = new SerialPort(path, baudrate);\n\n// 可选配置数据位、校验位、停止位 - 7E2(7数据位、偶校验、2停止位)\n// or with builder (with optional configurations) - 7E2 (7 data bits, even parity, 2 stop bits)\nSerialPort serialPort = SerialPort \n    .newBuilder(path, baudrate)\n// 校验位；0:无校验位(NONE，默认)；1:奇校验位(ODD);2:偶校验位(EVEN)\n// Check bit; 0: no check bit (NONE, default); 1: odd check bit (ODD); 2: even check bit (EVEN)\n//    .parity(2) \n// 数据位,默认8；可选值为5~8\n// Data bit, default 8; optional value is 5~8\n//    .dataBits(7) \n// 停止位，默认1；1:1位停止位；2:2位停止位\n// Stop bit, default 1; 1:1 stop bit; 2: 2 stop bit\n//    .stopBits(2) \n    .build();\n    \n// read/write to serial port - needs to be in different thread!\nInputStream in = serialPort.getInputStream();\nOutputStream out = serialPort.getOutputStream();\n\n// close\nserialPort.tryClose();\n```\n\n实现方式参考\n\nImplementation reference\n1. Check [sample project](https://github.com/licheedev/Android-SerialPort-API/tree/master/sample)\n2. https://juejin.im/post/5c010a19e51d456ac27b40fc\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flicheedev%2FAndroid-SerialPort-API","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flicheedev%2FAndroid-SerialPort-API","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flicheedev%2FAndroid-SerialPort-API/lists"}