1 function sortie = teletry(filename)
\r
6 if ~exist('filename')
\r
10 if isnumeric(filename)
\r
11 filename = strcat('COM', num2str(filename));
\r
14 % detection port ou ficier
\r
15 if isnumeric(sscanf(filename, 'COM%i'))
\r
16 % Set serial port mode
\r
17 SER_PORT_ID = serial(filename, 'baudrate',38400);
\r
19 SER_PORT_ID.Terminator = 10; % LF
\r
21 SER_PORT_ID.Timeout = 2;
\r
25 SER_PORT_ID = fopen(filename);
\r
35 % waiting for first input
\r
37 read = fgetl(SER_PORT_ID);
\r
38 if ~ strcmp(read, '')
\r
43 read = fgetl(SER_PORT_ID); % skip first entry, coz could be incomplete
\r
49 if strcmp(read, '') || ~isstr(read)
\r
50 fclose(SER_PORT_ID);
\r
55 result = sscanf(read,'%c%i');
\r
57 sortie(time, :) = NaN;
\r
58 for no_param=1:length(result)/2
\r
61 for i=1:length(labels)
\r
62 if strcmp(labels{i}, char(result(no_param*2 -1)))
\r
63 sortie(time, i) = result(no_param*2);
\r
70 labels{length(labels)+1} = char(result(no_param*2 -1));
\r
71 sortie(1, length(labels)) = result(no_param*2 -1); % label 2
\r
72 sortie(time, length(labels)) = result(no_param*2);
\r
77 read = fgetl(SER_PORT_ID);
\r