Shop OBEX P1 Docs P2 Docs Learn Events
how can I keep reading a serial port? — Parallax Forums

how can I keep reading a serial port?

yoyokilleryoyokiller Posts: 8
edited 2008-08-26 02:16 in General Discussion
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!!!!!!confused.gif

Comments

  • terry_bearterry_bear Posts: 84
    edited 2008-03-20 15:13
    yoyokiller,

    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
  • yoyokilleryoyokiller Posts: 8
    edited 2008-03-20 15:34
    thanks
    but I am not good at C as well all code I did in matlab
  • KlapKlap Posts: 65
    edited 2008-08-26 02:16
    I am using DAQ in matlab also. For examples please see my website.


    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
Sign In or Register to comment.