From baa5f520ab5e7e1b4f4ee579dedab539bde0a71b Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Wed, 22 Jul 2015 12:26:48 -0400 Subject: draft of the code to communicate with /dev/usbtm devices --- query.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 query.m diff --git a/query.m b/query.m new file mode 100644 index 0000000..f276125 --- /dev/null +++ b/query.m @@ -0,0 +1,20 @@ +function [out_str] = query(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 -- cgit v1.2.3