How to read data continuously from serial port??

Discussion in 'MATLAB' started by jacob lalaounis, Jan 18, 2011.

  1. Hello,
    I have a serial port that sends data continuously and i would like to save these data to a txt file. while the data are recorded , a function(calibration) must run. I tried it with the code i below.But the problem is that it scans one line and then go to the function and stops recording.

    s = serial('COM5');
    fopen(s)
    set(s,'Baudrate',115200);
    while data==0
    data=calibration(10);
    tline1=fgetl(s);
    A=fscanf(s);
    fprintf(fed,'%s',tline1);
    end

    Any ideas how to overcome this problem??
    thanx in advance
    jacob
     
    jacob lalaounis, Jan 18, 2011
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.