{"id":23275559,"url":"https://github.com/pr-dc/cordova-plugin-serialusb","last_synced_at":"2025-08-21T08:31:46.260Z","repository":{"id":57208897,"uuid":"445149412","full_name":"PR-DC/cordova-plugin-serialusb","owner":"PR-DC","description":"Cordova plugin for Android Serial USB communication (easily connect an Arduino board to an Android device).","archived":false,"fork":false,"pushed_at":"2024-05-15T21:48:13.000Z","size":19,"stargazers_count":7,"open_issues_count":2,"forks_count":3,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-05T09:43:04.057Z","etag":null,"topics":["android","cordova","node-js","nodejs","serial-communication","usb"],"latest_commit_sha":null,"homepage":"","language":"Java","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/PR-DC.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.txt","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":"2022-01-06T11:42:47.000Z","updated_at":"2025-05-29T20:09:55.000Z","dependencies_parsed_at":"2024-11-26T20:39:38.225Z","dependency_job_id":null,"html_url":"https://github.com/PR-DC/cordova-plugin-serialusb","commit_stats":{"total_commits":2,"total_committers":2,"mean_commits":1.0,"dds":0.5,"last_synced_commit":"40cc4585251a9330cbea73421b22b681c79e7e55"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/PR-DC/cordova-plugin-serialusb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PR-DC%2Fcordova-plugin-serialusb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PR-DC%2Fcordova-plugin-serialusb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PR-DC%2Fcordova-plugin-serialusb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PR-DC%2Fcordova-plugin-serialusb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PR-DC","download_url":"https://codeload.github.com/PR-DC/cordova-plugin-serialusb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PR-DC%2Fcordova-plugin-serialusb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271449277,"owners_count":24761645,"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","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["android","cordova","node-js","nodejs","serial-communication","usb"],"created_at":"2024-12-19T21:14:56.347Z","updated_at":"2025-08-21T08:31:45.999Z","avatar_url":"https://github.com/PR-DC.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## PR-DC cordova-plugin-serialusb\n\nCordova plugin for Android Serial USB communication. This plugin makes a connection to the external board trivial, for example, you can connect an Arduino board to an Android device and get power, storage, a high-quality touch interface and many possible ways of connecting with the rest of the world (mobile network, WiFi, Bluetooth...).\n\n## Requirements\n[Apache Cordova](https://cordova.apache.org/)\u003cbr\u003e\n\nThis library is tested with\n**Cordova Android 9.1.0**\n\n## Installation\nFrom the root folder of your Cordova project, run:\n```\ncordova plugin add https://github.com/PR-DC/cordova-plugin-serialusb.git\n```\n\n## Usage\nThanks to [usb-serial-for-android](https://github.com/mik3y/usb-serial-for-android) library, you can communicate with CDC, FTDI, Arduino and other devices.\n\nCopy `device_filter.xml` document to `www/res/xml`.\n\nAppend the following to the project's `config.xml` document within the Android platform-specific configuration. \n```xml\n\u003cconfig-file parent=\"/manifest/application/activity[@android:name='MainActivity']\" target=\"AndroidManifest.xml\"\u003e\n    \u003cintent-filter\u003e\n        \u003caction android:name=\"android.hardware.usb.action.USB_DEVICE_ATTACHED\" /\u003e\n    \u003c/intent-filter\u003e\n    \u003cmeta-data\n      android:name=\"android.hardware.usb.action.USB_DEVICE_ATTACHED\"\n      android:resource=\"@xml/device_filter\" /\u003e\n\u003c/config-file\u003e\n\u003cresource-file src=\"www/res/xml/device_filter.xml\" target=\"app/src/main/res/xml/device_filter.xml\" /\u003e\n```\n\nAppend following preference to project's `config.xml` document.\n```xml\n\u003cpreference name=\"AndroidXEnabled\" value=\"true\" /\u003e\n```\n\nNow you can proceed with the app code, request permission to use the serial port to the system:\n```js\nSerialUSB.requestPermission(function success(), function error());\n```\nAfter permission is granted you can open the serial port:\n```js\nSerialUSB.open(opts, function success(), function error());\n```\n`opts` is a JSON object with the following properties:\n\n- baudRate: defaults to 9600\n- dataBits: defaults to 8\n- stopBits: defaults to 1\n- parity: defaults to 0\n- dtr: defaults to false (it may be needed to be true for some Arduino)\n- rts: defaults to false (it may be needed to be true for some modules)\n- sleepOnPause: defaults to true. If false, the OTG port will remain open when the app goes to the background (or the screen turns off). Otherwise, the port automatically closes and resumes once the app is brought back to the foreground.\n\nYou're now able to read and write:\n```js\nSerialUSB.write(data, function success(), function error());\nSerialUSB.read(function success(buffer), function error());\n```\n`data` is the string representation to be written to the serial port.\n`buffer` is a JavaScript ArrayBuffer containing the data that was just read.\n\nApart from using `SerialUSB.write()`, you can also use `SerialUSB.writeHex()` to have an easy way to work with **RS232 protocol** driven hardware from your javascript by using **hex-strings**.\n\nIn a nutshell, `SerialUSB.writeHex('ff')` would write just a single byte where `SerialUSB.write('ff')` would let java write 2 bytes to the serial port.\n\nApart from that, `SerialUSB.writeHex()` works the same way as `SerialUSB.write()` does.\n\nRegister a callback that will be invoked when the driver reads incoming data from your serial device. The success callback function will receive an ArrayBuffer filled with the data read from serial:\n```js\nSerialUSB.registerReadCallback(\n  function success(data){\n    var view = new Uint8Array(data);\n    console.log(view);\n  },\n  function error(){\n    new Error(\"Failed to register read callback\");\n  });\n```\n\nRegister a callback that will be invoked when the device is detached:\n```js\nSerialUSB.detached(\n  function(success_message) {\n    \n  }, function(err) {\n    console.log(\"Device detached!\");\n  }\n);\n```\n\nAnd finally, you can also close the port with:\n```js\nSerialUSB.close(function success(), function error())\n```\n\n## Example with Cordova app and Arduino sketch\n\nAn example of connecting Cordova application to Arduino board is available at: https://github.com/PR-DC/PRDC_TestSerialUSB\n\n## Change log\n2021.12: [Miloš Petrašinović](https://github.com/PR-DC): renamed to cordova-plugin-serialusb (SerialUSB as in Arduino) and implemented detached event.\n\n2018.02: [Dario Cavada](https://github.com/dariocavada): renamed to cordova-plugin-usbserial and refactory internal to follow cordova naming convention.\n\n2015.10: [Ed. Lafargue](https://github.com/elafargue): Implemented \"sleepOnPause\" flag in the 'open' options to prevent closing the OTG port when app goes to background.\n\n2014.08: [Zevero](https://github.com/zevero): Option to find device by VID and PID, that let you use \"unrecognized\" devices.\n\n2014.07: [Hendrik Maus](https://github.com/hendrikmaus): Implemented writeHex for working with RS232 protocol, i.e. javascript can now pass \"ff\", java turns it into a 1 byte array and writes to the serial port - naturally, java, and the existing write method here, would create a 2 byte array from the input string.\n\n2014.04: [Derek K](https://github.com/etx): Implemented registerReadCallback for evented reading and Android onPause/onResume\n         \n2014.03: [Ed. Lafargue](https://github.com/elafargue): Implemented read(). The success callback returns a Javascript ArrayBuffer which is the best way to handle binary data in Javascript. It is straightforward to convert this to a string if required - a utility function could be implemented in this plugin.\n\n2013.11: [Xavier Seignard](https://github.com/xseignard): First implementation\n\n## License\nThe MIT License\n\nCopyright (c) 2021 Miloš Petrašinović PR-DC. https://pr-dc.com\n\nCopyright (c) 2015 Xavier Seignard. http://drangies.fr\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr-dc%2Fcordova-plugin-serialusb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpr-dc%2Fcordova-plugin-serialusb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr-dc%2Fcordova-plugin-serialusb/lists"}