Hi,
I am trying to stream data from a digital compass, the basic code below:
s=serial('COM9');
set(s,'BaudRate',9600);
fopen(s)
str=fscanf(s);
fclose(s)
the data can be read one time because the program only perform fcanf one time, now I want to update the robot position all the time, so I need to fscanf the COM port all the time until I press stop in my MATLAB GUI, I used while loop in the program like
while (s.Stauts=='open')
str=fscanf(s);
end
problem is the com port is opened all the time caused the program in a dead loop, I can not use the fclose to shut down the serial port any more? how can I add a loop to keep reading the port as well as I can stop the reading when I want? thanks for your hints. I appreciate your help 10000000X times in advance!
Jiazhong
|
|