urbiGetDeviceField

PURPOSE ^

Read a device field or a variable value

SYNOPSIS ^

function [v, time] = urbiGetDeviceField(con, deviceAndField)

DESCRIPTION ^

 Read a device field or a variable value
 e.g. v = getDeviceField(con, 'headPan.val');

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [v, time] = urbiGetDeviceField(con, deviceAndField)
0002 % Read a device field or a variable value
0003 % e.g. v = getDeviceField(con, 'headPan.val');
0004 
0005 urbiClearConnection(con,1);
0006 tag_base = 'gdftag';
0007 % Uses tag to choose the right answer among results
0008 % Note requested results outputed before are lost
0009 urbiSend(con, [tag_base ':' deviceAndField ';']);
0010 
0011 o_tag = '';
0012 while ~strcmp (o_tag, tag_base)
0013     r = pnet(con, 'readline', 'noblock');
0014     while isempty(r)
0015         r = pnet(con, 'readline', 'noblock');
0016     end;
0017     ans_string = strread (r, '%s');
0018     [timeStamp, o_tag] = strread(ans_string{1}, '[%u:%s]', 'whitespace', ']');
0019 end;
0020 v = str2num(ans_string{2});
0021 time = timeStamp;

Generated on Tue 20-Dec-2005 19:05:34 by m2html © 2003