Erster Test
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
9
.idea/go-scsupdate.iml
generated
Normal file
9
.idea/go-scsupdate.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/go-scsupdate.iml" filepath="$PROJECT_DIR$/.idea/go-scsupdate.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
5
go.mod
Normal file
5
go.mod
Normal file
@@ -0,0 +1,5 @@
|
||||
module go-scsupdate
|
||||
|
||||
go 1.17
|
||||
|
||||
require github.com/google/gousb v1.1.1
|
2
go.sum
Normal file
2
go.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
github.com/google/gousb v1.1.1 h1:2sjwXlc0PIBgDnXtNxUrHcD/RRFOmAtRq4QgnFBE6xc=
|
||||
github.com/google/gousb v1.1.1/go.mod h1:b3uU8itc6dHElt063KJobuVtcKHWEfFOysOqBNzHhLY=
|
54
usb.go
Normal file
54
usb.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/google/gousb"
|
||||
"github.com/google/gousb/usbid"
|
||||
)
|
||||
|
||||
/*
|
||||
USB Product IDs of the SCS devices:
|
||||
0xD010 SCS PTC-IIusb
|
||||
0xD011 SCS Tracker / DSP TNC
|
||||
0xD012 SCS P4dragon DR-7800
|
||||
0xD013 SCS P4dragon DR-7400
|
||||
0xD014 - not used
|
||||
0xD015 SCS PTC-IIIusb
|
||||
0xD016 - not used
|
||||
0xD017 - not used
|
||||
*/
|
||||
|
||||
func lsusb() {
|
||||
// Only one context should be needed for an application. It should always be closed.
|
||||
ctx := gousb.NewContext()
|
||||
defer ctx.Close()
|
||||
|
||||
// OpenDevices is used to find the devices to open.
|
||||
devs, err := ctx.OpenDevices(func(desc *gousb.DeviceDesc) bool {
|
||||
// The usbid package can be used to print out human readable information.
|
||||
fmt.Printf("%03d.%03d %s:%s %s\n", desc.Bus, desc.Address, desc.Vendor, desc.Product, usbid.Describe(desc))
|
||||
fmt.Printf(" Protocol: %s\n", usbid.Classify(desc))
|
||||
fmt.Println(desc.Configs)
|
||||
return false
|
||||
})
|
||||
|
||||
// All Devices returned from OpenDevices must be closed.
|
||||
defer func() {
|
||||
for _, d := range devs {
|
||||
d.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
// OpenDevices can occasionally fail, so be sure to check its return value.
|
||||
if err != nil {
|
||||
log.Fatalf("list: %s", err)
|
||||
}
|
||||
|
||||
for _, dev := range devs {
|
||||
// Once the device has been selected from OpenDevices, it is opened
|
||||
// and can be interacted with.
|
||||
_ = dev
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user