diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2015-07-22 12:26:48 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2015-07-22 12:26:48 -0400 |
commit | baa5f520ab5e7e1b4f4ee579dedab539bde0a71b (patch) | |
tree | bffc779f731962780dc3b2c81efce997d73c2811 | |
parent | 61dd6147d4681b1a81f989ab00c2732beccf561d (diff) | |
download | linux-matlab-gpib-baa5f520ab5e7e1b4f4ee579dedab539bde0a71b.tar.gz linux-matlab-gpib-baa5f520ab5e7e1b4f4ee579dedab539bde0a71b.zip |
draft of the code to communicate with /dev/usbtm devices
-rw-r--r-- | query.m | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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 |