https://github.com/johan-sports/busboy
Clojurescript USB monitoring for Node.js
https://github.com/johan-sports/busboy
clojure clojurescript monitoring nodejs usb
Last synced: about 2 months ago
JSON representation
Clojurescript USB monitoring for Node.js
- Host: GitHub
- URL: https://github.com/johan-sports/busboy
- Owner: johan-sports
- License: mit
- Created: 2017-05-26T15:21:34.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-13T09:23:05.000Z (about 9 years ago)
- Last Synced: 2025-07-01T12:52:17.827Z (12 months ago)
- Topics: clojure, clojurescript, monitoring, nodejs, usb
- Language: Clojure
- Size: 7.81 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Busboy
[](https://clojars.org/johan-sports/busboy)
Clojurescript USB monitoring for Node.js
## Usage
Busboy only provides one function, `create-usb-listener`. This will return a
`core.async` channel (you can also pass a prexisting one) that returns events
of type `[:attached ]` and `[:detached ]`. For example:
```
cljs.user> (require '[johan-sports.busboy :as busboy])
nil
cljs.user> (def poll-interval 1000) ;; in milliseconds
nil
cljs.user> (def dev-ch (busboy/create-usb-listener poll-interval))
nil
cljs.user> ;; device is attached
cljs.user> (go (println ( ;; device is detached
cljs.user> (go (println ( (close! dev-ch) ;; stop listening
```
There are plans in the future to remove the dependecy on `core.async` and either
pass a callback directly or use something like `manifold`.
### Devices
Devices are represented with a plain hash-map:
```clojure
{
:id "0x22B3-0xEF23-IDQ21AS23AB" ;; Unique ID
:vendor-id 0x22B3 ;; USB vendor ID
:product-id 0xEF23 ;; USB product ID
:manufacturer "Foobar Industries" ;; Name of manufacturer (if available)
:product "Time Traveler v3" ;; Name of product (if available)
:serial-number "IDQ21AS23AB" ;; Serial number (if available)
:mount "/Volumes/Vol1" ;; Path to mount point (if available)
}
```
## Contributors
* Antonis Kalou
## License
Licensed under MIT. See the [LICENSE](LICENSE) file in the project root directory.