How to read data from a Gaussmeter instrument using RS232 cable?

I am trying to read the data from a Gaussmeter. The Gaussmeter is connected to my laptop using an RS232 cable. The serial communication example looks simple but it never gives me the flux density data. Below is my code.
s = serial('COM5');
fopen(s);
fprintf(s,'*IDN?'); %identifacation
out = fscanf(s,'%c',25);
fprintf(s,'MEASUREMENT?'); % Is this the right command to ask for the measured data?
data = fscanf(s,'%c',25);
fclose(s);
delete(s);
clear s;
Then I have data in the workspace. ''out : F.W.BELL,7010 GAUSS-TESLA'' ; ''data : METER,V3.2''。 Obviously, V3.2 is not the flux density data. Does anyone have the experience of serial communication? How to read the data from the instrument?
Thank you.

Answers (1)

You are only reading the first 25 characters of the response to the identity query. You should use fgetl to read the entire line.

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Asked:

on 29 Apr 2016

Answered:

on 29 Apr 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!