-
Notifications
You must be signed in to change notification settings - Fork 1
/
vrLoggerCallback.m
62 lines (54 loc) · 1.67 KB
/
vrLoggerCallback.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
50
51
52
53
54
55
56
57
58
59
60
61
function h = vrLoggerCallback(u, h)
% fprintf('%s:%d\n', u.DatagramAddress, u.DatagramPort),
% u.RemoteHost=u.DatagramAddress;
% u.RemotePort=u.DatagramPort;
% disp('now reading data');
persistent folders filename
ip=u.DatagramAddress;
port=u.DatagramPort;
% these are needed for proper echo
u.RemoteHost=ip;
u.RemotePort=port;
data=fread(u);
str=char(data');
fprintf('Received ''%s'' from %s:%d\n', str, ip, port);
delimiter = ' +'; % one or more spaces
message=regexp(str, delimiter, 'split');
instruction = message{1};
% subject = message{2};
switch instruction
case 'hello'
% fwrite(u, data);
case 'Filename'
% this is the file on the zserver, which is updated after every
% trial with all the session info
filename = message{2};
case 'ExpStart'
load the EXP structure and extract all the experiment parameters
draw the maze map with a mouse in it
% fwrite(u, data);
case 'ExpEnd'
% fwrite(u, data);
case 'BlockStart'
% fwrite(u, data);
case 'BlockEnd'
% fwrite(u, data);
case 'StimStart'
% fwrite(u, data);
case 'StimEnd'
% fwrite(u, data);
case 'Position'
update the mouse position on the map
case 'Event'
otherwise
fprintf('Unknown instruction : %s', info.instruction);
% fwrite(u, data);
end
% disp('now the addresses are:');
% fprintf('%s:%d\n', u.DatagramAddress, u.DatagramPort),
% fprintf('now sending %s to the remote host\n', char(data(:))');
% fprintf('%s\n', char(data(:))');
% fprintf
end
%===========================================================
%