added logging
This commit is contained in:
parent
219214c0a6
commit
0202cb4a7f
BIN
bin/usb-client
BIN
bin/usb-client
Binary file not shown.
BIN
bin/usb-relay
BIN
bin/usb-relay
Binary file not shown.
|
|
@ -336,6 +336,26 @@ func (s *Server) handleCmdSubmit(r io.Reader, hdr *URBHeader, retChan chan<- []b
|
||||||
endpoint := uint8(hdr.Endpoint)
|
endpoint := uint8(hdr.Endpoint)
|
||||||
urbType := s.getURBType(endpoint)
|
urbType := s.getURBType(endpoint)
|
||||||
|
|
||||||
|
dirStr := "OUT"
|
||||||
|
if hdr.Direction == DirIn {
|
||||||
|
dirStr = "IN"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log all transfers for debugging
|
||||||
|
if endpoint == 0 {
|
||||||
|
bmReqType := body.Setup[0]
|
||||||
|
bReq := body.Setup[1]
|
||||||
|
wVal := binary.LittleEndian.Uint16(body.Setup[2:4])
|
||||||
|
wIdx := binary.LittleEndian.Uint16(body.Setup[4:6])
|
||||||
|
wLen := binary.LittleEndian.Uint16(body.Setup[6:8])
|
||||||
|
log.Printf("[usbip-server] CTRL %s seq=%d bmReqType=0x%02x bReq=0x%02x wVal=0x%04x wIdx=0x%04x wLen=%d bufLen=%d",
|
||||||
|
dirStr, hdr.SeqNum, bmReqType, bReq, wVal, wIdx, wLen, body.TransferBufferLen)
|
||||||
|
} else {
|
||||||
|
typeNames := map[uint8]string{0: "ISO", 1: "INT", 2: "CTRL", 3: "BULK"}
|
||||||
|
log.Printf("[usbip-server] EP%d %s seq=%d type=%s bufLen=%d numPkts=%d",
|
||||||
|
endpoint, dirStr, hdr.SeqNum, typeNames[urbType], body.TransferBufferLen, numPackets)
|
||||||
|
}
|
||||||
|
|
||||||
// Handle control transfers specially (endpoint 0)
|
// Handle control transfers specially (endpoint 0)
|
||||||
if endpoint == 0 && hdr.Direction == DirIn {
|
if endpoint == 0 && hdr.Direction == DirIn {
|
||||||
buf := make([]byte, body.TransferBufferLen)
|
buf := make([]byte, body.TransferBufferLen)
|
||||||
|
|
@ -348,6 +368,7 @@ func (s *Server) handleCmdSubmit(r io.Reader, hdr *URBHeader, retChan chan<- []b
|
||||||
)
|
)
|
||||||
var status int32
|
var status int32
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Printf("[usbip-server] CTRL IN failed: %v", err)
|
||||||
status = -32 // -EPIPE
|
status = -32 // -EPIPE
|
||||||
n = 0
|
n = 0
|
||||||
}
|
}
|
||||||
|
|
@ -441,6 +462,7 @@ func (s *Server) handleCmdSubmit(r io.Reader, hdr *URBHeader, retChan chan<- []b
|
||||||
UserContext: uintptr(hdr.SeqNum),
|
UserContext: uintptr(hdr.SeqNum),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Printf("[usbip-server] SubmitURB(ep=0x%02x, type=%d, len=%d) FAILED: %v", ep, urbType, len(buf), err)
|
||||||
resp, _ := BuildRetSubmit(hdr.SeqNum, hdr.DevID, hdr.Direction, hdr.Endpoint, -32, nil)
|
resp, _ := BuildRetSubmit(hdr.SeqNum, hdr.DevID, hdr.Direction, hdr.Endpoint, -32, nil)
|
||||||
retChan <- resp
|
retChan <- resp
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -494,6 +516,9 @@ func (s *Server) handleISOSubmit(hdr *URBHeader, body *CmdSubmitBody, transferBu
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submit ISO URB
|
// Submit ISO URB
|
||||||
|
log.Printf("[usbip-server] ISO submit: ep=0x%02x dir=%d pkts=%d totalBuf=%d",
|
||||||
|
ep, hdr.Direction, numPackets, totalBufLen)
|
||||||
|
|
||||||
urb, isoMem, err := s.handle.SubmitISOURB(&usb.SubmitISOURBParams{
|
urb, isoMem, err := s.handle.SubmitISOURB(&usb.SubmitISOURBParams{
|
||||||
Endpoint: ep,
|
Endpoint: ep,
|
||||||
Flags: 0x02, // URB_ISO_ASAP
|
Flags: 0x02, // URB_ISO_ASAP
|
||||||
|
|
@ -503,6 +528,7 @@ func (s *Server) handleISOSubmit(hdr *URBHeader, body *CmdSubmitBody, transferBu
|
||||||
UserContext: uintptr(hdr.SeqNum),
|
UserContext: uintptr(hdr.SeqNum),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Printf("[usbip-server] ISO submit FAILED: %v", err)
|
||||||
// Submit failed - send error response
|
// Submit failed - send error response
|
||||||
resp, _ := BuildRetSubmit(hdr.SeqNum, hdr.DevID, hdr.Direction, hdr.Endpoint, -32, nil)
|
resp, _ := BuildRetSubmit(hdr.SeqNum, hdr.DevID, hdr.Direction, hdr.Endpoint, -32, nil)
|
||||||
retChan <- resp
|
retChan <- resp
|
||||||
|
|
@ -601,6 +627,11 @@ func (s *Server) reapLoop(retChan chan<- []byte, done <-chan struct{}) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if urbInfo.Status != 0 {
|
||||||
|
log.Printf("[usbip-server] URB completed: seq=%d ep=%d status=%d actual=%d iso=%v",
|
||||||
|
pending.seqNum, pending.endpoint, urbInfo.Status, urbInfo.ActualLength, pending.isISO)
|
||||||
|
}
|
||||||
|
|
||||||
var resp []byte
|
var resp []byte
|
||||||
if pending.isISO {
|
if pending.isISO {
|
||||||
resp, err = s.buildISOResponse(urbInfo, pending)
|
resp, err = s.buildISOResponse(urbInfo, pending)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue