aboutsummaryrefslogtreecommitdiff
path: root/query_usbtmc.m
blob: 266e5799c2c4e5e18240473260cddf23231b4530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function [out_str] = query_usbtmc(fname, in_str)
    fname = '/dev/usbtmc0';

    string_terminator = 10;

    fhr = fopen( fname, 'r');
    fhw = fopen( fname, 'w');
    fwrite(fhw, in_str);

    out_str = [];
    [out_byte, cnt] = fread(fhr,1,'*uint8');
    while (out_byte ~= string_terminator) & (cnt ~= 0)
        out_str = [ out_str, char(out_byte) ];
        out_byte = fread(fhr,1,'*uint8');
    end

    fclose(fhr);
    fclose(fhw);

end