how can I keep reading a serial port?
Hi:
I tried to read·compass with a serial port, I used the program as below:
s=serial('COM9')
set(s,'BaudRate',9600);
fopen(s)
str=fscanf(s);
the·data can be read but I want to keep reading this port all the time, I used while(s.Status='open')loop to keep reading COM port, but the program will stay in the loop, I can not use fclose(s) to stop reading. what suggestion for this problem? thanks for your help I appreciate 100000 times in advance!!!!!!
I tried to read·compass with a serial port, I used the program as below:
s=serial('COM9')
set(s,'BaudRate',9600);
fopen(s)
str=fscanf(s);
the·data can be read but I want to keep reading this port all the time, I used while(s.Status='open')loop to keep reading COM port, but the program will stay in the loop, I can not use fclose(s) to stop reading. what suggestion for this problem? thanks for your help I appreciate 100000 times in advance!!!!!!
![confused.gif](http://forums.parallax.com/images/smilies/confused.gif)
Comments
It sounds as if you are going to have to do a fork() and then pass data from the child process back to the parent process. That's daunting to me, but then I'm not very good in C...
Have fun,
Terry
but I am not good at C as well all code I did in matlab
http://www.aaronklapheck.com/BS2_to_MATLAB.html
Currently I am working on using Parallax's data aquisition software and am simply reading it using MATLAB's read xls command.
Post Edited (Klap) : 5/7/2009 6:24:13 PM GMT