help-octave
[Top][All Lists]
Advanced

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

Re: stroring pointers from oct-files


From: pantxo diribarne
Subject: Re: stroring pointers from oct-files
Date: Sun, 4 Nov 2012 20:20:20 +0100



2012/11/4 Olaf Till <address@hidden>
On Sun, Nov 04, 2012 at 06:55:47PM +0100, pantxo diribarne wrote:
> Hello,
>
> I use octave to comunicate with laboratory hardwares using modbus protocol
> through tcp-ip. The modbus library I use (libmodbus: http://libmodbus.org/)
> returns a pointer the modbus "context" variable and then uses this pointer
> to access the server.
>
> In octave I cast the adress of the pointer to an "int" type, so that I can
> reuse that pointer for subsequent calls to one of modbus read/write
> functions. I then have to free this pointer before exiting octave. Is it
> the righ way to store pointers or is there a proper way to do that?
>
> Pantxo

This could be related to a problem I have written some as yet private
code for, but I'm not sure that I understand you right. Do you pass
the casted pointer to user space (into a variable of the Octave
interpreter)?
 
Right, and there are many functions (oct-files) that rely on that pointer. The typical way I use those functions is :
octave:1> ctx = modbus_new_tcp ("127.0.0.1", 1502); #here ctx is an int containing the adress of the pointer
octave:2> status = modbus_connect (ctx); #connect to the server
octave:3> #read/write data from/to the modbus server
octave:4> modbus_close(ctx); #disconnect
octave:5> modbus_free(ctx); #free the pointer

To avoid passing the pointer to the interpreter I would have to do that process (create/open/close/free) in each of the read/write functions (oct-files).

Pantxo

reply via email to

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