Oct File Access Array Elements

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Oct File Access Array Elements

Thomas D. Dean-2
I have an application that calls a C library function to get a list of
values.  These values are uint8_t.  The function call seems to work OK,
but, I am having problems getting the data back to octave.

    A = mufunc()

After reading the source code and the docs, I believe

        dim_vector dv(1, 2);
        dv(0) = 1;
        dv(1) = 2048;
        uint8NDArray out(dv);

is the best definition to do this.

The code that reads the device and returns values to octave is:

         OCTAVE_LOCAL_BUFFER (double, dev_dat, 2048)
         rc = read_dev(dev, dev_dat)
         copy data into out  --- how?
         ...
         return octave_value(out);


How do I either use the array out in the call to read_dev or iterate and
copy the values from dev_dat into out?

How do I assign values to members of the uint8NDArray out?

Or, better, how do I pass the uint8NDArray into the call to read_dev()?

Tom Dean


Reply | Threaded
Open this post in threaded view
|

Re: Oct File Access Array Elements

Thomas D. Dean-2
On 8/2/19 10:01 PM, Thomas D. Dean wrote:

> I have an application that calls a C library function to get a list of
> values.  These values are uint8_t.  The function call seems to work OK,
> but, I am having problems getting the data back to octave.
>
>     A = mufunc()
>
> After reading the source code and the docs, I believe
>
>      dim_vector dv(1, 2);
>      dv(0) = 1;
>      dv(1) = 2048;
>      uint8NDArray out(dv);
>
> is the best definition to do this.
>
> The code that reads the device and returns values to octave is:
>
>          OCTAVE_LOCAL_BUFFER (double, dev_dat, 2048)
>          rc = read_dev(dev, dev_dat)
>          copy data into out  --- how?
>          ...
>          return octave_value(out);
>
>

Again, it seems I hollered before I was hurt.  direct assignment works.

    out(idx) = dev_dat[idx]