-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_data.m
49 lines (32 loc) · 930 Bytes
/
get_data.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
%
clc;
clear;
close all;
%data_att = zeros(1,256);
Data=zeros(1,1000);
ComPort='COM4';
TG_BAUD_57600=57600;
TG_STREAM_PACKETS=0;
TG_DATA_RAW = 4;
loadlibrary('thinkgear.dll', 'thinkgear.h');
Dllversion=calllib('thinkgear','TG_GetVersion');
ConnectionId=calllib('thinkgear','TG_GetNewConnectionId');
CommERR=calllib('thinkgear','TG_Connect',ConnectionId,ComPort,TG_BAUD_57600,TG_STREAM_PACKETS);
if CommERR < 0
disp('Communication error,Reset Matlab and Brainsense');
end
i=1;
j=1;
while i < 1000
if (calllib('thinkgear','TG_ReadPackets',ConnectionId,1)==1)
% if (calllib('Thinkgear','TG_GetValueStatus',ConnectionId,TG_DATA_RAW)~=0)
Data(j)=calllib('thinkgear','TG_GetValue',ConnectionId,TG_DATA_RAW);
i=i+1;
j=j+1;
plot(Data);
drawnow;
% end
end
end
calllib('thinkgear', 'TG_FreeConnection', ConnectionId );
calllib('thinkgear', 'TG_Disconnect', ConnectionId );