octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Serial comm


From: CdeMills
Subject: Re: Serial comm
Date: Mon, 31 May 2010 03:09:15 -0700 (PDT)

Be carefull about some obscure problems. For instance, if you read data from
the serial port, process them and write the results to a file, the write()
may block and input data get lost. I would suggest to write a intermediate
program which reads from the serial port, buffer data and write them to a
file, using two separate threads for reading and writing. Then the octave
program reads its data from the input file. The advantages is that you can
"replay" a program until it works, view the data and inspect for oddities,
and so on. The skeleton should look similar to

while some_condition,
       if (feof(fd)) %# wait a bit more for available data
         usleep(100000); continue;
      endif
      xx = fgets(fd);
      if (1 == length(xx)) %# problem getting chars ?
        if (-1 == xx)
          break; %# no new data
        endif
      endif
      xx = deblank(xx);
      if (length(xx) < 1) continue; endif %# skip empty line
     %# process content

Regards

Pascal
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/Serial-comm-tp2234692p2237107.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]