From 499a8a9187c23f8047ca0f6eab5f0c63c62977da Mon Sep 17 00:00:00 2001 From: Tim Stadtmann <tim.stadtmann@rwth-aachen.de> Date: Tue, 25 Apr 2017 16:20:25 +0200 Subject: [PATCH] Fix bug that made sending packets under Win fail Using Windows, the packet size of USB packets has to equal wMaxPacketSize defined in the so called 'endpoint descriptor' of the USB-HID (+ 1 byte with the report ID; see HIDAPI doc) --- source/hidapi.m | 3 +++ source/usbBrickIO.m | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/hidapi.m b/source/hidapi.m index a8803b4..0815abd 100755 --- a/source/hidapi.m +++ b/source/hidapi.m @@ -383,6 +383,9 @@ classdef hidapi < handle % wmsg does not need to be the max packet size. Uncommenting this doesn't affect % anything, and I would prefer sending short messages over long ones. % Further testing may be required, so for now I don't change a thing. + % (MMI) Update:: Okay, so under Windows, this line IS necessary, as well as the + % fixed write-buffer size of 1025 bytes (== wMaxPacketSize+1; smaller packets fail; + % bigger packets do get handled by the brick, but the second assertion below will fail). wmsg(end+(hid.nWriteBuffer-length(wmsg))) = 0; % Create a uint8 pointer diff --git a/source/usbBrickIO.m b/source/usbBrickIO.m index 47a6820..6a7a7c5 100755 --- a/source/usbBrickIO.m +++ b/source/usbBrickIO.m @@ -27,7 +27,7 @@ classdef usbBrickIO < BrickIO % read buffer size nReadBuffer = 1024; % write buffer size - nWriteBuffer = 1024; + nWriteBuffer = 1025; % time-out period in milliseconds (if 0, no time-out) timeOut = 10000; end -- GitLab