forked from johnlauer/serial-port-json-server
-
Notifications
You must be signed in to change notification settings - Fork 101
/
usb.go
executable file
·58 lines (47 loc) · 1.03 KB
/
usb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
// "log"
"encoding/json"
// "runtime"
)
type UsbItem struct {
Id string
BusNum string
DeviceNum string
VidPid string
Name string
MaxPower string
IsVideo bool
VideoResolutions []VideoResolution
IsAudio bool
SerialNumber string
DeviceClass string
Vendor string
Product string
Pid string
Vid string
}
type VideoResolution struct {
Width int
Height int
}
type UsbListCmd struct {
UsbListStatus string
UsbList []UsbItem
}
func GetUsbList() []UsbItem {
// log.Println("Running main GetUsbList")
usbList := []UsbItem{}
// the call to getUsbList() is now handle by the usb_*.go files
//if runtime.GOOS == "linux" && runtime.GOARCH == "arm" {
usbList = getUsbList()
//}
return usbList
}
func SendUsbList() {
finalList := UsbListCmd{}
finalList.UsbListStatus = "Done"
finalList.UsbList = GetUsbList()
mapB, _ := json.Marshal(finalList)
h.broadcastSys <- mapB
}