diff --git a/ipp-usb.8 b/ipp-usb.8 index 36a3032..a82546e 100644 --- a/ipp-usb.8 +++ b/ipp-usb.8 @@ -307,6 +307,10 @@ Delay between subsequent requests\. \fBusb\-max\-interfaces = N\fR .br Don't use more that N USB interfaces, even if more is available\. +.IP "\(bu" 4 +\fBzlp\-send = true | false\fR +.br +Terminate outgoing transfers that a multiple of the endpoint's packet size win an extra zero length packet\. .IP "" 0 .P The DELAY parameter can be specified either as an unsigned integer (in milliseconds) or as a sequence of decimal numbers with an optional fraction and a unit suffix, such as "300ms," "0\.5s," or "2m30s\." Valid time units are "ns," "us" (or "µs"), "ms," "s," "m," and "h\." diff --git a/ipp-usb.8.md b/ipp-usb.8.md index 82d4679..7182e27 100644 --- a/ipp-usb.8.md +++ b/ipp-usb.8.md @@ -387,6 +387,10 @@ The following parameters are defined: * `usb-max-interfaces = N`
Don't use more that N USB interfaces, even if more is available. + * `zlp-send = true | false`
+ Terminate outgoing transfers that a multiple of the endpoint's + packet size win an extra zero length packet. + The DELAY parameter can be specified either as an unsigned integer (in milliseconds) or as a sequence of decimal numbers with an optional fraction and a unit suffix, such as "300ms," "0.5s," or "2m30s." Valid diff --git a/quirks.go b/quirks.go index 38fb3b8..63bb02f 100644 --- a/quirks.go +++ b/quirks.go @@ -44,6 +44,7 @@ const ( QuirkNmInitTimeout = "init-timeout" QuirkNmRequestDelay = "request-delay" QuirkNmUsbMaxInterfaces = "usb-max-interfaces" + QuirkNmZlpSend = "zlp-send" ) // quirkParse maps quirk names into appropriate parsing methods, @@ -58,6 +59,7 @@ var quirkParse = map[string]func(*Quirk) error{ QuirkNmInitTimeout: (*Quirk).parseDuration, QuirkNmRequestDelay: (*Quirk).parseDuration, QuirkNmUsbMaxInterfaces: (*Quirk).parseUint, + QuirkNmZlpSend: (*Quirk).parseBool, } // quirkDefaultStrings contains default values for quirks, in @@ -72,6 +74,7 @@ var quirkDefaultStrings = map[string]string{ QuirkNmInitTimeout: DevInitTimeout.String(), QuirkNmRequestDelay: "0", QuirkNmUsbMaxInterfaces: "0", + QuirkNmZlpSend: "false", } // quirkDefault contains default values for quirks, precompiled. @@ -344,6 +347,12 @@ func (quirks Quirks) GetUsbMaxInterfaces() uint { return quirks.Get(QuirkNmUsbMaxInterfaces).Parsed.(uint) } +// GetZlpSend returns effective "zlp-send" parameter, +// taking the whole set into consideration. +func (quirks Quirks) GetZlpSend() bool { + return quirks.Get(QuirkNmZlpSend).Parsed.(bool) +} + // QuirksSet represents collection of quirks type QuirksSet []*Quirks diff --git a/quirks_test.go b/quirks_test.go index cd901ad..0835034 100644 --- a/quirks_test.go +++ b/quirks_test.go @@ -135,6 +135,17 @@ func TestQuirksLookup(t *testing.T) { origin: "default", }, + { + model: "Unknown Device", + param: QuirkNmZlpSend, + get: func(quirks Quirks) interface{} { + return quirks.GetZlpSend() + }, + match: "*", + value: false, + origin: "default", + }, + // Quirks for some known devices { model: "HP ScanJet Pro 4500 fn1", diff --git a/usbio_libusb.go b/usbio_libusb.go index dfa2735..ccfbaaa 100644 --- a/usbio_libusb.go +++ b/usbio_libusb.go @@ -789,6 +789,10 @@ func (iface *UsbInterface) Send(ctx context.Context, 0, ) + if iface.quirks.GetZlpSend() { + xfer.flags |= C.LIBUSB_TRANSFER_ADD_ZERO_PACKET + } + // Submit transfer rc := C.libusb_submit_transfer(xfer) if rc < 0 {