This commit is contained in:
Kyle Lemons
2012-07-22 23:40:25 -07:00
parent b8ed23c967
commit 1723f5a08d
4 changed files with 18 additions and 18 deletions

View File

@@ -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)
}

View File

@@ -4,8 +4,8 @@ package usb
import "C"
import (
"log"
"fmt"
"log"
"reflect"
"sync"
"time"

View File

@@ -8,8 +8,8 @@ int submit(struct libusb_transfer *xfer);
import "C"
import (
"log"
"fmt"
"log"
"reflect"
"time"
"unsafe"
@@ -25,7 +25,7 @@ func (end *endpoint) allocTransfer() *Transfer {
// Use libusb_get_max_iso_packet_size ?
const (
iso_packets = 8 // 128 // 242
packet_size = 2*960 // 1760
packet_size = 2 * 960 // 1760
)
xfer := C.libusb_alloc_transfer(C.int(iso_packets))
@@ -82,12 +82,12 @@ 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)