./
modbus__define.pro
Class description for MODBUS
Properties
- Port init
- Host init
Fields
- PORT 0S
- HOST ''
- TID 0L
Routines
result = MODBUS::INIT( [Host=Host] [, Port=Port])This function is used to choose connection settings for a newly created modbus TCP connection.
MODBUS::Set [, Port=Port] [, Host=Host]This procedure allows us to change the Host and Port an existing MODBUS connection will connect to.
result = MODBUS::Get( [PORT=PORT] [, HOST=HOST] [, TID=TID])This function/procedure allows to read the internal state of a MODBUS object.
MODBUS::Get, Port=Port, Host=Host, Tid=Tidresult = MODBUS::Header(Command)This function adds a modbus TCP header to a byte-array containing a specific Command.
MODBUS::Error, Errno, Func [, Errmsg=Errmsg]This procedure prints a MODBUS error message.
result = MODBUS::WriteMultReg(Addr, Regs)This function writes a block of contiguous registers to a modbus device (socket).
result = MODBUS::ReadInputReg(Addr, NumRegs)This function reads 1-125 contiguous input registers from a modbus device (socket).
MODBUS__DEFINE
Routine details
topMODBUS::INIT
result = MODBUS::INIT( [Host=Host] [, Port=Port])
This function is used to choose connection settings for a newly created modbus TCP connection.
This function is only to be called from OBJ_NEW().
Return value
This function is only used inside OBJ_NEW(), which will then return a new MODBUS object.
Keywords
- Host in optional
The DNS-name of the modbus SPS.
- Port in optional
The TCP port of the modbus SPS.
Statistics
| Lines: | 5 |
| McCabe complexity: |
topMODBUS::Set
MODBUS::Set [, Port=Port] [, Host=Host]
This procedure allows us to change the Host and Port an existing MODBUS connection will connect to.
This procedure changes the Host and Port stored inside the MODBUS object.
Keywords
- Port in optional
The TCP port of the modbus SPS.
- Host in optional
The DNS-name of the modbus SPS.
Examples
Modbus = OBJ_NEW("MODBUS")
Modbus->Set, Port=499
Statistics
| Lines: | 4 |
| McCabe complexity: |
topMODBUS::Get
result = MODBUS::Get( [PORT=PORT] [, HOST=HOST] [, TID=TID])
This function/procedure allows to read the internal state of a MODBUS object. The function can return only one of HOST, PORT or TID --- if more than one keyword parameter is specified, only the Host (or, if that one wasn't requested, the Port) will be returned.
Return value
The function returns the first requested value (in the order HOST, PORT, TID).
Keywords
- PORT in optional
The TCP port of the modbus SPS.
- HOST in optional
The DNS-name of the modbus SPS.
- TID in optional
The last transaction id used.
Examples
Modbus = OBJ_NEW("MODBUS")
Port = Modbus->Get(/PORT)
Modbus->Get(Host=Host)
Statistics
| Lines: | 5 |
| McCabe complexity: |
topMODBUS::Get
MODBUS::Get, Port=Port, Host=Host, Tid=Tid
Keywords
- Port
- Host
- Tid
Statistics
| Lines: | 5 |
| McCabe complexity: |
topMODBUS::Header
result = MODBUS::Header(Command)
This function adds a modbus TCP header to a byte-array containing a specific Command.
This function increases self.tid, the objects transaction id, by one.
Return value
This function returns the Command with a prefixed modbus header.
Parameters
- Command in required
a byte array containing (Function, Address, Arguments).
Statistics
| Lines: | 11 |
| McCabe complexity: |
topMODBUS::Error
MODBUS::Error, Errno, Func [, Errmsg=Errmsg]
This procedure prints a MODBUS error message.
Parameters
- Errno in required
Number of standard error-message.
- Func in required
Name of calling function.
Keywords
- Errmsg in optional
Special error-message to print.
Statistics
| Lines: | 11 |
| McCabe complexity: |
topMODBUS::WriteMultReg
result = MODBUS::WriteMultReg(Addr, Regs)
This function writes a block of contiguous registers to a modbus device (socket).
Regs: has to be an even number of bytes, and at most 246 Bytes (123 WORDs)
Return value
This function outputs the reply sent by the MODBUS-device
Parameters
- Addr in required
(16bit) Starting address of registers to write
- Regs in required
String of HEX-values to send (HiLo-encoded)
Examples
; Enable Device
Modbus = OBJ_NEW("MODBUS")
print, Modbus->WriteMultReg('4020'XL, [0B,1B])
Statistics
| Lines: | 50 |
| McCabe complexity: |
topMODBUS::ReadInputReg
result = MODBUS::ReadInputReg(Addr, NumRegs)
This function reads 1-125 contiguous input registers from a modbus device (socket).
NumRegs: has to be a number between 0 and 125 Words (250 Bytes).
Return value
The function returns the reply sent by the MODBUS-device.
Parameters
- Addr in required
(16bit) Starting address of registers to read
- NumRegs in required
How many registers to read.
Examples
; Read complete set of registers (20 Bytes)
Modbus = OBJ_NEW("MODBUS")
print, Modbus->ReadInputReg('4020'XL, 10)
Statistics
| Lines: | 46 |
| McCabe complexity: |
File attributes
| Modification date: | Wed Jul 1 13:47:05 2009 |
| Lines: | 313 |
![[attach.png]](idldoc-resources/attach.png)