[Top][All Lists]

[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: Tue, 6 Nov 2012 09:25:07 +0100

2012/11/5 c. <address@hidden>

On 5 Nov 2012, at 13:11, pantxo diribarne wrote:

> Instrument-control package provides interfaces to serial/parallel/i2c ports, wich is far not enough to talk to a modbus device (or libmodbus author has created an empty lib :-). I need the protocol layer and it works very well with libmodbus.
> Do I really have to define an octave class (following e.g. Instrument-control classes example), or is the static variable solution viable (and safe)?
I think using an Octave class would be cleaner and safer, but if the static variable approach works and you are more confortable with it, just go for it.
This approach works very well : as initially suggested by Olaf, I wrote the whole function set in a single cpp file, and used a std::map<std::string, modbus_t *> to store the pointers to my modbus context(s) indexed by std::string key(s). I just don't know wether the memory is freed (it was allocated through libmodbus) when I quit Octave without calling modbus_free, or wether it results in a memory leak.      

> BTW I tried to put multiple DEFUN_DLD in the same file, it compiles fine but if I run octave in the corresponding directory, DLD functions don't seem to be defined. What is the trick here?
whenevere you have a function that is defined in an oct file with a name that does not coincide with the function name,
you need to use the autoload command to tell the Octave interpreter which file to load it from, e.g:

autoload ("foo", "bar.oct");
Thanck you for the tip(s)!


reply via email to

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