{"id":21393429,"url":"https://github.com/kopera/erlang-usb","last_synced_at":"2025-07-13T18:32:07.769Z","repository":{"id":65702570,"uuid":"274124476","full_name":"kopera/erlang-usb","owner":"kopera","description":"Erlang USB library","archived":false,"fork":false,"pushed_at":"2025-02-06T10:01:33.000Z","size":49,"stargazers_count":8,"open_issues_count":4,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-07T16:48:45.573Z","etag":null,"topics":["embedded","erlang","linux","usb"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","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/kopera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-06-22T11:57:34.000Z","updated_at":"2025-02-22T05:47:27.000Z","dependencies_parsed_at":"2024-04-18T16:59:25.317Z","dependency_job_id":null,"html_url":"https://github.com/kopera/erlang-usb","commit_stats":{"total_commits":27,"total_committers":4,"mean_commits":6.75,"dds":0.5925925925925926,"last_synced_commit":"224c0f1b3400230e94ec2199a32d7d84f31faee6"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/kopera/erlang-usb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopera%2Ferlang-usb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopera%2Ferlang-usb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopera%2Ferlang-usb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopera%2Ferlang-usb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kopera","download_url":"https://codeload.github.com/kopera/erlang-usb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kopera%2Ferlang-usb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265186789,"owners_count":23724740,"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":["embedded","erlang","linux","usb"],"created_at":"2024-11-22T14:11:51.203Z","updated_at":"2025-07-13T18:32:07.757Z","avatar_url":"https://github.com/kopera.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# usb\n\nAn Erlang application for interfacing with USB peripherals using libusb.\n\nThis application allows for discovering and communicating with USB peripherals by making use of libusb through a NIF interface.\n\n# Dependencies\n\nThis Erlang application library depends on:\n\n* `pkg-config` (build only)\n* `libusb` ≥ 1.0.16\n\n# Setup\n\nYou need to add `usb` as a dependency to your project. If you are using `rebar3`, you can add the following to your `rebar.config`:\n\n```erlang\n{deps, [\n    {usb, \"0.2.1\"}\n]}.\n```\n\nAlso ensure that `usb` is added as a dependency to your application, by\nupdating your `.app.src` file:\n\n```erlang\n{application, my_app, [\n\n    {applications, [\n        kernel,\n        stdlib,\n\n        usb  % \u003c- You need this in your applications list\n    ]}\n]}.\n```\n\n# Usage\n\n## Listing and querying devices\n\nYou can list currently connected USB devices, you can use:\n\n```erlang\n\u003e {ok, [Device|_]} = usb:get_device_list().\n{ok,[#Ref\u003c0.1223016592.607256583.114769\u003e]}.\n```\n\nYou can then query the device:\n\n```erlang\n\u003e usb:get_device_speed(Device).\n{ok, high}\n\u003e usb:get_device_descriptor(Device).\n{ok, #{\n    class_code =\u003e 0,\n    device_version =\u003e 532,\n    manufacturer_string_index =\u003e 1,\n    max_packet_size0 =\u003e 64,\n    num_configurations =\u003e 1,\n    product_id =\u003e 33028,\n    product_string_index =\u003e 0,\n    protocol_code =\u003e 0,\n    serial_number_string_index =\u003e 2,\n    sub_class_code =\u003e 0,\n    usb_version =\u003e 512,\n    vendor_id =\u003e 1452\n}}\n\u003e usb:get_config_descriptor(Device, 0).\n{ok, #{\n    attributes =\u003e 224,\n    configuration_number =\u003e 1,\n    description_string_index =\u003e 0,\n    extra =\u003e \u003c\u003c\u003e\u003e,\n    interfaces =\u003e [\n        #{alt_settings =\u003e [\n            #{\n                class_code =\u003e 3,\n                description_string_index =\u003e 4,\n                endpoints =\u003e [\n                    #{\n                        address =\u003e 129,\n                        attributes =\u003e 3,\n                        extra =\u003e \u003c\u003c\u003e\u003e,\n                        interval =\u003e 1,\n                        max_packet_size =\u003e 8,\n                        refresh =\u003e 0,\n                        synch_address =\u003e 0\n                    }\n                ],\n                extra =\u003e \u003c\u003c9,33,1,1,0,1,34,179,0\u003e\u003e,\n                interface_number =\u003e 0,\n                protocol_code =\u003e 0,\n                setting_number =\u003e 0,\n                sub_class_code =\u003e 0\n            }\n        ]}\n    ],\n    max_power =\u003e 500\n}}\n```\n\n## Monitoring USB device hotplug\n\nThe following will start monotoring for USB device arrival and departure:\n\n```erlang\n\u003e {ok, Monitor} = usb:monitor_hotplug([enumerate]).\n{ok, #Ref\u003c0.731181930.70909953.42752\u003e}\n```\n\nThe `enumerate` option will create hotplug notifications about already plugged\nin devices. Without the option, only newly connected devices will be reported.\n\nFrom this point on, the process monitoring USB hotplug will received one of the following messages:\n\n* `{usb, device_arrived, Device}`\n* `{usb, device_left, Device}`\n\nwhere `Device` is an opaque reference representing a specific device. these references can be used to interact with the device.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkopera%2Ferlang-usb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkopera%2Ferlang-usb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkopera%2Ferlang-usb/lists"}