FieldTalk Modbus® Master Protocol Library C++ Editions |
This class realizes the Modbus RTU master protocol. It provides functions to open and to close serial port as well as data and control functions which can be used at any time after the protocol has been opened. The data and control functions are organized different conformance classes. For a more detailed description of the data and control functions see section Data and Control Functions for all Protocol Flavours.
It is possible to instantiate multiple instances of this class for establishing multiple connections on different serial ports (They should be executed in separate threads).
Specialised Serial Port Management Functions | |
virtual int | openProtocol (const char *const portName, long baudRate, int dataBits, int stopBits, int parity) |
Opens a Modbus RTU protocol and the associated serial port with specific port parameters. | |
virtual int | openProtocol (const char *const portName, long baudRate) |
Opens a Modbus RTU protocol and the associated serial port with default port parameters. | |
Serial Port Management Functions | |
virtual void | closeProtocol () |
Closes the serial port and releases any system resources associated with the port. | |
virtual int | isOpen () |
Returns whether the protocol is open or not. | |
virtual int | enableRs485Mode (int rtsDelay) |
Enables RS485 mode. | |
Class 0 Modbus Functions | |
int | writeMultipleRegisters (int slaveAddr, int startRef, const short regArr[], int refCnt) |
Modbus function 16 (10 hex), Preset Multiple Registers/Write Multiple Registers. | |
int | writeMultipleLongInts (int slaveAddr, int startRef, const long int32Arr[], int refCnt) |
Modbus function 16 (10 hex) for 32-bit long int data types, Preset Multiple Registers/Write Multiple Registers with long int data. | |
int | writeMultipleMod10000 (int slaveAddr, int startRef, const long int32Arr[], int refCnt) |
Modbus function 16 (10 hex) for 32-bit modulo-10000 long int data types, Preset Multiple Registers/Write Multiple Registers with modulo-10000 long int data. | |
int | writeMultipleFloats (int slaveAddr, int startRef, const float float32Arr[], int refCnt) |
Modbus function 16 (10 hex) for 32-bit float data types, Preset Multiple Registers/Write Multiple Registers with float data. | |
int | readMultipleRegisters (int slaveAddr, int startRef, short regArr[], int refCnt) |
Modbus function 3 (03 hex), Read Holding Registers/Read Multiple Registers. | |
int | readMultipleLongInts (int slaveAddr, int startRef, long int32Arr[], int refCnt) |
Modbus function 3 (03 hex) for 32-bit long int data types, Read Holding Registers/Read Multiple Registers as long int data. | |
int | readMultipleMod10000 (int slaveAddr, int startRef, long int32Arr[], int refCnt) |
Modbus function 3 (03 hex) for 32-bit modulo-10000 long int data types, Read Holding Registers/Read Multiple Registers as modulo-10000 long int data. | |
int | readMultipleFloats (int slaveAddr, int startRef, float float32Arr[], int refCnt) |
Modbus function 3 (03 hex) for 32-bit float data types, Read Holding Registers/Read Multiple Registers as float data. | |
Class 1 Modbus Functions | |
int | readCoils (int slaveAddr, int startRef, int bitArr[], int refCnt) |
Modbus function 1 (01 hex), Read Coil Status/Read Coils. | |
int | readInputDiscretes (int slaveAddr, int startRef, int bitArr[], int refCnt) |
Modbus function 2 (02 hex), Read Inputs Status/Read Input Discretes. | |
int | readInputRegisters (int slaveAddr, int startRef, short regArr[], int refCnt) |
Modbus function 4 (04 hex), Read Input Registers. | |
int | readInputLongInts (int slaveAddr, int startRef, long int32Arr[], int refCnt) |
Modbus function 4 (04 hex) for 32-bit long int data types, Read Input Registers as long int data. | |
int | readInputMod10000 (int slaveAddr, int startRef, long int32Arr[], int refCnt) |
Modbus function 4 (04 hex) for 32-bit modulo-10000 long int data types, Read Input Registers as modulo-10000 long int data. | |
int | readInputFloats (int slaveAddr, int startRef, float float32Arr[], int refCnt) |
Modbus function 4 (04 hex) for 32-bit float data types, Read Input Registers as float data. | |
int | writeCoil (int slaveAddr, int bitAddr, int bitVal) |
Modbus function 5 (05 hex), Force Single Coil/Write Coil. | |
int | writeSingleRegister (int slaveAddr, int regAddr, short regVal) |
Modbus function 6 (06 hex), Preset Single Register/Write Single Register. | |
int | readExceptionStatus (int slaveAddr, unsigned char *statusByte) |
Modbus function 7 (07 hex), Read Exception Status. | |
Class 2 Modbus Functions | |
int | forceMultipleCoils (int slaveAddr, int startRef, const int bitArr[], int refCnt) |
Modbus function 15 (0F hex), Force Multiple Coils. | |
int | maskWriteRegister (int slaveAddr, int regAddr, unsigned short andMask, unsigned short orMask) |
Modbus function 22 (16 hex), Mask Write Register. | |
int | readWriteRegisters (int slaveAddr, int readRef, short readArr[], int readCnt, int writeRef, const short writeArr[], int writeCnt) |
Modbus function 23 (17 hex), Read/Write Registers. | |
Protocol Configuration | |
int | setTimeout (int timeOut) |
Configures time-out. | |
int | getTimeout () |
Returns the time-out value. | |
int | setPollDelay (int pollDelay) |
Configures poll delay. | |
int | getPollDelay () |
Returns the poll delay time. | |
int | setRetryCnt (int retryCnt) |
Configures the automatic retry setting. | |
int | getRetryCnt () |
Returns the automatic retry count. | |
Transmission Statistic Functions | |
unsigned long | getTotalCounter () |
Returns how often a message transfer has been executed. | |
void | resetTotalCounter () |
Resets total message transfer counter. | |
unsigned long | getSuccessCounter () |
Returns how often a message transfer was successful. | |
void | resetSuccessCounter () |
Resets successful message transfer counter. | |
Word Order Configuration | |
void | configureBigEndianInts () |
Configures int data type functions to do a word swap. | |
void | configureSwappedFloats () |
Configures float data type functions to do a word swap. | |
void | configureLittleEndianInts () |
Configures int data type functions not to do a word swap. | |
void | configureIeeeFloats () |
Configures float data type functions not to do a word swap. | |
Public Types | |
enum | { SER_DATABITS_7 = SerialPort::SER_DATABITS_7, SER_DATABITS_8 = SerialPort::SER_DATABITS_8 } |
enum | { SER_STOPBITS_1 = SerialPort::SER_STOPBITS_1, SER_STOPBITS_2 = SerialPort::SER_STOPBITS_2 } |
enum | { SER_PARITY_NONE = SerialPort::SER_PARITY_NONE, SER_PARITY_EVEN = SerialPort::SER_PARITY_EVEN, SER_PARITY_ODD = SerialPort::SER_PARITY_ODD } |
Public Member Functions | |
MbusRtuMasterProtocol () | |
Constructs a MbusRtuMasterProtocol object and initialises its data. | |
Static Public Member Functions | |
char * | getPackageVersion () |
Returns the package version number. | |
Protected Types | |
enum | { SER_RS232, SER_RS485 } |
|
|
|
|
|
|
|
|
|
Opens a Modbus RTU protocol and the associated serial port with specific port parameters. This function opens the serial port. After a port has been opened, data and control functions can be used.
Reimplemented from MbusSerialMasterProtocol. |
|
Opens a Modbus RTU protocol and the associated serial port with default port parameters. This function opens the serial port with 8 databits, 1 stopbit and no parity. After a port has been opened, data and control functions can be used.
Reimplemented from MbusSerialMasterProtocol. |
|
Returns whether the protocol is open or not.
Reimplemented from MbusMasterFunctions. |
|
Enables RS485 mode. In RS485 mode the RTS signal can be used to enable and disable the transmitter of a RS232/RS485 converter. The RTS signal is asserted before sending data. It is cleared after the transmit buffer has been emptied and in addition the specified delay time has elapsed. The delay time is necessary because even the transmit buffer is already empty, the UART's FIFO will still contain unsent characters.
|
Copyright © 2002-2004
FOCUS Software Engineering Pty Ltd, Australia.
All rights reserved.
Please see the Notices page for trademark notices. Last updated: 26 May 2004 |