gofmt
This commit is contained in:
@@ -10,12 +10,12 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
device = flag.String("device", "vend:prod", "Device to which to connect")
|
||||
config = flag.Int("config", 1, "Endpoint to which to connect")
|
||||
iface = flag.Int("interface", 0, "Endpoint to which to connect")
|
||||
setup = flag.Int("setup", 0, "Endpoint to which to connect")
|
||||
device = flag.String("device", "vend:prod", "Device to which to connect")
|
||||
config = flag.Int("config", 1, "Endpoint to which to connect")
|
||||
iface = flag.Int("interface", 0, "Endpoint to which to connect")
|
||||
setup = flag.Int("setup", 0, "Endpoint to which to connect")
|
||||
endpoint = flag.Int("endpoint", 1, "Endpoint to which to connect")
|
||||
debug = flag.Int("debug", 3, "Debug level for libusb")
|
||||
debug = flag.Int("debug", 3, "Debug level for libusb")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -81,7 +81,7 @@ func main() {
|
||||
|
||||
log.Printf("Connecting to endpoint...")
|
||||
log.Printf("- %#v", dev.Descriptor)
|
||||
ep, err := dev.OpenEndpoint(uint8(*config), uint8(*iface), uint8(*setup), uint8(*endpoint) | uint8(usb.ENDPOINT_DIR_IN))
|
||||
ep, err := dev.OpenEndpoint(uint8(*config), uint8(*iface), uint8(*setup), uint8(*endpoint)|uint8(usb.ENDPOINT_DIR_IN))
|
||||
if err != nil {
|
||||
log.Fatalf("open: %s", err)
|
||||
}
|
||||
|
@@ -117,9 +117,9 @@ func newConfig(dev *C.libusb_device, cfg *C.struct_libusb_config_descriptor) Con
|
||||
Attributes: uint8(end.bmAttributes),
|
||||
MaxPacketSize: uint16(end.wMaxPacketSize),
|
||||
//MaxIsoPacket: uint32(C.libusb_get_max_iso_packet_size(dev, C.uchar(end.bEndpointAddress))),
|
||||
PollInterval: uint8(end.bInterval),
|
||||
RefreshRate: uint8(end.bRefresh),
|
||||
SynchAddress: uint8(end.bSynchAddress),
|
||||
PollInterval: uint8(end.bInterval),
|
||||
RefreshRate: uint8(end.bRefresh),
|
||||
SynchAddress: uint8(end.bSynchAddress),
|
||||
})
|
||||
}
|
||||
descs = append(descs, i)
|
||||
|
@@ -4,8 +4,8 @@ package usb
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"sync"
|
||||
"time"
|
||||
|
16
usb/iso.go
16
usb/iso.go
@@ -8,8 +8,8 @@ int submit(struct libusb_transfer *xfer);
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"time"
|
||||
"unsafe"
|
||||
@@ -24,8 +24,8 @@ func iso_callback(cptr unsafe.Pointer) {
|
||||
func (end *endpoint) allocTransfer() *Transfer {
|
||||
// Use libusb_get_max_iso_packet_size ?
|
||||
const (
|
||||
iso_packets = 8 // 128 // 242
|
||||
packet_size = 2*960 // 1760
|
||||
iso_packets = 8 // 128 // 242
|
||||
packet_size = 2 * 960 // 1760
|
||||
)
|
||||
|
||||
xfer := C.libusb_alloc_transfer(C.int(iso_packets))
|
||||
@@ -82,16 +82,16 @@ func (t *Transfer) Submit(timeout time.Duration) error {
|
||||
|
||||
func (t *Transfer) Wait(b []byte) (n int, err error) {
|
||||
select {
|
||||
case <-time.After(10*time.Second):
|
||||
case <-time.After(10 * time.Second):
|
||||
return 0, fmt.Errorf("wait timed out after 10s")
|
||||
case <-t.done:
|
||||
}
|
||||
n = int(t.xfer.actual_length)
|
||||
copy(b, ((*[1<<16]byte)(unsafe.Pointer(t.xfer.buffer)))[:n])
|
||||
copy(b, ((*[1 << 16]byte)(unsafe.Pointer(t.xfer.buffer)))[:n])
|
||||
/*
|
||||
for i, pkt := range t.pkts {
|
||||
log.Printf("PACKET[%4d] - %#v", i, pkt)
|
||||
}*/
|
||||
for i, pkt := range t.pkts {
|
||||
log.Printf("PACKET[%4d] - %#v", i, pkt)
|
||||
}*/
|
||||
return n, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user