% This function requires:
%   * Brick connected via USB
%   * EV3-Touch-Sensor at port 1
clear all;

b = CommunicationInterface('usb');
b.debug = 0; % Set this to 1 to have all packets sent and received printed to the console

% If you call this script more than once in a row, the reply to this command will also be
% erroneous (as this is another implicit mode change, from Bumps to Pushed).
val = b.inputReadSI(0, SensorPort.Sensor1, DeviceMode.Touch.Pushed);
fprintf('Pushed: %d\n', val);

val = b.inputReadSI(0, SensorPort.Sensor1, DeviceMode.Touch.Bumps); % The reply to this command should be erroneous 
fprintf('Bumps: %d\n', val);
val = b.inputReadSI(0, SensorPort.Sensor1, DeviceMode.Touch.Bumps); % Now it should work
fprintf('Bumps: %d\n', val);