Skip to content
Snippets Groups Projects
Commit 499a8a91 authored by Tim Stadtmann's avatar Tim Stadtmann
Browse files

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)
parent 2f6197df
Branches
Tags
No related merge requests found
...@@ -383,6 +383,9 @@ classdef hidapi < handle ...@@ -383,6 +383,9 @@ classdef hidapi < handle
% wmsg does not need to be the max packet size. Uncommenting this doesn't affect % 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. % 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. % 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; wmsg(end+(hid.nWriteBuffer-length(wmsg))) = 0;
% Create a uint8 pointer % Create a uint8 pointer
......
...@@ -27,7 +27,7 @@ classdef usbBrickIO < BrickIO ...@@ -27,7 +27,7 @@ classdef usbBrickIO < BrickIO
% read buffer size % read buffer size
nReadBuffer = 1024; nReadBuffer = 1024;
% write buffer size % write buffer size
nWriteBuffer = 1024; nWriteBuffer = 1025;
% time-out period in milliseconds (if 0, no time-out) % time-out period in milliseconds (if 0, no time-out)
timeOut = 10000; timeOut = 10000;
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment