{"id":24973391,"url":"https://github.com/motla/ftdi-d2xx","last_synced_at":"2025-10-07T14:34:50.772Z","repository":{"id":43150000,"uuid":"461357619","full_name":"motla/ftdi-d2xx","owner":"motla","description":"🔌 Pre-compiled FTDI D2XX drivers for Node.js (Node-API/CMake)","archived":false,"fork":false,"pushed_at":"2023-10-21T14:56:09.000Z","size":2919,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-13T06:06:02.016Z","etag":null,"topics":["d2xx","electron","ftdi","javascript","nodeapi","nodejs","serial","usb"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/motla.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-02-20T01:41:23.000Z","updated_at":"2025-05-19T13:53:18.000Z","dependencies_parsed_at":"2024-06-21T19:08:10.457Z","dependency_job_id":"7ef77f67-f3ee-4e90-9a38-c3fef760fce8","html_url":"https://github.com/motla/ftdi-d2xx","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/motla/ftdi-d2xx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motla%2Fftdi-d2xx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motla%2Fftdi-d2xx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motla%2Fftdi-d2xx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motla%2Fftdi-d2xx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/motla","download_url":"https://codeload.github.com/motla/ftdi-d2xx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/motla%2Fftdi-d2xx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261808074,"owners_count":23212694,"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":["d2xx","electron","ftdi","javascript","nodeapi","nodejs","serial","usb"],"created_at":"2025-02-03T18:59:09.560Z","updated_at":"2025-10-07T14:34:45.712Z","avatar_url":"https://github.com/motla.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FTDI D2XX Driver for Node.js\n\n## Features\n- Asynchronous, non-blocking functions (use [`Promises`](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Promises) or [`async/await`](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Promises#async_and_await))\n- Pre-compiled for Windows / macOS / Linux\n- Compatible with [Electron](https://www.electronjs.org/) (see [the note](#note-to-electron-users) below)\n- Includes static FTDI Driver vendor libraries\n- Written in pure C language using [Node-API](https://nodejs.org/api/n-api.html#node-api)\n- Detailed error messages and codes are thrown without crashing Node.js\n- Includes TypeScript typings for auto-completion and validation\n- Compiled with [CMake.js](https://github.com/cmake-js/cmake-js) (no `gyp` / no Python required)\n\n\n## Installation\nIn your Node.js project folder, run:\n```bash\nnpm install ftdi-d2xx\n```\n\nOn the top of your JavaScript file, add:\n```js\nconst FTDI = require('ftdi-d2xx'); // CommonJS syntax (.js files)\n// import FTDI from 'ftdi-d2xx'; // ESM syntax (.mjs files)\n```\n\n\n## Quick example\n```js\nlet device;\n\nasync function quick_example() {\n\n  try {\n    // Get the connected devices info list \n    const list = await FTDI.getDeviceInfoList();\n    console.log(`${list.length} device${list.length\u003e1?'s':''} found:`, list);\n    \n    // If there is at least one device connected\n    if(list.length) {\n  \n      // Try to open the first device from the list\n      device = await FTDI.openDevice(list[0].serial_number); // alternatively openDevice({ usb_loc_id: list[0].usb_loc_id });\n      console.log(`One device open:`, device);\n\n      // Setup the device\n      device.setTimeouts(1000, 1000); // set the max TX and RX duration in ms\n      device.purge(FTDI.FT_PURGE_RX); // purge the RX buffer from previous received data\n      //device.setBaudRate(115200); // set the UART baud rate (bits per second)\n      //device.setDataCharacteristics(FTDI.FT_BITS_8, FTDI.FT_STOP_BITS_1, FTDI.FT_PARITY_NONE);\n  \n      // Send data from the TXD pin of the device\n      await device.write(Uint8Array.from([1, 2, 3, 4]));\n      console.log(`Data sent successfully.`);\n  \n      // Wait to receive from the RXD pin\n      console.log(`Trying to receive data...`);\n      const response = await device.read(4); // expected response byte length (will return either if this is reached or after an RX timeout)\n      console.log(`${response.byteLength} bytes were received:`, response);\n\n      // If TXD and RXD pins are connected together, you should get Uint8Array(4)[1, 2, 3, 4] immediately\n      // If not, you should get Uint8Array(0)[] after 1 second of timeout\n\n      // Close the device (device object must then be recreated using openDevice)\n      device.close();\n\n      // Be careful \"not to loose\" the device object before closing it, otherwise\n      // the device will likely stay open and you will not be able to re-open it.\n    }\n  } catch (e) {\n    console.error(e);\n  }\n}\n\n// Run the example\nawait quick_example();\n```\n\n\n## Docs\n- [FTDI D2XX Programmer's Guide](https://ftdichip.com/wp-content/uploads/2020/08/D2XX_Programmers_GuideFT_000071.pdf)\n- [ftdi-d2xx JavaScript implementation API](docs/Home.md)\n\n\u003e [!NOTE]\n\u003e On Windows, FT_Reload() is implemented under FTDI.setVIDPID().\n\n\u003e [!NOTE]\n\u003e See the included FTDI D2XX driver library versions in the [CHANGELOG.md](CHANGELOG.md) file.\n\n\n## Note to Electron users\n\nAs you may already know, Electron runs in two processes: a **main process** and a **renderer process** ([more info here](https://www.electronjs.org/docs/latest/tutorial/process-model)).\n\nFor security reasons, in the newest releases of Electron, you can only access Node.js inside the **main process**. However, you probably want to interact with this API using buttons, or to display information in the **renderer process**. It lets you two options:\n\n- ***Option 1*** : Accessing this API only inside a `preload.js` file which has access to Node.js and can also export globals to the **renderer process** (recommended):\n  - This file shall be associated to the `BrowserWindow` of your application using `webPreferences.preload` field with `webPreferences.sandbox` set to `false` to enable external modules loading ([more info here](https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts)).\n  - This file shall contain (or require) all your functions calling this FTDI library.\n  - This file shall contain a `contextBridge` to expose your functions globally to the renderer process ([more info here](https://www.electronjs.org/docs/latest/api/context-bridge#usage)).\n  - **Important:** information exchanged in the pipe between **main process** and **renderer process** (Electron calls it IPC) is **serialized**. That means data is converted in a JSON-like file format before being passed. [Only these data types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types) are supported ([more info here](https://www.electronjs.org/docs/latest/tutorial/ipc#object-serialization)).\n  - **Note:** for the above reason, exposing the `FTDI` library object or functions directly to the **renderer process** doesn't work (it would be a bad security practice anyway).\n- ***Option 2*** : Disabling the security and allowing Node.js to run in the **renderer process** ([more info here](https://www.electronjs.org/docs/latest/tutorial/security#2-do-not-enable-nodejs-integration-for-remote-content) - not recommended).\n\n\u003e [!IMPORTANT]\n\u003e If you use a compiler for your Electron project and you get errors, make sure to exclude this library from compilation as a native library.\n\n\n## To do\nTo be added if there is a need for it:\n- [ ] Add `FT_SetEventNotification` in a separate worker, with JS event handlers\n- [ ] Add `FT_Rescan`, `FT_CyclePort`, `FT_SetResetPipeRetryCount`, `FT_StopInTask`, `FT_RestartInTask`, `FT_SetDeadmanTimeout`. Hopefully with the latest drivers and recent hardware, these functions are not needed anymore.\n- [ ] Add `FT_SetChars` function\n- [ ] Add the other `FT_EE_*` functions\n\n\n## Development\n- [Download and install CMake](https://cmake.org/download/) on your computer\n- Clone this repository, add your modifications if needed\n- Run `npm install` inside the repository to install development dependencies locally (cmake-js and typedoc)\n- Compile the code:\n  - Running `npm run cmake:rebuild-debug` will rebuild the debug version of `ftdi-d2xx.node` for your platform and processor under `build/Debug`\n  - Running `npm run cmake:rebuild-release` will build `ftdi-d2xx.platform.processor.node` under `build/Release`\n  - Running `npm run cmake:clean` will clean the `build` folder\n- Run `npm run node:test` to execute the `/test.js` file, which loads the Debug Build and runs basic initialization code followed by a REPL console to test function calls dynamically\n- Run `npm run typedoc` to regenerate the API documentation\n- Make a pull request to share your work\n\n\n## Sponsor\nThe original work for the library wrapper has been sponsored by [ONWI](https://www.onwi.fr/), a small electronics design office and production unit based near Lyon, France.\n\n\n## Licensing\nThis library is distributed under the terms of the [GNU LGPLv3](LICENSE).\n\nIt includes the official **libftd2xx** library provided by FTDI, which is released under their specific Driver Licence Terms (https://ftdichip.com/driver-licence-terms/). Please make sure you agree to all the License Terms before using this library. See the included library versions in the [CHANGELOG.md](CHANGELOG.md) file.\n\n**libftd2xx** uses an unmodified version of libusb (http://libusb.info) which is distributed under the terms of the [GNU Lesser General Public License](https://www.gnu.org/licenses/lgpl-2.1.html). Source code for libusb is included in this distribution for reference (lib/libusb-source).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmotla%2Fftdi-d2xx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmotla%2Fftdi-d2xx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmotla%2Fftdi-d2xx/lists"}