Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arduino/board-discovery
https://github.com/arduino/board-discovery
arduino
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/arduino/board-discovery
- Owner: arduino
- License: gpl-2.0
- Created: 2017-08-25T09:54:07.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-27T10:33:20.000Z (3 months ago)
- Last Synced: 2024-09-29T08:25:58.367Z (about 2 months ago)
- Topics: arduino
- Language: Go
- Homepage:
- Size: 46.9 KB
- Stars: 7
- Watchers: 18
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= Arduino Board Discovery (Golang)
Alessandro SaninoThis package allows to discover and monitor Arduino boards connected to the network or the serial ports.
=== Getting the package
[source, bash]
----
$ go get github.com/arduino/board-discovery
----
Then import it to use it:
[source, go]
----
import "github.com/arduino/board-discovery"
----====== GODOC can be found link:https://godoc.org/github.com/arduino/board-discovery[HERE]
== Discovering devices
To discover devices you must first create a new Monitor (specifying the polling interval):
[source, go]
----
monitor := discovery.New(time.Millisecond)
----
Then start, get data and stop it when you don't need it anymore:
[source, go]
----
monitor.Start()
//Get devices connected
monitor.Stop()
----
You can get connected devices (via Serial or Network ports) by using the following functions:
[source, go]
----
serialDevices := monitor.Serial()
networkDevices := monitor.Network()
----=== The Monitor
Monitor periodically (period specified by *Interval*) checks the serial ports and the network in order to have
an updated list of Serial and Network ports.You can subscribe to the *Events* channel to get realtime notification of what's changed.
[source, go]
----
type Monitor struct {
Interval time.Duration
Events chan Event
}
----You can `Start`, `Stop` and `Restart` a Monitor, using the specified functions.
[source, go]
----
monitor.Start() // Starts monitoring
monitor.Stop() // Stops monitoring
monitor.Restart // Restarts the monitor (Stop, then Start)
----To have the list of devices discovered, you can use (assuming a started monitor `m`):
. `m.Serial()` to get the list of devices connected via serial interface.
. `m.Network()` to get the list of devices connected via the network.=== The device types
`SerialDevice` represents a device connected via serial port:
[source, go]
----
type SerialDevice struct {
Port string
SerialNumber string
ProductID string
VendorID string
Serial *serial.Info
}type SerialDevices map[string]*SerialDevice
----`NetworkDevice` represents a device connected via the network:
[source, go]
----
type NetworkDevice struct {
Address string
Info string
Name string
Port int
}type NetworkDevices map[string]*NetworkDevice
----== Security
If you think you found a vulnerability or other security-related bug in this project, please read our
https://github.com/arduino/board-discovery/security/policy[security policy] and report the bug to our Security Team 🛡️
Thank you!e-mail contact: [email protected]