help-octave
[Top][All Lists]
Advanced

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

Re: Serial connection (realtime)


From: Kire Pudsje
Subject: Re: Serial connection (realtime)
Date: Thu, 2 Mar 2017 03:33:05 +0100

Sorry, one of the last lines should have been
    dataacc(1:idx(end)) = [];

On Thu, Mar 2, 2017 at 3:29 AM, Kire Pudsje <address@hidden> wrote:
Looking at the data, I see 13 and 10. These are the ascii values of carriage return and line feed.
So the data is just a list of ascii values representing characters.
To convert to a string, just do:
s =  char(data);
Then (after making sure, you do proper aligning of strings, to prevent cuts between digits), use
val = str2num(s);

untested code, processing chunks of 100 bytes at once
dataacc = [];
while true
  % read data
  data="">
  % append to accumulation buffer
  datacc = [datacc, data];
  % find last line feed
  idx = find(dataacc == 10);
  % if something found
  if ~isempty(idx)
    % process data until last linefeed character
    val = str2num(char(dataacc(1:idx(end))));
    % do something useful with the data
    disp(val);
    % remove processed part from accumulation buffer
    dataacc(1:idx) = [];
  end
end


On Wed, Mar 1, 2017 at 11:15 PM, Juan Pablo Carbajal <address@hidden> wrote:
On Wed, Mar 1, 2017 at 6:25 PM, GuiCintraAlves
<address@hidden> wrote:
> No... but went i use
> #!/bin/bash
>  cu -l /dev/ttyACM0 -s 9600
>  $SHELL
>
> It works just like the arduino's serial monitor. I hope it's something
> octave ...
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/Serial-connection-realtime-tp4682072p4682088.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave

more information would be needed to detect what the problem is.
Ideally you could report a bug in the bug tracker.
It seems the serial connection is not being established by the
instrument-control package (I can't reproduce here).

_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave



reply via email to

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