delete(gcf);

fclose('all');

clear all
close all

global Data1;
global Data2;
global Data3;


seq_num_last = 0;

canch1 = canChannel('PEAK-System', 'PCAN_USBBUS1');
configBusSpeed(canch1, 500000);

Data1 = NaN(1,2^16);
Data2 = NaN(1,2^16);
Data3 = NaN(1,2^16);

figure
h1 = plot(Data1,'-.');
hold all
h2 = plot(Data2,'-.');
h3 = plot(Data3,'-.');

start(canch1)
canch1.MessageReceivedFcnCount = 1;
canch1.MessageReceivedFcn = @CanScopeCallback;


% while(1)
%    set(h1,'YData',Data1);
%    set(h2,'YData',Data2);
%    set(h3,'YData',Data2);
%    drawnow;
%    pause(.1);
% end