How to send data (>64 bytes) to HID printer on Windows
Asked Answered
B

0

6

I am currently trying to send a string of arbitrary length to a Boca FGL46 Thermal Printer (A HID Printer) with java. On MacOS this works without issue; A 100 byte payload leads to a 100 byte output report. On windows, however, the output report is always 32 bytes + 1 byte for the reportID (0x00). I was able to avoid this issue by chunking the data into 32 byte segments, but I would like to understand the root cause.

I have tried device.setOutputReport(reportId, data, data.length); with both hid4java and purejavahidapi. I have also tried writing data directly to the device path using Windows' WriteFile. In every method, the data was truncated to 32 bytes. The same code on MacOS sends reports of any length. Why does windows have this limitation but MacOS doesn't?

Baulk answered 1/5, 2020 at 23:17 Comment(4)
Did you try your code with another HID Printer? My guess is that it is the "feature" of the driver for your printer. WriteFile is handled by the driver, Windows doesn't fragment data sent to device-mapped files.Hallock
This is the only HID printer I have seen.Baulk
So, my guess is the same - it is the issue with the driver.Hallock
Possibly related: github.com/libusb/hidapi/issues/274 since one of the aforementioned libraries uses hidapi.Celestinecelestite

© 2022 - 2024 — McMap. All rights reserved.