[Top][All Lists]

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

[Octave-patch-tracker] [patch #8263] Instrument control package: add mod

From: Pantxo Diribarne
Subject: [Octave-patch-tracker] [patch #8263] Instrument control package: add modbus capabilities
Date: Sun, 12 Jan 2014 10:52:28 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0

Follow-up Comment #2, patch #8263 (project octave):

Hi Stephan,

Modbus is intrinsically low-level. You can think of it as four tables :
 - two register (16 bits) tables, one (input_registers) is read only 
 - two bits/coils tables, one (input_bits) is read only

There are thus four kinds of read operations and two kinds of write

To access data you have to specify the address of the concerned bit/register.
This prevents to mimic directly the interface of set/get or fread/fwrite as
you propose.

I can think of something like:

a = modbus('','tcp');
%Specify the adresses of bits/registers of interest
set (a, 'bits', 1:4) 
set (a, 'inputbits', 32:45)
ibits = read (a, 'inputbits');
bits = read (a, 'bits');
count = write (a, 'bits', [1 0 0 1]);

Practically, you often want to retrieve/write floats, which are made of two
(not necessarily consecutive) registers. This part is done using
bitget/bitpack functions in octave. For this part of the job I can think of a
something like:

a = modbus('','tcp');
%Specify the adresses through vector -> no conversion
set (a, 'registers', 1:4) 
regs = read (a, 'registers'); % here I get a vector of 4 uint16
%Specify the adresses through n-by-2 matrix -> conversion to floats
set (a, 'registers', [1 2; 3 4]) 
regs = read (a, 'registers'); % here I get a vector of 2 floats, composed
resp. of registers 1-2 and 3-4.
count = write (a, 'registers', [4.2; 2.8]) %each double is cast into a float
and then decomposed into 2 bytes written resp. in 1-2 and 3-4 registers



Reply to this item at:


  Message posté via/par Savannah

reply via email to

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