aboutsummaryrefslogtreecommitdiff
path: root/query_usbtmc.m
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2015-07-23 14:44:36 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2015-07-23 14:44:36 -0400
commit9c44d3bd16d68c28347532689494140c4c27adcf (patch)
treef3c84fb48e30396a93870348e777a1d87eb5c75a /query_usbtmc.m
parent8813252cc379420f237f59cfc8873ecba8d6736f (diff)
downloadlinux-matlab-gpib-9c44d3bd16d68c28347532689494140c4c27adcf.tar.gz
linux-matlab-gpib-9c44d3bd16d68c28347532689494140c4c27adcf.zip
rename query to avoid name clashing
Diffstat (limited to 'query_usbtmc.m')
-rw-r--r--query_usbtmc.m20
1 files changed, 20 insertions, 0 deletions
diff --git a/query_usbtmc.m b/query_usbtmc.m
new file mode 100644
index 0000000..266e579
--- /dev/null
+++ b/query_usbtmc.m
@@ -0,0 +1,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