├── Doxyfile ├── LICENSE.md ├── ModbusRtu.cpp ├── ModbusRtu.h ├── README.md ├── config ├── documentation ├── html │ ├── _modbus_rtu_8h.html │ ├── _modbus_rtu_8h_source.html │ ├── annotated.html │ ├── bc_s.png │ ├── bdwn.png │ ├── class_modbus-members.html │ ├── class_modbus.html │ ├── classes.html │ ├── closed.png │ ├── doxygen.css │ ├── doxygen.png │ ├── dynsections.js │ ├── files.html │ ├── ftv2blank.png │ ├── ftv2cl.png │ ├── ftv2doc.png │ ├── ftv2folderclosed.png │ ├── ftv2folderopen.png │ ├── ftv2lastnode.png │ ├── ftv2link.png │ ├── ftv2mlastnode.png │ ├── ftv2mnode.png │ ├── ftv2mo.png │ ├── ftv2node.png │ ├── ftv2ns.png │ ├── ftv2plastnode.png │ ├── ftv2pnode.png │ ├── ftv2splitbar.png │ ├── ftv2vertline.png │ ├── functions.html │ ├── functions_func.html │ ├── functions_vars.html │ ├── globals.html │ ├── globals_defs.html │ ├── globals_enum.html │ ├── globals_eval.html │ ├── globals_vars.html │ ├── group__buffer.html │ ├── group__discrete.html │ ├── group__loop.html │ ├── group__register.html │ ├── group__setup.html │ ├── index.hhc │ ├── index.hhk │ ├── index.hhp │ ├── index.html │ ├── modules.html │ ├── nav_f.png │ ├── nav_g.png │ ├── nav_h.png │ ├── open.png │ ├── pages.html │ ├── structmodbus__t-members.html │ ├── structmodbus__t.html │ ├── sync_off.png │ ├── sync_on.png │ ├── tab_a.png │ ├── tab_b.png │ ├── tab_h.png │ ├── tab_s.png │ ├── tabs.css │ └── todo.html ├── latex │ ├── Makefile │ ├── _modbus_rtu_8h.tex │ ├── annotated.tex │ ├── class_modbus.tex │ ├── doxygen.sty │ ├── files.tex │ ├── group__buffer.tex │ ├── group__discrete.tex │ ├── group__loop.tex │ ├── group__register.tex │ ├── group__setup.tex │ ├── modules.tex │ ├── refman.tex │ ├── structmodbus__t.tex │ └── todo.tex └── rtf │ └── refman.rtf ├── examples ├── RS485_slave │ └── RS485_slave.ino ├── advanced_master │ └── advanced_master.ino ├── advanced_slave │ └── advanced_slave.ino ├── simple_master │ └── simple_master.ino ├── simple_slave │ └── simple_slave.ino ├── simple_slave2 │ └── simple_slave2.ino └── software_serial_simple_master │ └── software_serial_simple_master.ino └── keywords.txt /ModbusRtu.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ModbusRtu.h 3 | * @version 1.21 4 | * @date 2016.02.21 5 | * @author Samuel Marco i Armengol 6 | * @contact sammarcoarmengol@gmail.com 7 | * @contribution Helium6072 8 | * @contribution gabrielsan 9 | * 10 | * @description 11 | * Arduino library for communicating with Modbus devices 12 | * over RS232/USB/485 via RTU protocol. 13 | * 14 | * Further information: 15 | * http://modbus.org/ 16 | * http://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf 17 | * 18 | * @license 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; version 22 | * 2.1 of the License. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library; if not, write to the Free Software 31 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 32 | * 33 | * @defgroup setup Modbus Object Instantiation/Initialization 34 | * @defgroup loop Modbus Object Management 35 | * @defgroup buffer Modbus Buffer Management 36 | * @defgroup discrete Modbus Function Codes for Discrete Coils/Inputs 37 | * @defgroup register Modbus Function Codes for Holding/Input Registers 38 | * 39 | */ 40 | 41 | #ifndef MODBUS_RTU_H 42 | #define MODBUS_RTU_H 43 | 44 | #include 45 | #include "Arduino.h" 46 | 47 | 48 | /** 49 | * @struct modbus_t 50 | * @brief 51 | * Master query structure: 52 | * This includes all the necessary fields to make the Master generate a Modbus query. 53 | * A Master may keep several of these structures and send them cyclically or 54 | * use them according to program needs. 55 | */ 56 | typedef struct 57 | { 58 | uint8_t u8id; /*!< Slave address between 1 and 247. 0 means broadcast */ 59 | uint8_t u8fct; /*!< Function code: 1, 2, 3, 4, 5, 6, 15 or 16 */ 60 | uint16_t u16RegAdd; /*!< Address of the first register to access at slave/s */ 61 | uint16_t u16CoilsNo; /*!< Number of coils or registers to access */ 62 | uint16_t *au16reg; /*!< Pointer to memory image in master */ 63 | } 64 | modbus_t; 65 | 66 | enum 67 | { 68 | RESPONSE_SIZE = 6, 69 | EXCEPTION_SIZE = 3, 70 | CHECKSUM_SIZE = 2 71 | }; 72 | 73 | /** 74 | * @enum MESSAGE 75 | * @brief 76 | * Indexes to telegram frame positions 77 | */ 78 | enum MESSAGE 79 | { 80 | ID = 0, //!< ID field 81 | FUNC, //!< Function code position 82 | ADD_HI, //!< Address high byte 83 | ADD_LO, //!< Address low byte 84 | NB_HI, //!< Number of coils or registers high byte 85 | NB_LO, //!< Number of coils or registers low byte 86 | BYTE_CNT //!< byte counter 87 | }; 88 | 89 | /** 90 | * @enum MB_FC 91 | * @brief 92 | * Modbus function codes summary. 93 | * These are the implement function codes either for Master or for Slave. 94 | * 95 | * @see also fctsupported 96 | * @see also modbus_t 97 | */ 98 | enum MB_FC 99 | { 100 | MB_FC_NONE = 0, /*!< null operator */ 101 | MB_FC_READ_COILS = 1, /*!< FCT=1 -> read coils or digital outputs */ 102 | MB_FC_READ_DISCRETE_INPUT = 2, /*!< FCT=2 -> read digital inputs */ 103 | MB_FC_READ_REGISTERS = 3, /*!< FCT=3 -> read registers or analog outputs */ 104 | MB_FC_READ_INPUT_REGISTER = 4, /*!< FCT=4 -> read analog inputs */ 105 | MB_FC_WRITE_COIL = 5, /*!< FCT=5 -> write single coil or output */ 106 | MB_FC_WRITE_REGISTER = 6, /*!< FCT=6 -> write single register */ 107 | MB_FC_WRITE_MULTIPLE_COILS = 15, /*!< FCT=15 -> write multiple coils or outputs */ 108 | MB_FC_WRITE_MULTIPLE_REGISTERS = 16 /*!< FCT=16 -> write multiple registers */ 109 | }; 110 | 111 | enum COM_STATES 112 | { 113 | COM_IDLE = 0, 114 | COM_WAITING = 1 115 | 116 | }; 117 | 118 | enum ERR_LIST 119 | { 120 | ERR_NOT_MASTER = -1, 121 | ERR_POLLING = -2, 122 | ERR_BUFF_OVERFLOW = -3, 123 | ERR_BAD_CRC = -4, 124 | ERR_EXCEPTION = -5 125 | }; 126 | 127 | enum 128 | { 129 | NO_REPLY = 255, 130 | EXC_FUNC_CODE = 1, 131 | EXC_ADDR_RANGE = 2, 132 | EXC_REGS_QUANT = 3, 133 | EXC_EXECUTE = 4 134 | }; 135 | 136 | const unsigned char fctsupported[] = 137 | { 138 | MB_FC_READ_COILS, 139 | MB_FC_READ_DISCRETE_INPUT, 140 | MB_FC_READ_REGISTERS, 141 | MB_FC_READ_INPUT_REGISTER, 142 | MB_FC_WRITE_COIL, 143 | MB_FC_WRITE_REGISTER, 144 | MB_FC_WRITE_MULTIPLE_COILS, 145 | MB_FC_WRITE_MULTIPLE_REGISTERS 146 | }; 147 | 148 | #define T35 5 149 | #define MAX_BUFFER 64 //!< maximum size for the communication buffer in bytes 150 | 151 | /** 152 | * @class Modbus 153 | * @brief 154 | * Arduino class library for communicating with Modbus devices over 155 | * USB/RS232/485 (via RTU protocol). 156 | */ 157 | class Modbus 158 | { 159 | private: 160 | Stream *port; //!< Pointer to Stream class object (Either HardwareSerial or SoftwareSerial) 161 | uint8_t u8id; //!< 0=master, 1..247=slave number 162 | uint8_t u8txenpin; //!< flow control pin: 0=USB or RS-232 mode, >1=RS-485 mode 163 | uint8_t u8state; 164 | uint8_t u8lastError; 165 | uint8_t au8Buffer[MAX_BUFFER]; 166 | uint8_t u8BufferSize; 167 | uint8_t u8lastRec; 168 | uint16_t *au16regs; 169 | uint16_t u16InCnt, u16OutCnt, u16errCnt; 170 | uint16_t u16timeOut; 171 | uint32_t u32time, u32timeOut, u32overTime; 172 | uint8_t u8regsize; 173 | 174 | void sendTxBuffer(); 175 | int8_t getRxBuffer(); 176 | uint16_t calcCRC(uint8_t u8length); 177 | uint8_t validateAnswer(); 178 | uint8_t validateRequest(); 179 | void get_FC1(); 180 | void get_FC3(); 181 | int8_t process_FC1( uint16_t *regs, uint8_t u8size ); 182 | int8_t process_FC3( uint16_t *regs, uint8_t u8size ); 183 | int8_t process_FC5( uint16_t *regs, uint8_t u8size ); 184 | int8_t process_FC6( uint16_t *regs, uint8_t u8size ); 185 | int8_t process_FC15( uint16_t *regs, uint8_t u8size ); 186 | int8_t process_FC16( uint16_t *regs, uint8_t u8size ); 187 | void buildException( uint8_t u8exception ); // build exception message 188 | 189 | public: 190 | Modbus(uint8_t u8id, Stream& port, uint8_t u8txenpin =0); 191 | 192 | void start(); 193 | void setTimeOut( uint16_t u16timeOut); //! 217 | void begin(T_Stream* port_, long u32speed_) __attribute__((deprecated)); 218 | 219 | // Deprecated: Use "start()" instead. 220 | template 221 | void begin(T_Stream* port_, long u32speed_, uint8_t u8txenpin_) __attribute__((deprecated)); 222 | 223 | // Deprecated: Use "start()" instead. 224 | void begin(long u32speed = 19200) __attribute__((deprecated)); 225 | }; 226 | 227 | #endif // MODBUS_RTU_H 228 | 229 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | README.txt 2 | 3 | libmodbus is a library that provides a Serial Modbus implementation for Arduino. 4 | 5 | A primary goal was to enable industrial communication for the Arduino in order to link it to industrial devices such as HMIs, CNCs, PLCs, temperature regulators or speed drives. 6 | 7 | now you can use software serial with the update from Helium6072! 8 | 9 | LIBRARY CONTENTS 10 | ================================================================= 11 | LICENSE.txt GNU Licence file 12 | keywords.txt Arduino IDE colouring syntax 13 | 14 | /documentation 15 | Library documentation generated with Doxygen. 16 | 17 | /examples 18 | Sample sketches to implement miscellaneous settings: 19 | 20 | /examples/advanced_slave Modbus slave node, which links Arduino pins to the Modbus port. 21 | /examples/RS485_slave Modbus slave adapted to the RS485 port 22 | /examples/simple_master Modbus master node with a single query 23 | /examples/simple_slave Modbus slave node with a link array 24 | /examples/software_serial_simple_master Modbus master node that works via software serial 25 | 26 | INSTALLATION PROCEDURE 27 | ================================================================= 28 | Refer to this documentation to Install this library: 29 | 30 | http://arduino.cc/en/Guide/Libraries 31 | 32 | Starting with version 1.0.5, you can install 3rd party libraries in the IDE. 33 | 34 | Do not unzip the downloaded library, leave it as is. 35 | 36 | In the Arduino IDE, navigate to Sketch > Import Library. At the top of the drop down list, select the option to "Add Library". 37 | 38 | You will be prompted to select this zipped library. 39 | 40 | Return to the Sketch > Import Library menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. 41 | 42 | The zip file will have been expanded in the libraries folder in your Arduino sketches directory. 43 | 44 | NB : the library will be available to use in sketches, but examples for the library will not be exposed in the File > Examples until after the IDE has restarted. 45 | 46 | 47 | KNOWN ISSUES 48 | ================================================================= 49 | It is not compatible with ARDUINO LEONARDO and not tested under ARDUINO DUE and newer boards. 50 | 51 | TODO List 52 | ================================================================= 53 | Common to Master and Slave: 54 | 55 | 1) Implement other Serial settings: parity, stop bits, ... 56 | 57 | 2) End frame delay, also known as T35 58 | 59 | 3) Test it with several Arduino boards: UNO, Mega, etc.. 60 | 61 | 4) Extend it to Leonardo 62 | 63 | Master: 64 | 65 | 1) Function code 1 and 2 still not implemented 66 | 67 | 2) Function code 15 still not implement 68 | 69 | 3) Other codes under development 70 | 71 | New features by Helium6072 29 July 2016 72 | ================================================================= 73 | 1) "port->flush();" changed into "while(port->read() >= 0);" 74 | 75 | Since Serial.flush() (port->flush(); in ModbusRtu.h line 287, 337, & 827) no longer empties incoming buffer on 1.6 (Arduino.cc : flush() "Waits for the transmission of outgoing serial data to complete. Prior to Arduino 1.0, this instead removed any buffered incoming serial data.), use "while(port->read() >= 0);" instead. 76 | 77 | 2) software serial compatible 78 | 79 | New constructor Modbus::Modbus(uint8_t u8id) and method void Modbus::begin(SoftwareSerial *sPort, long u32speed) that makes using software serial possible. 80 | Check out sexample "software_serial_simple_master" and learn more! -------------------------------------------------------------------------------- /documentation/html/annotated.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Class List 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 47 |
48 |
49 |
50 |
Class List
51 |
52 |
53 |
Here are the classes, structs, unions and interfaces with brief descriptions:
54 | 55 | 56 | 57 |
oCModbusArduino class library for communicating with Modbus devices over USB/RS232/485 (via RTU protocol)
\Cmodbus_tMaster query structure: This includes all the necessary fields to make the Master generate a Modbus query. A Master may keep several of these structures and send them cyclically or use them according to program needs
58 |
59 |
60 | 61 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /documentation/html/bc_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/bc_s.png -------------------------------------------------------------------------------- /documentation/html/bdwn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/bdwn.png -------------------------------------------------------------------------------- /documentation/html/class_modbus-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Member List 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 47 |
48 |
49 |
50 |
Modbus Member List
51 |
52 |
53 | 54 |

This is the complete list of members for Modbus, including all inherited members.

55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 |
begin(long u32speed)Modbus
begin()Modbus
end()Modbus
getErrCnt()Modbus
getID()Modbus
getInCnt()Modbus
getLastError()Modbus
getOutCnt()Modbus
getState()Modbus
getTimeOut()Modbus
getTimeOutState()Modbus
Modbus()Modbus
Modbus(uint8_t u8id, uint8_t u8serno)Modbus
Modbus(uint8_t u8id, uint8_t u8serno, uint8_t u8txenpin)Modbus
poll()Modbus
poll(uint16_t *regs, uint8_t u8size)Modbus
query(modbus_t telegram)Modbus
setID(uint8_t u8id)Modbus
setTimeOut(uint16_t u16timeout)Modbus
76 | 77 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /documentation/html/classes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Class Index 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 47 |
48 |
49 |
50 |
Class Index
51 |
52 |
53 | 54 | 55 | 57 | 58 | 59 | 60 |
  M  
56 |
modbus_t   
Modbus   
61 | 62 |
63 | 64 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /documentation/html/closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/closed.png -------------------------------------------------------------------------------- /documentation/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/doxygen.png -------------------------------------------------------------------------------- /documentation/html/dynsections.js: -------------------------------------------------------------------------------- 1 | function toggleVisibility(linkObj) 2 | { 3 | var base = $(linkObj).attr('id'); 4 | var summary = $('#'+base+'-summary'); 5 | var content = $('#'+base+'-content'); 6 | var trigger = $('#'+base+'-trigger'); 7 | var src=$(trigger).attr('src'); 8 | if (content.is(':visible')===true) { 9 | content.hide(); 10 | summary.show(); 11 | $(linkObj).addClass('closed').removeClass('opened'); 12 | $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); 13 | } else { 14 | content.show(); 15 | summary.hide(); 16 | $(linkObj).removeClass('closed').addClass('opened'); 17 | $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); 18 | } 19 | return false; 20 | } 21 | 22 | function updateStripes() 23 | { 24 | $('table.directory tr'). 25 | removeClass('even').filter(':visible:even').addClass('even'); 26 | } 27 | function toggleLevel(level) 28 | { 29 | $('table.directory tr').each(function(){ 30 | var l = this.id.split('_').length-1; 31 | var i = $('#img'+this.id.substring(3)); 32 | var a = $('#arr'+this.id.substring(3)); 33 | if (l 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: File List 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 46 |
47 |
48 |
49 |
File List
50 |
51 |
52 |
Here is a list of all files with brief descriptions:
53 | 54 | 55 |
\*ModbusRtu.h
56 |
57 |
58 | 59 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /documentation/html/ftv2blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2blank.png -------------------------------------------------------------------------------- /documentation/html/ftv2cl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2cl.png -------------------------------------------------------------------------------- /documentation/html/ftv2doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2doc.png -------------------------------------------------------------------------------- /documentation/html/ftv2folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2folderclosed.png -------------------------------------------------------------------------------- /documentation/html/ftv2folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2folderopen.png -------------------------------------------------------------------------------- /documentation/html/ftv2lastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2lastnode.png -------------------------------------------------------------------------------- /documentation/html/ftv2link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2link.png -------------------------------------------------------------------------------- /documentation/html/ftv2mlastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2mlastnode.png -------------------------------------------------------------------------------- /documentation/html/ftv2mnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2mnode.png -------------------------------------------------------------------------------- /documentation/html/ftv2mo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2mo.png -------------------------------------------------------------------------------- /documentation/html/ftv2node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2node.png -------------------------------------------------------------------------------- /documentation/html/ftv2ns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2ns.png -------------------------------------------------------------------------------- /documentation/html/ftv2plastnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2plastnode.png -------------------------------------------------------------------------------- /documentation/html/ftv2pnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2pnode.png -------------------------------------------------------------------------------- /documentation/html/ftv2splitbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2splitbar.png -------------------------------------------------------------------------------- /documentation/html/ftv2vertline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/ftv2vertline.png -------------------------------------------------------------------------------- /documentation/html/functions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Class Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 47 | 54 |
55 |
56 |
Here is a list of all class members with links to the classes they belong to:
    57 |
  • au16reg 58 | : modbus_t 59 |
  • 60 |
  • begin() 61 | : Modbus 62 |
  • 63 |
  • end() 64 | : Modbus 65 |
  • 66 |
  • getErrCnt() 67 | : Modbus 68 |
  • 69 |
  • getID() 70 | : Modbus 71 |
  • 72 |
  • getInCnt() 73 | : Modbus 74 |
  • 75 |
  • getLastError() 76 | : Modbus 77 |
  • 78 |
  • getOutCnt() 79 | : Modbus 80 |
  • 81 |
  • getState() 82 | : Modbus 83 |
  • 84 |
  • getTimeOut() 85 | : Modbus 86 |
  • 87 |
  • getTimeOutState() 88 | : Modbus 89 |
  • 90 |
  • Modbus() 91 | : Modbus 92 |
  • 93 |
  • poll() 94 | : Modbus 95 |
  • 96 |
  • query() 97 | : Modbus 98 |
  • 99 |
  • setID() 100 | : Modbus 101 |
  • 102 |
  • setTimeOut() 103 | : Modbus 104 |
  • 105 |
  • u16CoilsNo 106 | : modbus_t 107 |
  • 108 |
  • u16RegAdd 109 | : modbus_t 110 |
  • 111 |
  • u8fct 112 | : modbus_t 113 |
  • 114 |
  • u8id 115 | : modbus_t 116 |
  • 117 |
118 |
119 | 120 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /documentation/html/functions_func.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Class Members - Functions 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 47 | 54 |
55 |
56 |  
    57 |
  • begin() 58 | : Modbus 59 |
  • 60 |
  • end() 61 | : Modbus 62 |
  • 63 |
  • getErrCnt() 64 | : Modbus 65 |
  • 66 |
  • getID() 67 | : Modbus 68 |
  • 69 |
  • getInCnt() 70 | : Modbus 71 |
  • 72 |
  • getLastError() 73 | : Modbus 74 |
  • 75 |
  • getOutCnt() 76 | : Modbus 77 |
  • 78 |
  • getState() 79 | : Modbus 80 |
  • 81 |
  • getTimeOut() 82 | : Modbus 83 |
  • 84 |
  • getTimeOutState() 85 | : Modbus 86 |
  • 87 |
  • Modbus() 88 | : Modbus 89 |
  • 90 |
  • poll() 91 | : Modbus 92 |
  • 93 |
  • query() 94 | : Modbus 95 |
  • 96 |
  • setID() 97 | : Modbus 98 |
  • 99 |
  • setTimeOut() 100 | : Modbus 101 |
  • 102 |
103 |
104 | 105 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /documentation/html/functions_vars.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Class Members - Variables 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 47 | 54 |
55 |
56 |   73 |
74 | 75 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /documentation/html/globals.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: File Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 46 | 55 | 69 |
70 |
71 |
Here is a list of all file members with links to the files they belong to:
72 | 73 |

- a -

81 | 82 | 83 |

- b -

88 | 89 | 90 |

- c -

104 | 105 | 106 |

- e -

141 | 142 | 143 |

- f -

151 | 152 | 153 |

- i -

158 | 159 | 160 |

- m -

198 | 199 | 200 |

- n -

211 | 212 | 213 |

- r -

218 | 219 | 220 |

- t -

225 |
226 | 227 | 232 | 233 | 234 | -------------------------------------------------------------------------------- /documentation/html/globals_defs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: File Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 46 | 55 |
56 |
57 |   65 |
66 | 67 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /documentation/html/globals_enum.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: File Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 46 | 55 |
56 |
57 |   71 |
72 | 73 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /documentation/html/globals_eval.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: File Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 46 | 55 | 68 |
69 |
70 |   71 | 72 |

- a -

80 | 81 | 82 |

- b -

87 | 88 | 89 |

- c -

100 | 101 | 102 |

- e -

134 | 135 | 136 |

- f -

141 | 142 | 143 |

- i -

148 | 149 | 150 |

- m -

179 | 180 | 181 |

- n -

192 | 193 | 194 |

- r -

199 |
200 | 201 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /documentation/html/globals_vars.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: File Members 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 46 | 55 |
56 |
57 |   62 |
63 | 64 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /documentation/html/group__buffer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Modbus Buffer Management 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 |
41 |
42 |
43 | Functions
44 |
45 |
Modbus Buffer Management
46 |
47 |
48 | 49 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |

50 | Functions

uint16_t Modbus::getInCnt ()
 number of incoming messages More...
 
uint16_t Modbus::getOutCnt ()
 number of outcoming messages More...
 
uint16_t Modbus::getErrCnt ()
 error counter More...
 
uint8_t Modbus::getState ()
 
uint8_t Modbus::getLastError ()
 get last error message More...
 
66 |

Detailed Description

67 |

Function Documentation

68 | 69 |
70 |
71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |
uint16_t Modbus::getErrCnt ()
79 |
80 | 81 |

error counter

82 |

Get errors counter value This can be useful to diagnose communication.

83 |
Returns
errors counter
84 | 85 |

Definition at line 386 of file ModbusRtu.h.

86 | 87 |
88 |
89 | 90 |
91 |
92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
uint16_t Modbus::getInCnt ()
100 |
101 | 102 |

number of incoming messages

103 |

Get input messages counter value This can be useful to diagnose communication.

104 |
Returns
input messages counter
105 | 106 |

Definition at line 362 of file ModbusRtu.h.

107 | 108 |
109 |
110 | 111 |
112 |
113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 |
uint8_t Modbus::getLastError ()
121 |
122 | 123 |

get last error message

124 |

Get the last error in the protocol processor

125 |

NO_REPLY = 255 Time-out

126 |
Returns
EXC_FUNC_CODE = 1 Function code not available
127 |
128 | EXC_ADDR_RANGE = 2 Address beyond available space for Modbus registers
129 |
130 | EXC_REGS_QUANT = 3 Coils or registers number beyond the available space
131 | 132 |

Definition at line 409 of file ModbusRtu.h.

133 | 134 |
135 |
136 | 137 |
138 |
139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 |
uint16_t Modbus::getOutCnt ()
147 |
148 | 149 |

number of outcoming messages

150 |

Get transmitted messages counter value This can be useful to diagnose communication.

151 |
Returns
transmitted messages counter
152 | 153 |

Definition at line 374 of file ModbusRtu.h.

154 | 155 |
156 |
157 | 158 |
159 |
160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
uint8_t Modbus::getState ()
168 |
169 |

Get modbus master state

170 |
Returns
= 0 IDLE, = 1 WAITING FOR ANSWER
171 | 172 |

Definition at line 396 of file ModbusRtu.h.

173 | 174 |
175 |
176 |
177 | 178 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /documentation/html/group__discrete.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Modbus Function Codes for Discrete Coils/Inputs 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 |
41 |
42 |
43 |
Modbus Function Codes for Discrete Coils/Inputs
44 |
45 |
46 |

Detailed Description

47 |
48 | 49 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /documentation/html/group__loop.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Modbus Object Management 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 |
41 |
42 |
43 | Functions
44 |
45 |
Modbus Object Management
46 |
47 |
48 | 49 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |

50 | Functions

boolean Modbus::getTimeOutState ()
 get communication watch-dog timer state More...
 
int8_t Modbus::query (modbus_t telegram)
 only for master More...
 
int8_t Modbus::poll ()
 cyclic poll for master More...
 
int8_t Modbus::poll (uint16_t *regs, uint8_t u8size)
 cyclic poll for slave More...
 
64 |

Detailed Description

65 |

Function Documentation

66 | 67 |
68 |
69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 |
boolean Modbus::getTimeOutState ()
77 |
78 | 79 |

get communication watch-dog timer state

80 |

Return communication Watchdog state. It could be usefull to reset outputs if the watchdog is fired.

81 |
Returns
TRUE if millis() > u32timeOut
82 | 83 |

Definition at line 350 of file ModbusRtu.h.

84 | 85 |
86 |
87 | 88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 |
int8_t Modbus::poll ()
98 |
99 | 100 |

cyclic poll for master

101 |

*** Only for Modbus Master *** This method checks if there is any incoming answer if pending. If there is no answer, it would change Master state to COM_IDLE. This method must be called only at loop section. Avoid any delay() function.

102 |

Any incoming data would be redirected to au16regs pointer, as defined in its modbus_t query telegram.

103 |

nothing

104 |
Returns
errors counter
105 | 106 |

Definition at line 513 of file ModbusRtu.h.

107 | 108 |
109 |
110 | 111 |
112 |
113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 |
int8_t Modbus::poll (uint16_t * regs,
uint8_t u8size 
)
132 |
133 | 134 |

cyclic poll for slave

135 |

*** Only for Modbus Slave *** This method checks if there is any incoming query Afterwards, it would shoot a validation routine plus a register query Avoid any delay() function !!!! After a successful frame between the Master and the Slave, the time-out timer is reset.

136 |
Parameters
137 | 138 | 139 | 140 |
*regsregister table for communication exchange
u8sizesize of the register table
141 |
142 |
143 |
Returns
0 if no query, 1..4 if communication error, >4 if correct query processed
144 | 145 |

Definition at line 588 of file ModbusRtu.h.

146 | 147 |
148 |
149 | 150 |
151 |
152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 |
int8_t Modbus::query (modbus_t telegram)
161 |
162 | 163 |

only for master

164 |

*** Only Modbus Master *** Generate a query to an slave with a modbus_t telegram structure The Master must be in COM_IDLE mode. After it, its state would be COM_WAITING. This method has to be called only in loop() section.

165 |
See Also
modbus_t
166 |
Parameters
167 | 168 | 169 |
modbus_tmodbus telegram structure (id, fct, ...)
170 |
171 |
172 |
Todo:
finish function 15
173 | 174 |

Definition at line 425 of file ModbusRtu.h.

175 | 176 |
177 |
178 |
179 | 180 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /documentation/html/group__register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Modbus Function Codes for Holding/Input Registers 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 |
41 |
42 |
43 |
Modbus Function Codes for Holding/Input Registers
44 |
45 |
46 |

Detailed Description

47 |
48 | 49 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /documentation/html/group__setup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Modbus Object Instantiation/Initialization 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 |
41 |
42 |
43 | Functions
44 |
45 |
Modbus Object Instantiation/Initialization
46 |
47 |
48 | 49 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |

50 | Functions

 Modbus::Modbus ()
 Default Constructor for Master through Serial. More...
 
void Modbus::begin (long u32speed)
 Initialize class object. More...
 
void Modbus::setID (uint8_t u8id)
 write new ID for the slave More...
 
uint8_t Modbus::getID ()
 get slave ID between 1 and 247 More...
 
void Modbus::setTimeOut (uint16_t u16timeout)
 write communication watch-dog timer More...
 
67 |

Detailed Description

68 |

Function Documentation

69 | 70 |
71 |
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
void Modbus::begin (long u32speed)
81 |
82 | 83 |

Initialize class object.

84 |

Sets up the serial port using specified baud rate. Call once class has been instantiated, typically within setup().

85 |
See Also
http://arduino.cc/en/Serial/Begin#.Uy4CJ6aKlHY
86 |
Parameters
87 | 88 | 89 | 90 |
speedbaud rate, in standard increments (300..115200)
configdata frame settings (data length, parity and stop bits)
91 |
92 |
93 | 94 |

Definition at line 250 of file ModbusRtu.h.

95 | 96 |
97 |
98 | 99 |
100 |
101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 |
uint8_t Modbus::getID ()
109 |
110 | 111 |

get slave ID between 1 and 247

112 |

Method to read current slave ID address.

113 |
Returns
u8id current slave address between 1 and 247
114 | 115 |

Definition at line 323 of file ModbusRtu.h.

116 | 117 |
118 |
119 | 120 |
121 |
122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 |
Modbus::Modbus ()
130 |
131 | 132 |

Default Constructor for Master through Serial.

133 | 134 |

Definition at line 204 of file ModbusRtu.h.

135 | 136 |
137 |
138 | 139 |
140 |
141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 |
void Modbus::setID (uint8_t u8id)
150 |
151 | 152 |

write new ID for the slave

153 |

Method to write a new slave ID address.

154 |
Parameters
155 | 156 | 157 |
u8idnew slave address between 1 and 247
158 |
159 |
160 | 161 |

Definition at line 310 of file ModbusRtu.h.

162 | 163 |
164 |
165 | 166 |
167 |
168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 |
void Modbus::setTimeOut (uint16_t u16timeOut)
177 |
178 | 179 |

write communication watch-dog timer

180 |

Initialize time-out parameter.

181 |

Call once class has been instantiated, typically within setup(). The time-out timer is reset each time that there is a successful communication between Master and Slave. It works for both.

182 |
Parameters
183 | 184 | 185 |
time-outvalue (ms)
186 |
187 |
188 | 189 |

Definition at line 338 of file ModbusRtu.h.

190 | 191 |
192 |
193 |
194 | 195 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /documentation/html/index.hhp: -------------------------------------------------------------------------------- 1 | [OPTIONS] 2 | Compatibility=1.1 3 | Full-text search=Yes 4 | Contents file=index.hhc 5 | Default Window=main 6 | Default topic=index.html 7 | Index file=index.hhk 8 | Language=0x409 English (United States) 9 | Title=Modbus Master and Slave for Arduino 10 | 11 | [WINDOWS] 12 | main="Modbus Master and Slave for Arduino","index.hhc","index.hhk","index.html","index.html",,,,,0x23520,,0x10387e,,,,,,,,0 13 | 14 | [FILES] 15 | _modbus_rtu_8h_source.html 16 | _modbus_rtu_8h.html 17 | todo.html 18 | group__setup.html 19 | group__loop.html 20 | group__buffer.html 21 | group__discrete.html 22 | group__register.html 23 | class_modbus.html 24 | class_modbus-members.html 25 | structmodbus__t.html 26 | structmodbus__t-members.html 27 | index.html 28 | pages.html 29 | modules.html 30 | annotated.html 31 | classes.html 32 | functions.html 33 | functions_func.html 34 | functions_vars.html 35 | files.html 36 | globals.html 37 | globals_vars.html 38 | globals_enum.html 39 | globals_eval.html 40 | globals_defs.html 41 | tab_a.png 42 | tab_b.png 43 | tab_h.png 44 | tab_s.png 45 | nav_h.png 46 | nav_f.png 47 | bc_s.png 48 | doxygen.png 49 | closed.png 50 | open.png 51 | bdwn.png 52 | sync_on.png 53 | sync_off.png 54 | ftv2blank.png 55 | ftv2doc.png 56 | ftv2folderclosed.png 57 | ftv2folderopen.png 58 | ftv2ns.png 59 | ftv2mo.png 60 | ftv2cl.png 61 | ftv2lastnode.png 62 | ftv2link.png 63 | ftv2mlastnode.png 64 | ftv2mnode.png 65 | ftv2node.png 66 | ftv2plastnode.png 67 | ftv2pnode.png 68 | ftv2vertline.png 69 | ftv2splitbar.png 70 | -------------------------------------------------------------------------------- /documentation/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Main Page 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 |
41 |
42 |
43 |
Modbus Master and Slave for Arduino Documentation
44 |
45 |
46 |
47 | 48 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /documentation/html/modules.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Modules 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 |
41 |
42 |
43 |
Modules
44 |
45 | 56 | 57 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /documentation/html/nav_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/nav_f.png -------------------------------------------------------------------------------- /documentation/html/nav_g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/nav_g.png -------------------------------------------------------------------------------- /documentation/html/nav_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/nav_h.png -------------------------------------------------------------------------------- /documentation/html/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/open.png -------------------------------------------------------------------------------- /documentation/html/pages.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Related Pages 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 |
41 |
42 |
43 |
Related Pages
44 |
45 |
46 |
Here is a list of all related documentation pages:
47 | 48 | 49 |
\Todo List
50 |
51 |
52 | 53 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /documentation/html/structmodbus__t-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Member List 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 47 |
48 |
49 |
50 |
modbus_t Member List
51 |
52 |
53 | 54 |

This is the complete list of members for modbus_t, including all inherited members.

55 | 56 | 57 | 58 | 59 | 60 | 61 |
au16regmodbus_t
u16CoilsNomodbus_t
u16RegAddmodbus_t
u8fctmodbus_t
u8idmodbus_t
62 | 63 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /documentation/html/structmodbus__t.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: modbus_t Struct Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 | 47 |
48 |
49 | 52 |
53 |
modbus_t Struct Reference
54 |
55 |
56 | 57 |

Master query structure: This includes all the necessary fields to make the Master generate a Modbus query. A Master may keep several of these structures and send them cyclically or use them according to program needs. 58 | More...

59 | 60 |

#include <ModbusRtu.h>

61 | 62 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 |

63 | Public Attributes

uint8_t u8id
 
uint8_t u8fct
 
uint16_t u16RegAdd
 
uint16_t u16CoilsNo
 
uint16_t * au16reg
 
75 |

Detailed Description

76 |

Master query structure: This includes all the necessary fields to make the Master generate a Modbus query. A Master may keep several of these structures and send them cyclically or use them according to program needs.

77 | 78 |

Definition at line 48 of file ModbusRtu.h.

79 |

Member Data Documentation

80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 |
uint16_t* modbus_t::au16reg
88 |
89 |

Pointer to memory image in master

90 | 91 |

Definition at line 53 of file ModbusRtu.h.

92 | 93 |
94 |
95 | 96 |
97 |
98 | 99 | 100 | 101 | 102 |
uint16_t modbus_t::u16CoilsNo
103 |
104 |

Number of coils or registers to access

105 | 106 |

Definition at line 52 of file ModbusRtu.h.

107 | 108 |
109 |
110 | 111 |
112 |
113 | 114 | 115 | 116 | 117 |
uint16_t modbus_t::u16RegAdd
118 |
119 |

Address of the first register to access at slave/s

120 | 121 |

Definition at line 51 of file ModbusRtu.h.

122 | 123 |
124 |
125 | 126 |
127 |
128 | 129 | 130 | 131 | 132 |
uint8_t modbus_t::u8fct
133 |
134 |

Function code: 1, 2, 3, 4, 5, 6, 15 or 16

135 | 136 |

Definition at line 50 of file ModbusRtu.h.

137 | 138 |
139 |
140 | 141 |
142 |
143 | 144 | 145 | 146 | 147 |
uint8_t modbus_t::u8id
148 |
149 |

Slave address between 1 and 247. 0 means broadcast

150 | 151 |

Definition at line 49 of file ModbusRtu.h.

152 | 153 |
154 |
155 |
The documentation for this struct was generated from the following file: 158 |
159 | 160 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /documentation/html/sync_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/sync_off.png -------------------------------------------------------------------------------- /documentation/html/sync_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/sync_on.png -------------------------------------------------------------------------------- /documentation/html/tab_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/tab_a.png -------------------------------------------------------------------------------- /documentation/html/tab_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/tab_b.png -------------------------------------------------------------------------------- /documentation/html/tab_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/tab_h.png -------------------------------------------------------------------------------- /documentation/html/tab_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smarmengol/Modbus-Master-Slave-for-Arduino/38a43f2a6f4996e7b2c863ca5586b049158829ac/documentation/html/tab_s.png -------------------------------------------------------------------------------- /documentation/html/tabs.css: -------------------------------------------------------------------------------- 1 | .tabs, .tabs2, .tabs3 { 2 | background-image: url('tab_b.png'); 3 | width: 100%; 4 | z-index: 101; 5 | font-size: 13px; 6 | font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; 7 | } 8 | 9 | .tabs2 { 10 | font-size: 10px; 11 | } 12 | .tabs3 { 13 | font-size: 9px; 14 | } 15 | 16 | .tablist { 17 | margin: 0; 18 | padding: 0; 19 | display: table; 20 | } 21 | 22 | .tablist li { 23 | float: left; 24 | display: table-cell; 25 | background-image: url('tab_b.png'); 26 | line-height: 36px; 27 | list-style: none; 28 | } 29 | 30 | .tablist a { 31 | display: block; 32 | padding: 0 20px; 33 | font-weight: bold; 34 | background-image:url('tab_s.png'); 35 | background-repeat:no-repeat; 36 | background-position:right; 37 | color: #283A5D; 38 | text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); 39 | text-decoration: none; 40 | outline: none; 41 | } 42 | 43 | .tabs3 .tablist a { 44 | padding: 0 10px; 45 | } 46 | 47 | .tablist a:hover { 48 | background-image: url('tab_h.png'); 49 | background-repeat:repeat-x; 50 | color: #fff; 51 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 52 | text-decoration: none; 53 | } 54 | 55 | .tablist li.current a { 56 | background-image: url('tab_a.png'); 57 | background-repeat:repeat-x; 58 | color: #fff; 59 | text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); 60 | } 61 | -------------------------------------------------------------------------------- /documentation/html/todo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Modbus Master and Slave for Arduino: Todo List 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | 19 | 25 | 26 | 27 |
20 |
Modbus Master and Slave for Arduino 21 |  1.2 22 |
23 |
Arduino library for implementing a Modbus Master or Slave through Serial port
24 |
28 |
29 | 30 | 31 | 40 |
41 |
42 |
43 |
Todo List
44 |
45 |
46 |
47 |
Member Modbus::query (modbus_t telegram)
48 |
finish function 15
49 |
50 |
51 | 52 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /documentation/latex/Makefile: -------------------------------------------------------------------------------- 1 | all: refman.pdf 2 | 3 | pdf: refman.pdf 4 | 5 | refman.pdf: clean refman.tex 6 | pdflatex refman 7 | makeindex refman.idx 8 | pdflatex refman 9 | latex_count=5 ; \ 10 | while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\ 11 | do \ 12 | echo "Rerunning latex...." ;\ 13 | pdflatex refman ;\ 14 | latex_count=`expr $$latex_count - 1` ;\ 15 | done 16 | makeindex refman.idx 17 | pdflatex refman 18 | 19 | 20 | clean: 21 | rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf 22 | -------------------------------------------------------------------------------- /documentation/latex/annotated.tex: -------------------------------------------------------------------------------- 1 | \section{Class List} 2 | Here are the classes, structs, unions and interfaces with brief descriptions\-:\begin{DoxyCompactList} 3 | \item\contentsline{section}{\hyperlink{class_modbus}{Modbus} \\*Arduino class library for communicating with \hyperlink{class_modbus}{Modbus} devices over U\-S\-B/\-R\-S232/485 (via R\-T\-U protocol) }{\pageref{class_modbus}}{} 4 | \item\contentsline{section}{\hyperlink{structmodbus__t}{modbus\-\_\-t} \\*Master query structure\-: This includes all the necessary fields to make the Master generate a \hyperlink{class_modbus}{Modbus} query. A Master may keep several of these structures and send them cyclically or use them according to program needs }{\pageref{structmodbus__t}}{} 5 | \end{DoxyCompactList} 6 | -------------------------------------------------------------------------------- /documentation/latex/class_modbus.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{class_modbus}{\section{Modbus Class Reference} 2 | \label{class_modbus}\index{Modbus@{Modbus}} 3 | } 4 | 5 | 6 | Arduino class library for communicating with \hyperlink{class_modbus}{Modbus} devices over U\-S\-B/\-R\-S232/485 (via R\-T\-U protocol). 7 | 8 | 9 | 10 | 11 | {\ttfamily \#include $<$Modbus\-Rtu.\-h$>$} 12 | 13 | \subsection*{Public Member Functions} 14 | \begin{DoxyCompactItemize} 15 | \item 16 | \hyperlink{group__setup_ga101809cdd4734537bab58dc315a840b4}{Modbus} () 17 | \begin{DoxyCompactList}\small\item\em Default Constructor for Master through Serial. \end{DoxyCompactList}\item 18 | \hyperlink{class_modbus_afbbf7c81565d8e1ea1cd5890a96e7507}{Modbus} (uint8\-\_\-t u8id, uint8\-\_\-t u8serno) 19 | \item 20 | \hyperlink{class_modbus_a5e23a7b669d0c2d5be1c0054c7c54dca}{Modbus} (uint8\-\_\-t u8id, uint8\-\_\-t u8serno, uint8\-\_\-t u8txenpin) 21 | \item 22 | void \hyperlink{group__setup_ga475a4fa0fac491307b10c4529ad6d2a0}{begin} (long u32speed) 23 | \begin{DoxyCompactList}\small\item\em Initialize class object. \end{DoxyCompactList}\item 24 | void \hyperlink{class_modbus_a4f9673a3d113c49af69cb87b030ef099}{begin} () 25 | \item 26 | void \hyperlink{group__setup_gaf828190ebe24efb1b3b1957429f3872e}{set\-Time\-Out} (uint16\-\_\-t u16timeout) 27 | \begin{DoxyCompactList}\small\item\em write communication watch-\/dog timer \end{DoxyCompactList}\item 28 | uint16\-\_\-t \hyperlink{class_modbus_ac860024db3117a2ef907d0325b2fb7a1}{get\-Time\-Out} () 29 | \begin{DoxyCompactList}\small\item\em get communication watch-\/dog timer value \end{DoxyCompactList}\item 30 | boolean \hyperlink{group__loop_gaf6dd413191ed8a833022046873e0a063}{get\-Time\-Out\-State} () 31 | \begin{DoxyCompactList}\small\item\em get communication watch-\/dog timer state \end{DoxyCompactList}\item 32 | int8\-\_\-t \hyperlink{group__loop_ga19398cabed57b6d085d014af6c149f54}{query} (\hyperlink{structmodbus__t}{modbus\-\_\-t} telegram) 33 | \begin{DoxyCompactList}\small\item\em only for master \end{DoxyCompactList}\item 34 | int8\-\_\-t \hyperlink{group__loop_ga53bde78490c1cd8e3c070a676bdcfb0d}{poll} () 35 | \begin{DoxyCompactList}\small\item\em cyclic poll for master \end{DoxyCompactList}\item 36 | int8\-\_\-t \hyperlink{group__loop_gab3ef20562fc8cee14fc85f7e276890b5}{poll} (uint16\-\_\-t $\ast$regs, uint8\-\_\-t u8size) 37 | \begin{DoxyCompactList}\small\item\em cyclic poll for slave \end{DoxyCompactList}\item 38 | uint16\-\_\-t \hyperlink{group__buffer_ga4fa6ede8df85b7cc70b1282b9547378a}{get\-In\-Cnt} () 39 | \begin{DoxyCompactList}\small\item\em number of incoming messages \end{DoxyCompactList}\item 40 | uint16\-\_\-t \hyperlink{group__buffer_ga6f831ecaf3678c27dafb663a28bf81f0}{get\-Out\-Cnt} () 41 | \begin{DoxyCompactList}\small\item\em number of outcoming messages \end{DoxyCompactList}\item 42 | uint16\-\_\-t \hyperlink{group__buffer_ga6883c7f3ff12f084ed56d559d4e06ed0}{get\-Err\-Cnt} () 43 | \begin{DoxyCompactList}\small\item\em error counter \end{DoxyCompactList}\item 44 | uint8\-\_\-t \hyperlink{group__setup_ga6449894306ff8cc5d4caff09b1b0d1ce}{get\-I\-D} () 45 | \begin{DoxyCompactList}\small\item\em get slave I\-D between 1 and 247 \end{DoxyCompactList}\item 46 | uint8\-\_\-t \hyperlink{group__buffer_ga2f39717d957a929af488c9120488fcdc}{get\-State} () 47 | \item 48 | uint8\-\_\-t \hyperlink{group__buffer_gace7f726db13adc8feeceab987b719531}{get\-Last\-Error} () 49 | \begin{DoxyCompactList}\small\item\em get last error message \end{DoxyCompactList}\item 50 | void \hyperlink{group__setup_ga9bd497e97ac1777d4f0d4171078d60e0}{set\-I\-D} (uint8\-\_\-t u8id) 51 | \begin{DoxyCompactList}\small\item\em write new I\-D for the slave \end{DoxyCompactList}\item 52 | void \hyperlink{class_modbus_a0d80101b650344c712a085c4bb005c4c}{end} () 53 | \begin{DoxyCompactList}\small\item\em finish any communication and release serial communication port \end{DoxyCompactList}\end{DoxyCompactItemize} 54 | 55 | 56 | \subsection{Detailed Description} 57 | Arduino class library for communicating with \hyperlink{class_modbus}{Modbus} devices over U\-S\-B/\-R\-S232/485 (via R\-T\-U protocol). 58 | 59 | Definition at line 141 of file Modbus\-Rtu.\-h. 60 | 61 | 62 | 63 | \subsection{Constructor \& Destructor Documentation} 64 | \hypertarget{class_modbus_afbbf7c81565d8e1ea1cd5890a96e7507}{\index{Modbus@{Modbus}!Modbus@{Modbus}} 65 | \index{Modbus@{Modbus}!Modbus@{Modbus}} 66 | \subsubsection[{Modbus}]{\setlength{\rightskip}{0pt plus 5cm}Modbus\-::\-Modbus ( 67 | \begin{DoxyParamCaption} 68 | \item[{uint8\-\_\-t}]{u8id, } 69 | \item[{uint8\-\_\-t}]{u8serno} 70 | \end{DoxyParamCaption} 71 | )}}\label{class_modbus_afbbf7c81565d8e1ea1cd5890a96e7507} 72 | 73 | 74 | Definition at line 218 of file Modbus\-Rtu.\-h. 75 | 76 | \hypertarget{class_modbus_a5e23a7b669d0c2d5be1c0054c7c54dca}{\index{Modbus@{Modbus}!Modbus@{Modbus}} 77 | \index{Modbus@{Modbus}!Modbus@{Modbus}} 78 | \subsubsection[{Modbus}]{\setlength{\rightskip}{0pt plus 5cm}Modbus\-::\-Modbus ( 79 | \begin{DoxyParamCaption} 80 | \item[{uint8\-\_\-t}]{u8id, } 81 | \item[{uint8\-\_\-t}]{u8serno, } 82 | \item[{uint8\-\_\-t}]{u8txenpin} 83 | \end{DoxyParamCaption} 84 | )}}\label{class_modbus_a5e23a7b669d0c2d5be1c0054c7c54dca} 85 | 86 | 87 | Definition at line 234 of file Modbus\-Rtu.\-h. 88 | 89 | 90 | 91 | \subsection{Member Function Documentation} 92 | \hypertarget{class_modbus_a4f9673a3d113c49af69cb87b030ef099}{\index{Modbus@{Modbus}!begin@{begin}} 93 | \index{begin@{begin}!Modbus@{Modbus}} 94 | \subsubsection[{begin}]{\setlength{\rightskip}{0pt plus 5cm}void Modbus\-::begin ( 95 | \begin{DoxyParamCaption} 96 | {} 97 | \end{DoxyParamCaption} 98 | )}}\label{class_modbus_a4f9673a3d113c49af69cb87b030ef099} 99 | 100 | 101 | Definition at line 299 of file Modbus\-Rtu.\-h. 102 | 103 | \hypertarget{class_modbus_a0d80101b650344c712a085c4bb005c4c}{\index{Modbus@{Modbus}!end@{end}} 104 | \index{end@{end}!Modbus@{Modbus}} 105 | \subsubsection[{end}]{\setlength{\rightskip}{0pt plus 5cm}void Modbus\-::end ( 106 | \begin{DoxyParamCaption} 107 | {} 108 | \end{DoxyParamCaption} 109 | )}}\label{class_modbus_a0d80101b650344c712a085c4bb005c4c} 110 | 111 | 112 | finish any communication and release serial communication port 113 | 114 | \hypertarget{class_modbus_ac860024db3117a2ef907d0325b2fb7a1}{\index{Modbus@{Modbus}!get\-Time\-Out@{get\-Time\-Out}} 115 | \index{get\-Time\-Out@{get\-Time\-Out}!Modbus@{Modbus}} 116 | \subsubsection[{get\-Time\-Out}]{\setlength{\rightskip}{0pt plus 5cm}uint16\-\_\-t Modbus\-::get\-Time\-Out ( 117 | \begin{DoxyParamCaption} 118 | {} 119 | \end{DoxyParamCaption} 120 | )}}\label{class_modbus_ac860024db3117a2ef907d0325b2fb7a1} 121 | 122 | 123 | get communication watch-\/dog timer value 124 | 125 | 126 | 127 | The documentation for this class was generated from the following file\-:\begin{DoxyCompactItemize} 128 | \item 129 | \hyperlink{_modbus_rtu_8h}{Modbus\-Rtu.\-h}\end{DoxyCompactItemize} 130 | -------------------------------------------------------------------------------- /documentation/latex/doxygen.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e} 2 | \ProvidesPackage{doxygen} 3 | 4 | % Packages used by this style file 5 | \RequirePackage{alltt} 6 | \RequirePackage{array} 7 | \RequirePackage{calc} 8 | \RequirePackage{float} 9 | \RequirePackage{ifthen} 10 | \RequirePackage{verbatim} 11 | \RequirePackage[table]{xcolor} 12 | \RequirePackage{xtab} 13 | 14 | %---------- Internal commands used in this style file ---------------- 15 | 16 | \newcommand{\ensurespace}[1]{% 17 | \begingroup% 18 | \setlength{\dimen@}{#1}% 19 | \vskip\z@\@plus\dimen@% 20 | \penalty -100\vskip\z@\@plus -\dimen@% 21 | \vskip\dimen@% 22 | \penalty 9999% 23 | \vskip -\dimen@% 24 | \vskip\z@skip% hide the previous |\vskip| from |\addvspace| 25 | \endgroup% 26 | } 27 | 28 | \newcommand{\DoxyLabelFont}{} 29 | \newcommand{\entrylabel}[1]{% 30 | {% 31 | \parbox[b]{\labelwidth-4pt}{% 32 | \makebox[0pt][l]{\DoxyLabelFont#1}% 33 | \vspace{1.5\baselineskip}% 34 | }% 35 | }% 36 | } 37 | 38 | \newenvironment{DoxyDesc}[1]{% 39 | \ensurespace{4\baselineskip}% 40 | \begin{list}{}{% 41 | \settowidth{\labelwidth}{20pt}% 42 | \setlength{\parsep}{0pt}% 43 | \setlength{\itemsep}{0pt}% 44 | \setlength{\leftmargin}{\labelwidth+\labelsep}% 45 | \renewcommand{\makelabel}{\entrylabel}% 46 | }% 47 | \item[#1]% 48 | }{% 49 | \end{list}% 50 | } 51 | 52 | \newsavebox{\xrefbox} 53 | \newlength{\xreflength} 54 | \newcommand{\xreflabel}[1]{% 55 | \sbox{\xrefbox}{#1}% 56 | \setlength{\xreflength}{\wd\xrefbox}% 57 | \ifthenelse{\xreflength>\labelwidth}{% 58 | \begin{minipage}{\textwidth}% 59 | \setlength{\parindent}{0pt}% 60 | \hangindent=15pt\bfseries #1\vspace{1.2\itemsep}% 61 | \end{minipage}% 62 | }{% 63 | \parbox[b]{\labelwidth}{\makebox[0pt][l]{\textbf{#1}}}% 64 | }% 65 | } 66 | 67 | %---------- Commands used by doxygen LaTeX output generator ---------- 68 | 69 | % Used by
 ... 
70 | \newenvironment{DoxyPre}{% 71 | \small% 72 | \begin{alltt}% 73 | }{% 74 | \end{alltt}% 75 | \normalsize% 76 | } 77 | 78 | % Used by @code ... @endcode 79 | \newenvironment{DoxyCode}{% 80 | \par% 81 | \scriptsize% 82 | \begin{alltt}% 83 | }{% 84 | \end{alltt}% 85 | \normalsize% 86 | } 87 | 88 | % Used by @example, @include, @includelineno and @dontinclude 89 | \newenvironment{DoxyCodeInclude}{% 90 | \DoxyCode% 91 | }{% 92 | \endDoxyCode% 93 | } 94 | 95 | % Used by @verbatim ... @endverbatim 96 | \newenvironment{DoxyVerb}{% 97 | \footnotesize% 98 | \verbatim% 99 | }{% 100 | \endverbatim% 101 | \normalsize% 102 | } 103 | 104 | % Used by @verbinclude 105 | \newenvironment{DoxyVerbInclude}{% 106 | \DoxyVerb% 107 | }{% 108 | \endDoxyVerb% 109 | } 110 | 111 | % Used by numbered lists (using '-#' or
    ...
) 112 | \newenvironment{DoxyEnumerate}{% 113 | \enumerate% 114 | }{% 115 | \endenumerate% 116 | } 117 | 118 | % Used by bullet lists (using '-', @li, @arg, or
    ...
) 119 | \newenvironment{DoxyItemize}{% 120 | \itemize% 121 | }{% 122 | \enditemize% 123 | } 124 | 125 | % Used by description lists (using
...
) 126 | \newenvironment{DoxyDescription}{% 127 | \description% 128 | }{% 129 | \enddescription% 130 | } 131 | 132 | % Used by @image, @dotfile, @dot ... @enddot, and @msc ... @endmsc 133 | % (only if caption is specified) 134 | \newenvironment{DoxyImage}{% 135 | \begin{figure}[H]% 136 | \begin{center}% 137 | }{% 138 | \end{center}% 139 | \end{figure}% 140 | } 141 | 142 | % Used by @image, @dotfile, @dot ... @enddot, and @msc ... @endmsc 143 | % (only if no caption is specified) 144 | \newenvironment{DoxyImageNoCaption}{% 145 | }{% 146 | } 147 | 148 | % Used by @attention 149 | \newenvironment{DoxyAttention}[1]{% 150 | \begin{DoxyDesc}{#1}% 151 | }{% 152 | \end{DoxyDesc}% 153 | } 154 | 155 | % Used by @author and @authors 156 | \newenvironment{DoxyAuthor}[1]{% 157 | \begin{DoxyDesc}{#1}% 158 | }{% 159 | \end{DoxyDesc}% 160 | } 161 | 162 | % Used by @date 163 | \newenvironment{DoxyDate}[1]{% 164 | \begin{DoxyDesc}{#1}% 165 | }{% 166 | \end{DoxyDesc}% 167 | } 168 | 169 | % Used by @invariant 170 | \newenvironment{DoxyInvariant}[1]{% 171 | \begin{DoxyDesc}{#1}% 172 | }{% 173 | \end{DoxyDesc}% 174 | } 175 | 176 | % Used by @note 177 | \newenvironment{DoxyNote}[1]{% 178 | \begin{DoxyDesc}{#1}% 179 | }{% 180 | \end{DoxyDesc}% 181 | } 182 | 183 | % Used by @post 184 | \newenvironment{DoxyPostcond}[1]{% 185 | \begin{DoxyDesc}{#1}% 186 | }{% 187 | \end{DoxyDesc}% 188 | } 189 | 190 | % Used by @pre 191 | \newenvironment{DoxyPrecond}[1]{% 192 | \begin{DoxyDesc}{#1}% 193 | }{% 194 | \end{DoxyDesc}% 195 | } 196 | 197 | % Used by @copyright 198 | \newenvironment{DoxyCopyright}[1]{% 199 | \begin{DoxyDesc}{#1}% 200 | }{% 201 | \end{DoxyDesc}% 202 | } 203 | 204 | % Used by @remark 205 | \newenvironment{DoxyRemark}[1]{% 206 | \begin{DoxyDesc}{#1}% 207 | }{% 208 | \end{DoxyDesc}% 209 | } 210 | 211 | % Used by @return and @returns 212 | \newenvironment{DoxyReturn}[1]{% 213 | \begin{DoxyDesc}{#1}% 214 | }{% 215 | \end{DoxyDesc}% 216 | } 217 | 218 | % Used by @since 219 | \newenvironment{DoxySince}[1]{% 220 | \begin{DoxyDesc}{#1}% 221 | }{% 222 | \end{DoxyDesc}% 223 | } 224 | 225 | % Used by @see 226 | \newenvironment{DoxySeeAlso}[1]{% 227 | \begin{DoxyDesc}{#1}% 228 | }{% 229 | \end{DoxyDesc}% 230 | } 231 | 232 | % Used by @version 233 | \newenvironment{DoxyVersion}[1]{% 234 | \begin{DoxyDesc}{#1}% 235 | }{% 236 | \end{DoxyDesc}% 237 | } 238 | 239 | % Used by @warning 240 | \newenvironment{DoxyWarning}[1]{% 241 | \begin{DoxyDesc}{#1}% 242 | }{% 243 | \end{DoxyDesc}% 244 | } 245 | 246 | % Used by @internal 247 | \newenvironment{DoxyInternal}[1]{% 248 | \paragraph*{#1}% 249 | }{% 250 | } 251 | 252 | % Used by @par and @paragraph 253 | \newenvironment{DoxyParagraph}[1]{% 254 | \begin{list}{}{% 255 | \settowidth{\labelwidth}{40pt}% 256 | \setlength{\leftmargin}{\labelwidth}% 257 | \setlength{\parsep}{0pt}% 258 | \setlength{\itemsep}{-4pt}% 259 | \renewcommand{\makelabel}{\entrylabel}% 260 | }% 261 | \item[#1]% 262 | }{% 263 | \end{list}% 264 | } 265 | 266 | % Used by parameter lists 267 | \newenvironment{DoxyParams}[2][]{% 268 | \par% 269 | \tabletail{\hline}% 270 | \tablelasttail{\hline}% 271 | \tablefirsthead{}% 272 | \tablehead{}% 273 | \ifthenelse{\equal{#1}{}}% 274 | {\tablefirsthead{\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #2}\\[1ex]}% 275 | \begin{xtabular}{|>{\raggedleft\hspace{0pt}}p{0.15\textwidth}|% 276 | p{0.805\textwidth}|}}% 277 | {\ifthenelse{\equal{#1}{1}}% 278 | {\tablefirsthead{\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #2}\\[1ex]}% 279 | \begin{xtabular}{|>{\centering}p{0.10\textwidth}|% 280 | >{\raggedleft\hspace{0pt}}p{0.15\textwidth}|% 281 | p{0.678\textwidth}|}}% 282 | {\tablefirsthead{\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #2}\\[1ex]}% 283 | \begin{xtabular}{|>{\centering}p{0.10\textwidth}|% 284 | >{\centering\hspace{0pt}}p{0.15\textwidth}|% 285 | >{\raggedleft\hspace{0pt}}p{0.15\textwidth}|% 286 | p{0.501\textwidth}|}}% 287 | }\hline% 288 | }{% 289 | \end{xtabular}% 290 | \tablefirsthead{}% 291 | \vspace{6pt}% 292 | } 293 | 294 | % Used for fields of simple structs 295 | \newenvironment{DoxyFields}[1]{% 296 | \par% 297 | \tabletail{\hline}% 298 | \tablelasttail{\hline}% 299 | \tablehead{}% 300 | \tablefirsthead{\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]}% 301 | \begin{xtabular}{|>{\raggedleft\hspace{0pt}}p{0.15\textwidth}|% 302 | p{0.15\textwidth}|% 303 | p{0.63\textwidth}|}% 304 | \hline% 305 | }{% 306 | \end{xtabular}% 307 | \tablefirsthead{}% 308 | \vspace{6pt}% 309 | } 310 | 311 | % Used for parameters within a detailed function description 312 | \newenvironment{DoxyParamCaption}{% 313 | \renewcommand{\item}[2][]{##1 {\em ##2}}% 314 | }{% 315 | } 316 | 317 | % Used by return value lists 318 | \newenvironment{DoxyRetVals}[1]{% 319 | \par% 320 | \tabletail{\hline}% 321 | \tablelasttail{\hline}% 322 | \tablehead{}% 323 | \tablefirsthead{\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]}% 324 | \begin{xtabular}{|>{\raggedleft\hspace{0pt}}p{0.25\textwidth}|% 325 | p{0.705\textwidth}|}% 326 | \hline% 327 | }{% 328 | \end{xtabular}% 329 | \tablefirsthead{}% 330 | \vspace{6pt}% 331 | } 332 | 333 | % Used by exception lists 334 | \newenvironment{DoxyExceptions}[1]{% 335 | \par% 336 | \tabletail{\hline}% 337 | \tablelasttail{\hline}% 338 | \tablehead{}% 339 | \tablefirsthead{\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]}% 340 | \begin{xtabular}{|>{\raggedleft\hspace{0pt}}p{0.25\textwidth}|% 341 | p{0.705\textwidth}|}% 342 | \hline% 343 | }{% 344 | \end{xtabular}% 345 | \tablefirsthead{}% 346 | \vspace{6pt}% 347 | } 348 | 349 | % Used by template parameter lists 350 | \newenvironment{DoxyTemplParams}[1]{% 351 | \par% 352 | \tabletail{\hline}% 353 | \tablelasttail{\hline}% 354 | \tablehead{}% 355 | \tablefirsthead{\multicolumn{2}{l}{\hspace{-6pt}\bfseries\fontseries{bc}\selectfont\color{darkgray} #1}\\[1ex]}% 356 | \begin{xtabular}{|>{\raggedleft\hspace{0pt}}p{0.25\textwidth}|% 357 | p{0.705\textwidth}|}% 358 | \hline% 359 | }{% 360 | \end{xtabular}% 361 | \tablefirsthead{}% 362 | \vspace{6pt}% 363 | } 364 | 365 | % Used for member lists 366 | \newenvironment{DoxyCompactItemize}{% 367 | \begin{itemize}% 368 | \setlength{\itemsep}{-3pt}% 369 | \setlength{\parsep}{0pt}% 370 | \setlength{\topsep}{0pt}% 371 | \setlength{\partopsep}{0pt}% 372 | }{% 373 | \end{itemize}% 374 | } 375 | 376 | % Used for member descriptions 377 | \newenvironment{DoxyCompactList}{% 378 | \begin{list}{}{% 379 | \setlength{\leftmargin}{0.5cm}% 380 | \setlength{\itemsep}{0pt}% 381 | \setlength{\parsep}{0pt}% 382 | \setlength{\topsep}{0pt}% 383 | \renewcommand{\makelabel}{\hfill}% 384 | }% 385 | }{% 386 | \end{list}% 387 | } 388 | 389 | % Used for reference lists (@bug, @deprecated, @todo, etc.) 390 | \newenvironment{DoxyRefList}{% 391 | \begin{list}{}{% 392 | \setlength{\labelwidth}{10pt}% 393 | \setlength{\leftmargin}{\labelwidth}% 394 | \addtolength{\leftmargin}{\labelsep}% 395 | \renewcommand{\makelabel}{\xreflabel}% 396 | }% 397 | }{% 398 | \end{list}% 399 | } 400 | 401 | % Used by @bug, @deprecated, @todo, etc. 402 | \newenvironment{DoxyRefDesc}[1]{% 403 | \begin{list}{}{% 404 | \renewcommand\makelabel[1]{\textbf{##1}}% 405 | \settowidth\labelwidth{\makelabel{#1}}% 406 | \setlength\leftmargin{\labelwidth+\labelsep}% 407 | }% 408 | }{% 409 | \end{list}% 410 | } 411 | 412 | % Used by parameter lists and simple sections 413 | \newenvironment{Desc} 414 | {\begin{list}{}{% 415 | \settowidth{\labelwidth}{40pt}% 416 | \setlength{\leftmargin}{\labelwidth}% 417 | \setlength{\parsep}{0pt}% 418 | \setlength{\itemsep}{-4pt}% 419 | \renewcommand{\makelabel}{\entrylabel}% 420 | } 421 | }{% 422 | \end{list}% 423 | } 424 | 425 | % Used by tables 426 | \newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp}% 427 | \newlength{\tmplength}% 428 | \newenvironment{TabularC}[1]% 429 | {% 430 | \setlength{\tmplength}% 431 | {\linewidth/(#1)-\tabcolsep*2-\arrayrulewidth*(#1+1)/(#1)}% 432 | \par\begin{xtabular*}{\linewidth}% 433 | {*{#1}{|>{\PBS\raggedright\hspace{0pt}}p{\the\tmplength}}|}% 434 | }% 435 | {\end{xtabular*}\par}% 436 | 437 | % Used for member group headers 438 | \newenvironment{Indent}{% 439 | \begin{list}{}{% 440 | \setlength{\leftmargin}{0.5cm}% 441 | }% 442 | \item[]\ignorespaces% 443 | }{% 444 | \unskip% 445 | \end{list}% 446 | } 447 | 448 | % Used when hyperlinks are turned off 449 | \newcommand{\doxyref}[3]{% 450 | \textbf{#1} (\textnormal{#2}\,\pageref{#3})% 451 | } 452 | 453 | % Used for syntax highlighting 454 | \definecolor{comment}{rgb}{0.5,0.0,0.0} 455 | \definecolor{keyword}{rgb}{0.0,0.5,0.0} 456 | \definecolor{keywordtype}{rgb}{0.38,0.25,0.125} 457 | \definecolor{keywordflow}{rgb}{0.88,0.5,0.0} 458 | \definecolor{preprocessor}{rgb}{0.5,0.38,0.125} 459 | \definecolor{stringliteral}{rgb}{0.0,0.125,0.25} 460 | \definecolor{charliteral}{rgb}{0.0,0.5,0.5} 461 | \definecolor{vhdldigit}{rgb}{1.0,0.0,1.0} 462 | \definecolor{vhdlkeyword}{rgb}{0.43,0.0,0.43} 463 | \definecolor{vhdllogic}{rgb}{1.0,0.0,0.0} 464 | \definecolor{vhdlchar}{rgb}{0.0,0.0,0.0} 465 | -------------------------------------------------------------------------------- /documentation/latex/files.tex: -------------------------------------------------------------------------------- 1 | \section{File List} 2 | Here is a list of all files with brief descriptions\-:\begin{DoxyCompactList} 3 | \item\contentsline{section}{\hyperlink{_modbus_rtu_8h}{Modbus\-Rtu.\-h} }{\pageref{_modbus_rtu_8h}}{} 4 | \end{DoxyCompactList} 5 | -------------------------------------------------------------------------------- /documentation/latex/group__buffer.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{group__buffer}{\section{Modbus Buffer Management} 2 | \label{group__buffer}\index{Modbus Buffer Management@{Modbus Buffer Management}} 3 | } 4 | \subsection*{Functions} 5 | \begin{DoxyCompactItemize} 6 | \item 7 | uint16\-\_\-t \hyperlink{group__buffer_ga4fa6ede8df85b7cc70b1282b9547378a}{Modbus\-::get\-In\-Cnt} () 8 | \begin{DoxyCompactList}\small\item\em number of incoming messages \end{DoxyCompactList}\item 9 | uint16\-\_\-t \hyperlink{group__buffer_ga6f831ecaf3678c27dafb663a28bf81f0}{Modbus\-::get\-Out\-Cnt} () 10 | \begin{DoxyCompactList}\small\item\em number of outcoming messages \end{DoxyCompactList}\item 11 | uint16\-\_\-t \hyperlink{group__buffer_ga6883c7f3ff12f084ed56d559d4e06ed0}{Modbus\-::get\-Err\-Cnt} () 12 | \begin{DoxyCompactList}\small\item\em error counter \end{DoxyCompactList}\item 13 | uint8\-\_\-t \hyperlink{group__buffer_ga2f39717d957a929af488c9120488fcdc}{Modbus\-::get\-State} () 14 | \item 15 | uint8\-\_\-t \hyperlink{group__buffer_gace7f726db13adc8feeceab987b719531}{Modbus\-::get\-Last\-Error} () 16 | \begin{DoxyCompactList}\small\item\em get last error message \end{DoxyCompactList}\end{DoxyCompactItemize} 17 | 18 | 19 | \subsection{Detailed Description} 20 | 21 | 22 | \subsection{Function Documentation} 23 | \hypertarget{group__buffer_ga6883c7f3ff12f084ed56d559d4e06ed0}{\index{Modbus Buffer Management@{Modbus Buffer Management}!get\-Err\-Cnt@{get\-Err\-Cnt}} 24 | \index{get\-Err\-Cnt@{get\-Err\-Cnt}!Modbus Buffer Management@{Modbus Buffer Management}} 25 | \subsubsection[{get\-Err\-Cnt}]{\setlength{\rightskip}{0pt plus 5cm}uint16\-\_\-t Modbus\-::get\-Err\-Cnt ( 26 | \begin{DoxyParamCaption} 27 | {} 28 | \end{DoxyParamCaption} 29 | )}}\label{group__buffer_ga6883c7f3ff12f084ed56d559d4e06ed0} 30 | 31 | 32 | error counter 33 | 34 | Get errors counter value This can be useful to diagnose communication. 35 | 36 | \begin{DoxyReturn}{Returns} 37 | errors counter 38 | \end{DoxyReturn} 39 | 40 | 41 | Definition at line 386 of file Modbus\-Rtu.\-h. 42 | 43 | \hypertarget{group__buffer_ga4fa6ede8df85b7cc70b1282b9547378a}{\index{Modbus Buffer Management@{Modbus Buffer Management}!get\-In\-Cnt@{get\-In\-Cnt}} 44 | \index{get\-In\-Cnt@{get\-In\-Cnt}!Modbus Buffer Management@{Modbus Buffer Management}} 45 | \subsubsection[{get\-In\-Cnt}]{\setlength{\rightskip}{0pt plus 5cm}uint16\-\_\-t Modbus\-::get\-In\-Cnt ( 46 | \begin{DoxyParamCaption} 47 | {} 48 | \end{DoxyParamCaption} 49 | )}}\label{group__buffer_ga4fa6ede8df85b7cc70b1282b9547378a} 50 | 51 | 52 | number of incoming messages 53 | 54 | Get input messages counter value This can be useful to diagnose communication. 55 | 56 | \begin{DoxyReturn}{Returns} 57 | input messages counter 58 | \end{DoxyReturn} 59 | 60 | 61 | Definition at line 362 of file Modbus\-Rtu.\-h. 62 | 63 | \hypertarget{group__buffer_gace7f726db13adc8feeceab987b719531}{\index{Modbus Buffer Management@{Modbus Buffer Management}!get\-Last\-Error@{get\-Last\-Error}} 64 | \index{get\-Last\-Error@{get\-Last\-Error}!Modbus Buffer Management@{Modbus Buffer Management}} 65 | \subsubsection[{get\-Last\-Error}]{\setlength{\rightskip}{0pt plus 5cm}uint8\-\_\-t Modbus\-::get\-Last\-Error ( 66 | \begin{DoxyParamCaption} 67 | {} 68 | \end{DoxyParamCaption} 69 | )}}\label{group__buffer_gace7f726db13adc8feeceab987b719531} 70 | 71 | 72 | get last error message 73 | 74 | Get the last error in the protocol processor 75 | 76 | N\-O\-\_\-\-R\-E\-P\-L\-Y = 255 Time-\/out \begin{DoxyReturn}{Returns} 77 | E\-X\-C\-\_\-\-F\-U\-N\-C\-\_\-\-C\-O\-D\-E = 1 Function code not available 78 | 79 | E\-X\-C\-\_\-\-A\-D\-D\-R\-\_\-\-R\-A\-N\-G\-E = 2 Address beyond available space for \hyperlink{class_modbus}{Modbus} registers 80 | 81 | E\-X\-C\-\_\-\-R\-E\-G\-S\-\_\-\-Q\-U\-A\-N\-T = 3 Coils or registers number beyond the available space 82 | \end{DoxyReturn} 83 | 84 | 85 | Definition at line 409 of file Modbus\-Rtu.\-h. 86 | 87 | \hypertarget{group__buffer_ga6f831ecaf3678c27dafb663a28bf81f0}{\index{Modbus Buffer Management@{Modbus Buffer Management}!get\-Out\-Cnt@{get\-Out\-Cnt}} 88 | \index{get\-Out\-Cnt@{get\-Out\-Cnt}!Modbus Buffer Management@{Modbus Buffer Management}} 89 | \subsubsection[{get\-Out\-Cnt}]{\setlength{\rightskip}{0pt plus 5cm}uint16\-\_\-t Modbus\-::get\-Out\-Cnt ( 90 | \begin{DoxyParamCaption} 91 | {} 92 | \end{DoxyParamCaption} 93 | )}}\label{group__buffer_ga6f831ecaf3678c27dafb663a28bf81f0} 94 | 95 | 96 | number of outcoming messages 97 | 98 | Get transmitted messages counter value This can be useful to diagnose communication. 99 | 100 | \begin{DoxyReturn}{Returns} 101 | transmitted messages counter 102 | \end{DoxyReturn} 103 | 104 | 105 | Definition at line 374 of file Modbus\-Rtu.\-h. 106 | 107 | \hypertarget{group__buffer_ga2f39717d957a929af488c9120488fcdc}{\index{Modbus Buffer Management@{Modbus Buffer Management}!get\-State@{get\-State}} 108 | \index{get\-State@{get\-State}!Modbus Buffer Management@{Modbus Buffer Management}} 109 | \subsubsection[{get\-State}]{\setlength{\rightskip}{0pt plus 5cm}uint8\-\_\-t Modbus\-::get\-State ( 110 | \begin{DoxyParamCaption} 111 | {} 112 | \end{DoxyParamCaption} 113 | )}}\label{group__buffer_ga2f39717d957a929af488c9120488fcdc} 114 | Get modbus master state 115 | 116 | \begin{DoxyReturn}{Returns} 117 | = 0 I\-D\-L\-E, = 1 W\-A\-I\-T\-I\-N\-G F\-O\-R A\-N\-S\-W\-E\-R 118 | \end{DoxyReturn} 119 | 120 | 121 | Definition at line 396 of file Modbus\-Rtu.\-h. 122 | 123 | -------------------------------------------------------------------------------- /documentation/latex/group__discrete.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{group__discrete}{\section{Modbus Function Codes for Discrete Coils/\-Inputs} 2 | \label{group__discrete}\index{Modbus Function Codes for Discrete Coils/\-Inputs@{Modbus Function Codes for Discrete Coils/\-Inputs}} 3 | } 4 | 5 | 6 | \subsection{Detailed Description} 7 | -------------------------------------------------------------------------------- /documentation/latex/group__loop.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{group__loop}{\section{Modbus Object Management} 2 | \label{group__loop}\index{Modbus Object Management@{Modbus Object Management}} 3 | } 4 | \subsection*{Functions} 5 | \begin{DoxyCompactItemize} 6 | \item 7 | boolean \hyperlink{group__loop_gaf6dd413191ed8a833022046873e0a063}{Modbus\-::get\-Time\-Out\-State} () 8 | \begin{DoxyCompactList}\small\item\em get communication watch-\/dog timer state \end{DoxyCompactList}\item 9 | int8\-\_\-t \hyperlink{group__loop_ga19398cabed57b6d085d014af6c149f54}{Modbus\-::query} (\hyperlink{structmodbus__t}{modbus\-\_\-t} telegram) 10 | \begin{DoxyCompactList}\small\item\em only for master \end{DoxyCompactList}\item 11 | int8\-\_\-t \hyperlink{group__loop_ga53bde78490c1cd8e3c070a676bdcfb0d}{Modbus\-::poll} () 12 | \begin{DoxyCompactList}\small\item\em cyclic poll for master \end{DoxyCompactList}\item 13 | int8\-\_\-t \hyperlink{group__loop_gab3ef20562fc8cee14fc85f7e276890b5}{Modbus\-::poll} (uint16\-\_\-t $\ast$regs, uint8\-\_\-t u8size) 14 | \begin{DoxyCompactList}\small\item\em cyclic poll for slave \end{DoxyCompactList}\end{DoxyCompactItemize} 15 | 16 | 17 | \subsection{Detailed Description} 18 | 19 | 20 | \subsection{Function Documentation} 21 | \hypertarget{group__loop_gaf6dd413191ed8a833022046873e0a063}{\index{Modbus Object Management@{Modbus Object Management}!get\-Time\-Out\-State@{get\-Time\-Out\-State}} 22 | \index{get\-Time\-Out\-State@{get\-Time\-Out\-State}!Modbus Object Management@{Modbus Object Management}} 23 | \subsubsection[{get\-Time\-Out\-State}]{\setlength{\rightskip}{0pt plus 5cm}boolean Modbus\-::get\-Time\-Out\-State ( 24 | \begin{DoxyParamCaption} 25 | {} 26 | \end{DoxyParamCaption} 27 | )}}\label{group__loop_gaf6dd413191ed8a833022046873e0a063} 28 | 29 | 30 | get communication watch-\/dog timer state 31 | 32 | Return communication Watchdog state. It could be usefull to reset outputs if the watchdog is fired. 33 | 34 | \begin{DoxyReturn}{Returns} 35 | T\-R\-U\-E if millis() $>$ u32time\-Out 36 | \end{DoxyReturn} 37 | 38 | 39 | Definition at line 350 of file Modbus\-Rtu.\-h. 40 | 41 | \hypertarget{group__loop_ga53bde78490c1cd8e3c070a676bdcfb0d}{\index{Modbus Object Management@{Modbus Object Management}!poll@{poll}} 42 | \index{poll@{poll}!Modbus Object Management@{Modbus Object Management}} 43 | \subsubsection[{poll}]{\setlength{\rightskip}{0pt plus 5cm}int8\-\_\-t Modbus\-::poll ( 44 | \begin{DoxyParamCaption} 45 | {} 46 | \end{DoxyParamCaption} 47 | )}}\label{group__loop_ga53bde78490c1cd8e3c070a676bdcfb0d} 48 | 49 | 50 | cyclic poll for master 51 | 52 | $\ast$$\ast$$\ast$ Only for \hyperlink{class_modbus}{Modbus} Master $\ast$$\ast$$\ast$ This method checks if there is any incoming answer if pending. If there is no answer, it would change Master state to C\-O\-M\-\_\-\-I\-D\-L\-E. This method must be called only at loop section. Avoid any delay() function. 53 | 54 | Any incoming data would be redirected to au16regs pointer, as defined in its \hyperlink{structmodbus__t}{modbus\-\_\-t} query telegram. 55 | 56 | nothing \begin{DoxyReturn}{Returns} 57 | errors counter 58 | \end{DoxyReturn} 59 | 60 | 61 | Definition at line 513 of file Modbus\-Rtu.\-h. 62 | 63 | \hypertarget{group__loop_gab3ef20562fc8cee14fc85f7e276890b5}{\index{Modbus Object Management@{Modbus Object Management}!poll@{poll}} 64 | \index{poll@{poll}!Modbus Object Management@{Modbus Object Management}} 65 | \subsubsection[{poll}]{\setlength{\rightskip}{0pt plus 5cm}int8\-\_\-t Modbus\-::poll ( 66 | \begin{DoxyParamCaption} 67 | \item[{uint16\-\_\-t $\ast$}]{regs, } 68 | \item[{uint8\-\_\-t}]{u8size} 69 | \end{DoxyParamCaption} 70 | )}}\label{group__loop_gab3ef20562fc8cee14fc85f7e276890b5} 71 | 72 | 73 | cyclic poll for slave 74 | 75 | $\ast$$\ast$$\ast$ Only for \hyperlink{class_modbus}{Modbus} Slave $\ast$$\ast$$\ast$ This method checks if there is any incoming query Afterwards, it would shoot a validation routine plus a register query Avoid any delay() function !!!! After a successful frame between the Master and the Slave, the time-\/out timer is reset. 76 | 77 | 78 | \begin{DoxyParams}{Parameters} 79 | {\em $\ast$regs} & register table for communication exchange \\ 80 | \hline 81 | {\em u8size} & size of the register table \\ 82 | \hline 83 | \end{DoxyParams} 84 | \begin{DoxyReturn}{Returns} 85 | 0 if no query, 1..4 if communication error, $>$4 if correct query processed 86 | \end{DoxyReturn} 87 | 88 | 89 | Definition at line 588 of file Modbus\-Rtu.\-h. 90 | 91 | \hypertarget{group__loop_ga19398cabed57b6d085d014af6c149f54}{\index{Modbus Object Management@{Modbus Object Management}!query@{query}} 92 | \index{query@{query}!Modbus Object Management@{Modbus Object Management}} 93 | \subsubsection[{query}]{\setlength{\rightskip}{0pt plus 5cm}int8\-\_\-t Modbus\-::query ( 94 | \begin{DoxyParamCaption} 95 | \item[{{\bf modbus\-\_\-t}}]{telegram} 96 | \end{DoxyParamCaption} 97 | )}}\label{group__loop_ga19398cabed57b6d085d014af6c149f54} 98 | 99 | 100 | only for master 101 | 102 | $\ast$$\ast$$\ast$ Only \hyperlink{class_modbus}{Modbus} Master $\ast$$\ast$$\ast$ Generate a query to an slave with a \hyperlink{structmodbus__t}{modbus\-\_\-t} telegram structure The Master must be in C\-O\-M\-\_\-\-I\-D\-L\-E mode. After it, its state would be C\-O\-M\-\_\-\-W\-A\-I\-T\-I\-N\-G. This method has to be called only in loop() section. 103 | 104 | \begin{DoxySeeAlso}{See Also} 105 | \hyperlink{structmodbus__t}{modbus\-\_\-t} 106 | \end{DoxySeeAlso} 107 | 108 | \begin{DoxyParams}{Parameters} 109 | {\em \hyperlink{structmodbus__t}{modbus\-\_\-t}} & modbus telegram structure (id, fct, ...)\\ 110 | \hline 111 | \end{DoxyParams} 112 | \begin{DoxyRefDesc}{Todo} 113 | \item[\hyperlink{todo__todo000001}{Todo}]finish function 15 \end{DoxyRefDesc} 114 | 115 | 116 | Definition at line 425 of file Modbus\-Rtu.\-h. 117 | 118 | -------------------------------------------------------------------------------- /documentation/latex/group__register.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{group__register}{\section{Modbus Function Codes for Holding/\-Input Registers} 2 | \label{group__register}\index{Modbus Function Codes for Holding/\-Input Registers@{Modbus Function Codes for Holding/\-Input Registers}} 3 | } 4 | 5 | 6 | \subsection{Detailed Description} 7 | -------------------------------------------------------------------------------- /documentation/latex/group__setup.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{group__setup}{\section{Modbus Object Instantiation/\-Initialization} 2 | \label{group__setup}\index{Modbus Object Instantiation/\-Initialization@{Modbus Object Instantiation/\-Initialization}} 3 | } 4 | \subsection*{Functions} 5 | \begin{DoxyCompactItemize} 6 | \item 7 | \hyperlink{group__setup_ga101809cdd4734537bab58dc315a840b4}{Modbus\-::\-Modbus} () 8 | \begin{DoxyCompactList}\small\item\em Default Constructor for Master through Serial. \end{DoxyCompactList}\item 9 | void \hyperlink{group__setup_ga475a4fa0fac491307b10c4529ad6d2a0}{Modbus\-::begin} (long u32speed) 10 | \begin{DoxyCompactList}\small\item\em Initialize class object. \end{DoxyCompactList}\item 11 | void \hyperlink{group__setup_ga9bd497e97ac1777d4f0d4171078d60e0}{Modbus\-::set\-I\-D} (uint8\-\_\-t u8id) 12 | \begin{DoxyCompactList}\small\item\em write new I\-D for the slave \end{DoxyCompactList}\item 13 | uint8\-\_\-t \hyperlink{group__setup_ga6449894306ff8cc5d4caff09b1b0d1ce}{Modbus\-::get\-I\-D} () 14 | \begin{DoxyCompactList}\small\item\em get slave I\-D between 1 and 247 \end{DoxyCompactList}\item 15 | void \hyperlink{group__setup_gaf828190ebe24efb1b3b1957429f3872e}{Modbus\-::set\-Time\-Out} (uint16\-\_\-t u16timeout) 16 | \begin{DoxyCompactList}\small\item\em write communication watch-\/dog timer \end{DoxyCompactList}\end{DoxyCompactItemize} 17 | 18 | 19 | \subsection{Detailed Description} 20 | 21 | 22 | \subsection{Function Documentation} 23 | \hypertarget{group__setup_ga475a4fa0fac491307b10c4529ad6d2a0}{\index{Modbus Object Instantiation/\-Initialization@{Modbus Object Instantiation/\-Initialization}!begin@{begin}} 24 | \index{begin@{begin}!Modbus Object Instantiation/Initialization@{Modbus Object Instantiation/\-Initialization}} 25 | \subsubsection[{begin}]{\setlength{\rightskip}{0pt plus 5cm}void Modbus\-::begin ( 26 | \begin{DoxyParamCaption} 27 | \item[{long}]{u32speed} 28 | \end{DoxyParamCaption} 29 | )}}\label{group__setup_ga475a4fa0fac491307b10c4529ad6d2a0} 30 | 31 | 32 | Initialize class object. 33 | 34 | Sets up the serial port using specified baud rate. Call once class has been instantiated, typically within setup(). 35 | 36 | \begin{DoxySeeAlso}{See Also} 37 | \href{http://arduino.cc/en/Serial/Begin#.Uy4CJ6aKlHY}{\tt http\-://arduino.\-cc/en/\-Serial/\-Begin\#.\-Uy4\-C\-J6a\-Kl\-H\-Y} 38 | \end{DoxySeeAlso} 39 | 40 | \begin{DoxyParams}{Parameters} 41 | {\em speed} & baud rate, in standard increments (300..115200) \\ 42 | \hline 43 | {\em config} & data frame settings (data length, parity and stop bits) \\ 44 | \hline 45 | \end{DoxyParams} 46 | 47 | 48 | Definition at line 250 of file Modbus\-Rtu.\-h. 49 | 50 | \hypertarget{group__setup_ga6449894306ff8cc5d4caff09b1b0d1ce}{\index{Modbus Object Instantiation/\-Initialization@{Modbus Object Instantiation/\-Initialization}!get\-I\-D@{get\-I\-D}} 51 | \index{get\-I\-D@{get\-I\-D}!Modbus Object Instantiation/Initialization@{Modbus Object Instantiation/\-Initialization}} 52 | \subsubsection[{get\-I\-D}]{\setlength{\rightskip}{0pt plus 5cm}uint8\-\_\-t Modbus\-::get\-I\-D ( 53 | \begin{DoxyParamCaption} 54 | {} 55 | \end{DoxyParamCaption} 56 | )}}\label{group__setup_ga6449894306ff8cc5d4caff09b1b0d1ce} 57 | 58 | 59 | get slave I\-D between 1 and 247 60 | 61 | Method to read current slave I\-D address. 62 | 63 | \begin{DoxyReturn}{Returns} 64 | u8id current slave address between 1 and 247 65 | \end{DoxyReturn} 66 | 67 | 68 | Definition at line 323 of file Modbus\-Rtu.\-h. 69 | 70 | \hypertarget{group__setup_ga101809cdd4734537bab58dc315a840b4}{\index{Modbus Object Instantiation/\-Initialization@{Modbus Object Instantiation/\-Initialization}!Modbus@{Modbus}} 71 | \index{Modbus@{Modbus}!Modbus Object Instantiation/Initialization@{Modbus Object Instantiation/\-Initialization}} 72 | \subsubsection[{Modbus}]{\setlength{\rightskip}{0pt plus 5cm}Modbus\-::\-Modbus ( 73 | \begin{DoxyParamCaption} 74 | {} 75 | \end{DoxyParamCaption} 76 | )}}\label{group__setup_ga101809cdd4734537bab58dc315a840b4} 77 | 78 | 79 | Default Constructor for Master through Serial. 80 | 81 | 82 | 83 | Definition at line 204 of file Modbus\-Rtu.\-h. 84 | 85 | \hypertarget{group__setup_ga9bd497e97ac1777d4f0d4171078d60e0}{\index{Modbus Object Instantiation/\-Initialization@{Modbus Object Instantiation/\-Initialization}!set\-I\-D@{set\-I\-D}} 86 | \index{set\-I\-D@{set\-I\-D}!Modbus Object Instantiation/Initialization@{Modbus Object Instantiation/\-Initialization}} 87 | \subsubsection[{set\-I\-D}]{\setlength{\rightskip}{0pt plus 5cm}void Modbus\-::set\-I\-D ( 88 | \begin{DoxyParamCaption} 89 | \item[{uint8\-\_\-t}]{u8id} 90 | \end{DoxyParamCaption} 91 | )}}\label{group__setup_ga9bd497e97ac1777d4f0d4171078d60e0} 92 | 93 | 94 | write new I\-D for the slave 95 | 96 | Method to write a new slave I\-D address. 97 | 98 | 99 | \begin{DoxyParams}{Parameters} 100 | {\em u8id} & new slave address between 1 and 247 \\ 101 | \hline 102 | \end{DoxyParams} 103 | 104 | 105 | Definition at line 310 of file Modbus\-Rtu.\-h. 106 | 107 | \hypertarget{group__setup_gaf828190ebe24efb1b3b1957429f3872e}{\index{Modbus Object Instantiation/\-Initialization@{Modbus Object Instantiation/\-Initialization}!set\-Time\-Out@{set\-Time\-Out}} 108 | \index{set\-Time\-Out@{set\-Time\-Out}!Modbus Object Instantiation/Initialization@{Modbus Object Instantiation/\-Initialization}} 109 | \subsubsection[{set\-Time\-Out}]{\setlength{\rightskip}{0pt plus 5cm}void Modbus\-::set\-Time\-Out ( 110 | \begin{DoxyParamCaption} 111 | \item[{uint16\-\_\-t}]{u16time\-Out} 112 | \end{DoxyParamCaption} 113 | )}}\label{group__setup_gaf828190ebe24efb1b3b1957429f3872e} 114 | 115 | 116 | write communication watch-\/dog timer 117 | 118 | Initialize time-\/out parameter. 119 | 120 | Call once class has been instantiated, typically within setup(). The time-\/out timer is reset each time that there is a successful communication between Master and Slave. It works for both. 121 | 122 | 123 | \begin{DoxyParams}{Parameters} 124 | {\em time-\/out} & value (ms) \\ 125 | \hline 126 | \end{DoxyParams} 127 | 128 | 129 | Definition at line 338 of file Modbus\-Rtu.\-h. 130 | 131 | -------------------------------------------------------------------------------- /documentation/latex/modules.tex: -------------------------------------------------------------------------------- 1 | \section{Modules} 2 | Here is a list of all modules\-:\begin{DoxyCompactList} 3 | \item \contentsline{section}{Modbus Object Instantiation/\-Initialization}{\pageref{group__setup}}{} 4 | \item \contentsline{section}{Modbus Object Management}{\pageref{group__loop}}{} 5 | \item \contentsline{section}{Modbus Buffer Management}{\pageref{group__buffer}}{} 6 | \item \contentsline{section}{Modbus Function Codes for Discrete Coils/\-Inputs}{\pageref{group__discrete}}{} 7 | \item \contentsline{section}{Modbus Function Codes for Holding/\-Input Registers}{\pageref{group__register}}{} 8 | \end{DoxyCompactList} 9 | -------------------------------------------------------------------------------- /documentation/latex/refman.tex: -------------------------------------------------------------------------------- 1 | \documentclass[twoside]{book} 2 | 3 | % Packages required by doxygen 4 | \usepackage{calc} 5 | \usepackage{doxygen} 6 | \usepackage{graphicx} 7 | \usepackage[utf8]{inputenc} 8 | \usepackage{makeidx} 9 | \usepackage{multicol} 10 | \usepackage{multirow} 11 | \usepackage{textcomp} 12 | \usepackage[table]{xcolor} 13 | 14 | % Font selection 15 | \usepackage[T1]{fontenc} 16 | \usepackage{mathptmx} 17 | \usepackage[scaled=.90]{helvet} 18 | \usepackage{courier} 19 | \usepackage{amssymb} 20 | \usepackage{sectsty} 21 | \renewcommand{\familydefault}{\sfdefault} 22 | \allsectionsfont{% 23 | \fontseries{bc}\selectfont% 24 | \color{darkgray}% 25 | } 26 | \renewcommand{\DoxyLabelFont}{% 27 | \fontseries{bc}\selectfont% 28 | \color{darkgray}% 29 | } 30 | 31 | % Page & text layout 32 | \usepackage{geometry} 33 | \geometry{% 34 | a4paper,% 35 | top=2.5cm,% 36 | bottom=2.5cm,% 37 | left=2.5cm,% 38 | right=2.5cm% 39 | } 40 | \tolerance=750 41 | \hfuzz=15pt 42 | \hbadness=750 43 | \setlength{\emergencystretch}{15pt} 44 | \setlength{\parindent}{0cm} 45 | \setlength{\parskip}{0.2cm} 46 | \makeatletter 47 | \renewcommand{\paragraph}{% 48 | \@startsection{paragraph}{4}{0ex}{-1.0ex}{1.0ex}{% 49 | \normalfont\normalsize\bfseries\SS@parafont% 50 | }% 51 | } 52 | \renewcommand{\subparagraph}{% 53 | \@startsection{subparagraph}{5}{0ex}{-1.0ex}{1.0ex}{% 54 | \normalfont\normalsize\bfseries\SS@subparafont% 55 | }% 56 | } 57 | \makeatother 58 | 59 | % Headers & footers 60 | \usepackage{fancyhdr} 61 | \pagestyle{fancyplain} 62 | \fancyhead[LE]{\fancyplain{}{\bfseries\thepage}} 63 | \fancyhead[CE]{\fancyplain{}{}} 64 | \fancyhead[RE]{\fancyplain{}{\bfseries\leftmark}} 65 | \fancyhead[LO]{\fancyplain{}{\bfseries\rightmark}} 66 | \fancyhead[CO]{\fancyplain{}{}} 67 | \fancyhead[RO]{\fancyplain{}{\bfseries\thepage}} 68 | \fancyfoot[LE]{\fancyplain{}{}} 69 | \fancyfoot[CE]{\fancyplain{}{}} 70 | \fancyfoot[RE]{\fancyplain{}{\bfseries\scriptsize Generated on Tue Sep 9 2014 21:52:15 for Modbus Master and Slave for Arduino by Doxygen }} 71 | \fancyfoot[LO]{\fancyplain{}{\bfseries\scriptsize Generated on Tue Sep 9 2014 21:52:15 for Modbus Master and Slave for Arduino by Doxygen }} 72 | \fancyfoot[CO]{\fancyplain{}{}} 73 | \fancyfoot[RO]{\fancyplain{}{}} 74 | \renewcommand{\footrulewidth}{0.4pt} 75 | \renewcommand{\chaptermark}[1]{% 76 | \markboth{#1}{}% 77 | } 78 | \renewcommand{\sectionmark}[1]{% 79 | \markright{\thesection\ #1}% 80 | } 81 | 82 | % Indices & bibliography 83 | \usepackage{natbib} 84 | \usepackage[titles]{tocloft} 85 | \setcounter{tocdepth}{3} 86 | \setcounter{secnumdepth}{5} 87 | \makeindex 88 | 89 | % Hyperlinks (required, but should be loaded last) 90 | \usepackage{ifpdf} 91 | \ifpdf 92 | \usepackage[pdftex,pagebackref=true]{hyperref} 93 | \else 94 | \usepackage[ps2pdf,pagebackref=true]{hyperref} 95 | \fi 96 | \hypersetup{% 97 | colorlinks=true,% 98 | linkcolor=blue,% 99 | citecolor=blue,% 100 | unicode% 101 | } 102 | 103 | % Custom commands 104 | \newcommand{\clearemptydoublepage}{% 105 | \newpage{\pagestyle{empty}\cleardoublepage}% 106 | } 107 | 108 | 109 | %===== C O N T E N T S ===== 110 | 111 | \begin{document} 112 | 113 | % Titlepage & ToC 114 | \hypersetup{pageanchor=false} 115 | \pagenumbering{roman} 116 | \begin{titlepage} 117 | \vspace*{7cm} 118 | \begin{center}% 119 | {\Large Modbus Master and Slave for Arduino \\[1ex]\large 1.\-2 }\\ 120 | \vspace*{1cm} 121 | {\large Generated by Doxygen 1.8.4}\\ 122 | \vspace*{0.5cm} 123 | {\small Tue Sep 9 2014 21:52:15}\\ 124 | \end{center} 125 | \end{titlepage} 126 | \clearemptydoublepage 127 | \tableofcontents 128 | \clearemptydoublepage 129 | \pagenumbering{arabic} 130 | \hypersetup{pageanchor=true} 131 | 132 | %--- Begin generated contents --- 133 | \chapter{Todo List} 134 | \label{todo} 135 | \hypertarget{todo}{} 136 | \input{todo} 137 | \chapter{Module Index} 138 | \input{modules} 139 | \chapter{Class Index} 140 | \input{annotated} 141 | \chapter{File Index} 142 | \input{files} 143 | \chapter{Module Documentation} 144 | \input{group__setup} 145 | \include{group__loop} 146 | \include{group__buffer} 147 | \include{group__discrete} 148 | \include{group__register} 149 | \chapter{Class Documentation} 150 | \input{class_modbus} 151 | \input{structmodbus__t} 152 | \chapter{File Documentation} 153 | \input{_modbus_rtu_8h} 154 | %--- End generated contents --- 155 | 156 | % Index 157 | \newpage 158 | \phantomsection 159 | \addcontentsline{toc}{part}{Index} 160 | \printindex 161 | 162 | \end{document} 163 | -------------------------------------------------------------------------------- /documentation/latex/structmodbus__t.tex: -------------------------------------------------------------------------------- 1 | \hypertarget{structmodbus__t}{\section{modbus\-\_\-t Struct Reference} 2 | \label{structmodbus__t}\index{modbus\-\_\-t@{modbus\-\_\-t}} 3 | } 4 | 5 | 6 | Master query structure\-: This includes all the necessary fields to make the Master generate a \hyperlink{class_modbus}{Modbus} query. A Master may keep several of these structures and send them cyclically or use them according to program needs. 7 | 8 | 9 | 10 | 11 | {\ttfamily \#include $<$Modbus\-Rtu.\-h$>$} 12 | 13 | \subsection*{Public Attributes} 14 | \begin{DoxyCompactItemize} 15 | \item 16 | uint8\-\_\-t \hyperlink{structmodbus__t_af78ad11f93e63022a1c279de7206358c}{u8id} 17 | \item 18 | uint8\-\_\-t \hyperlink{structmodbus__t_a57d1630d4548e5d50d79e206a48b09bc}{u8fct} 19 | \item 20 | uint16\-\_\-t \hyperlink{structmodbus__t_a224ead9ff72467696e94fba9cf06bd3c}{u16\-Reg\-Add} 21 | \item 22 | uint16\-\_\-t \hyperlink{structmodbus__t_a5b9cee9c1a9415d927543f6cf054eb43}{u16\-Coils\-No} 23 | \item 24 | uint16\-\_\-t $\ast$ \hyperlink{structmodbus__t_a36212dd6316cbffb8ea31b2a2f5ae1be}{au16reg} 25 | \end{DoxyCompactItemize} 26 | 27 | 28 | \subsection{Detailed Description} 29 | Master query structure\-: This includes all the necessary fields to make the Master generate a \hyperlink{class_modbus}{Modbus} query. A Master may keep several of these structures and send them cyclically or use them according to program needs. 30 | 31 | Definition at line 48 of file Modbus\-Rtu.\-h. 32 | 33 | 34 | 35 | \subsection{Member Data Documentation} 36 | \hypertarget{structmodbus__t_a36212dd6316cbffb8ea31b2a2f5ae1be}{\index{modbus\-\_\-t@{modbus\-\_\-t}!au16reg@{au16reg}} 37 | \index{au16reg@{au16reg}!modbus_t@{modbus\-\_\-t}} 38 | \subsubsection[{au16reg}]{\setlength{\rightskip}{0pt plus 5cm}uint16\-\_\-t$\ast$ modbus\-\_\-t\-::au16reg}}\label{structmodbus__t_a36212dd6316cbffb8ea31b2a2f5ae1be} 39 | Pointer to memory image in master 40 | 41 | Definition at line 53 of file Modbus\-Rtu.\-h. 42 | 43 | \hypertarget{structmodbus__t_a5b9cee9c1a9415d927543f6cf054eb43}{\index{modbus\-\_\-t@{modbus\-\_\-t}!u16\-Coils\-No@{u16\-Coils\-No}} 44 | \index{u16\-Coils\-No@{u16\-Coils\-No}!modbus_t@{modbus\-\_\-t}} 45 | \subsubsection[{u16\-Coils\-No}]{\setlength{\rightskip}{0pt plus 5cm}uint16\-\_\-t modbus\-\_\-t\-::u16\-Coils\-No}}\label{structmodbus__t_a5b9cee9c1a9415d927543f6cf054eb43} 46 | Number of coils or registers to access 47 | 48 | Definition at line 52 of file Modbus\-Rtu.\-h. 49 | 50 | \hypertarget{structmodbus__t_a224ead9ff72467696e94fba9cf06bd3c}{\index{modbus\-\_\-t@{modbus\-\_\-t}!u16\-Reg\-Add@{u16\-Reg\-Add}} 51 | \index{u16\-Reg\-Add@{u16\-Reg\-Add}!modbus_t@{modbus\-\_\-t}} 52 | \subsubsection[{u16\-Reg\-Add}]{\setlength{\rightskip}{0pt plus 5cm}uint16\-\_\-t modbus\-\_\-t\-::u16\-Reg\-Add}}\label{structmodbus__t_a224ead9ff72467696e94fba9cf06bd3c} 53 | Address of the first register to access at slave/s 54 | 55 | Definition at line 51 of file Modbus\-Rtu.\-h. 56 | 57 | \hypertarget{structmodbus__t_a57d1630d4548e5d50d79e206a48b09bc}{\index{modbus\-\_\-t@{modbus\-\_\-t}!u8fct@{u8fct}} 58 | \index{u8fct@{u8fct}!modbus_t@{modbus\-\_\-t}} 59 | \subsubsection[{u8fct}]{\setlength{\rightskip}{0pt plus 5cm}uint8\-\_\-t modbus\-\_\-t\-::u8fct}}\label{structmodbus__t_a57d1630d4548e5d50d79e206a48b09bc} 60 | Function code\-: 1, 2, 3, 4, 5, 6, 15 or 16 61 | 62 | Definition at line 50 of file Modbus\-Rtu.\-h. 63 | 64 | \hypertarget{structmodbus__t_af78ad11f93e63022a1c279de7206358c}{\index{modbus\-\_\-t@{modbus\-\_\-t}!u8id@{u8id}} 65 | \index{u8id@{u8id}!modbus_t@{modbus\-\_\-t}} 66 | \subsubsection[{u8id}]{\setlength{\rightskip}{0pt plus 5cm}uint8\-\_\-t modbus\-\_\-t\-::u8id}}\label{structmodbus__t_af78ad11f93e63022a1c279de7206358c} 67 | Slave address between 1 and 247. 0 means broadcast 68 | 69 | Definition at line 49 of file Modbus\-Rtu.\-h. 70 | 71 | 72 | 73 | The documentation for this struct was generated from the following file\-:\begin{DoxyCompactItemize} 74 | \item 75 | \hyperlink{_modbus_rtu_8h}{Modbus\-Rtu.\-h}\end{DoxyCompactItemize} 76 | -------------------------------------------------------------------------------- /documentation/latex/todo.tex: -------------------------------------------------------------------------------- 1 | 2 | \begin{DoxyRefList} 3 | \item[\label{todo__todo000001}% 4 | \hypertarget{todo__todo000001}{}% 5 | Member \hyperlink{group__loop_ga19398cabed57b6d085d014af6c149f54}{Modbus\-:\-:query} (\hyperlink{structmodbus__t}{modbus\-\_\-t} telegram)]finish function 15 6 | \end{DoxyRefList} -------------------------------------------------------------------------------- /examples/RS485_slave/RS485_slave.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Modbus slave example 3: 3 | * The purpose of this example is to link a data array 4 | * from the Arduino to an external device through RS485. 5 | * 6 | * Recommended Modbus Master: QModbus 7 | * http://qmodbus.sourceforge.net/ 8 | */ 9 | 10 | #include 11 | 12 | // assign the Arduino pin that must be connected to RE-DE RS485 transceiver 13 | #define TXEN 4 14 | 15 | // data array for modbus network sharing 16 | uint16_t au16data[16] = { 17 | 3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 }; 18 | 19 | /** 20 | * Modbus object declaration 21 | * u8id : node id = 0 for master, = 1..247 for slave 22 | * port : serial port 23 | * u8txenpin : 0 for RS-232 and USB-FTDI 24 | * or any pin number > 1 for RS-485 25 | */ 26 | Modbus slave(1,Serial,TXEN); // this is slave @1 and RS-485 27 | 28 | void setup() { 29 | Serial.begin( 19200 ); // baud-rate at 19200 30 | slave.start(); 31 | } 32 | 33 | void loop() { 34 | slave.poll( au16data, 16 ); 35 | } 36 | -------------------------------------------------------------------------------- /examples/advanced_master/advanced_master.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Modbus master example 2: 3 | * The purpose of this example is to query several sets of data 4 | * from an external Modbus slave device. 5 | * The link media can be USB or RS232. 6 | * 7 | * Recommended Modbus slave: 8 | * diagslave http://www.modbusdriver.com/diagslave.html 9 | * 10 | * In a Linux box, run 11 | * "./diagslave /dev/ttyUSB0 -b 19200 -d 8 -s 1 -p none -m rtu -a 1" 12 | * This is: 13 | * serial port /dev/ttyUSB0 at 19200 baud 8N1 14 | * RTU mode and address @1 15 | */ 16 | 17 | #include 18 | 19 | uint16_t au16data[16]; //!< data array for modbus network sharing 20 | uint8_t u8state; //!< machine state 21 | uint8_t u8query; //!< pointer to message query 22 | 23 | /** 24 | * Modbus object declaration 25 | * u8id : node id = 0 for master, = 1..247 for slave 26 | * port : serial port 27 | * u8txenpin : 0 for RS-232 and USB-FTDI 28 | * or any pin number > 1 for RS-485 29 | */ 30 | Modbus master(0,Serial,0); // this is master and RS-232 or USB-FTDI 31 | 32 | /** 33 | * This is an structe which contains a query to an slave device 34 | */ 35 | modbus_t telegram[2]; 36 | 37 | unsigned long u32wait; 38 | 39 | void setup() { 40 | // telegram 0: read registers 41 | telegram[0].u8id = 1; // slave address 42 | telegram[0].u8fct = 3; // function code (this one is registers read) 43 | telegram[0].u16RegAdd = 0; // start address in slave 44 | telegram[0].u16CoilsNo = 4; // number of elements (coils or registers) to read 45 | telegram[0].au16reg = au16data; // pointer to a memory array in the Arduino 46 | 47 | // telegram 1: write a single register 48 | telegram[1].u8id = 1; // slave address 49 | telegram[1].u8fct = 6; // function code (this one is write a single register) 50 | telegram[1].u16RegAdd = 4; // start address in slave 51 | telegram[1].u16CoilsNo = 1; // number of elements (coils or registers) to read 52 | telegram[1].au16reg = au16data+4; // pointer to a memory array in the Arduino 53 | 54 | Serial.begin( 19200 ); // baud-rate at 19200 55 | master.start(); 56 | master.setTimeOut( 5000 ); // if there is no answer in 5000 ms, roll over 57 | u32wait = millis() + 1000; 58 | u8state = u8query = 0; 59 | } 60 | 61 | void loop() { 62 | switch( u8state ) { 63 | case 0: 64 | if (millis() > u32wait) u8state++; // wait state 65 | break; 66 | case 1: 67 | master.query( telegram[u8query] ); // send query (only once) 68 | u8state++; 69 | u8query++; 70 | if (u8query > 2) u8query = 0; 71 | break; 72 | case 2: 73 | master.poll(); // check incoming messages 74 | if (master.getState() == COM_IDLE) { 75 | u8state = 0; 76 | u32wait = millis() + 1000; 77 | } 78 | break; 79 | } 80 | 81 | au16data[4] = analogRead( 0 ); 82 | 83 | } 84 | 85 | -------------------------------------------------------------------------------- /examples/advanced_slave/advanced_slave.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Modbus slave example 2: 3 | * The purpose of this example is to link the Arduino digital and analog 4 | * pins to an external device. 5 | * 6 | * Recommended Modbus Master: QModbus 7 | * http://qmodbus.sourceforge.net/ 8 | * 9 | * Editado al español por LuxARTS 10 | */ 11 | 12 | //Incluye la librería del protocolo Modbus 13 | #include 14 | #define ID 1 15 | 16 | //Crear instancia 17 | Modbus slave(ID, Serial, 0); //ID del nodo. 0 para el master, 1-247 para esclavo 18 | //Puerto serie (0 = TX: 1 - RX: 0) 19 | //Protocolo serie. 0 para RS-232 + USB (default), cualquier pin mayor a 1 para RS-485 20 | boolean led; 21 | int8_t state = 0; 22 | unsigned long tempus; 23 | 24 | uint16_t au16data[9]; //La tabla de registros que se desea compartir por la red 25 | 26 | /********************************************************* 27 | Configuración del programa 28 | *********************************************************/ 29 | void setup() { 30 | io_setup(); //configura las entradas y salidas 31 | 32 | Serial.begin(19200); //Abre la comunicación como esclavo 33 | slave.start(); 34 | tempus = millis() + 100; //Guarda el tiempo actual + 100ms 35 | digitalWrite(13, HIGH ); //Prende el led del pin 13 (el de la placa) 36 | } 37 | 38 | /********************************************************* 39 | Inicio del programa 40 | *********************************************************/ 41 | void loop() { 42 | //Comprueba el buffer de entrada 43 | state = slave.poll( au16data, 9 ); //Parámetros: Tabla de registros para el intercambio de info 44 | // Tamaño de la tabla de registros 45 | //Devuelve 0 si no hay pedido de datos 46 | //Devuelve 1 al 4 si hubo error de comunicación 47 | //Devuelve mas de 4 si se procesó correctamente el pedido 48 | 49 | if (state > 4) { //Si es mayor a 4 = el pedido fué correcto 50 | tempus = millis() + 50; //Tiempo actual + 50ms 51 | digitalWrite(13, HIGH);//Prende el led 52 | } 53 | if (millis() > tempus) digitalWrite(13, LOW );//Apaga el led 50ms después 54 | 55 | //Actualiza los pines de Arduino con la tabla de Modbus 56 | io_poll(); 57 | } 58 | 59 | /** 60 | * pin maping: 61 | * 2 - digital input 62 | * 3 - digital input 63 | * 4 - digital input 64 | * 5 - digital input 65 | * 6 - digital output 66 | * 7 - digital output 67 | * 8 - digital output 68 | * 9 - digital output 69 | * 10 - analog output 70 | * 11 - analog output 71 | * 14 - analog input 72 | * 15 - analog input 73 | * 74 | * pin 13 reservado para ver el estado de la comunicación 75 | */ 76 | void io_setup() { 77 | pinMode(2, INPUT); 78 | pinMode(3, INPUT); 79 | pinMode(4, INPUT); 80 | pinMode(5, INPUT); 81 | pinMode(6, OUTPUT); 82 | pinMode(7, OUTPUT); 83 | pinMode(8, OUTPUT); 84 | pinMode(9, OUTPUT); 85 | pinMode(10, OUTPUT); 86 | pinMode(11, OUTPUT); 87 | pinMode(13, OUTPUT); 88 | 89 | digitalWrite(6, LOW ); 90 | digitalWrite(7, LOW ); 91 | digitalWrite(8, LOW ); 92 | digitalWrite(9, LOW ); 93 | digitalWrite(13, HIGH ); //Led del pin 13 de la placa 94 | analogWrite(10, 0 ); //PWM 0% 95 | analogWrite(11, 0 ); //PWM 0% 96 | } 97 | 98 | /********************************************************* 99 | Enlaza la tabla de registros con los pines 100 | *********************************************************/ 101 | void io_poll() { 102 | // digital inputs -> au16data[0] 103 | // Lee las entradas digitales y las guarda en bits de la primera variable del vector 104 | // (es lo mismo que hacer una máscara) 105 | bitWrite( au16data[0], 0, digitalRead( 2 )); //Lee el pin 2 de Arduino y lo guarda en el bit 0 de la variable au16data[0] 106 | bitWrite( au16data[0], 1, digitalRead( 3 )); 107 | bitWrite( au16data[0], 2, digitalRead( 4 )); 108 | bitWrite( au16data[0], 3, digitalRead( 5 )); 109 | 110 | // digital outputs -> au16data[1] 111 | // Lee los bits de la segunda variable y los pone en las salidas digitales 112 | digitalWrite( 6, bitRead( au16data[1], 0 )); //Lee el bit 0 de la variable au16data[1] y lo pone en el pin 6 de Arduino 113 | digitalWrite( 7, bitRead( au16data[1], 1 )); 114 | digitalWrite( 8, bitRead( au16data[1], 2 )); 115 | digitalWrite( 9, bitRead( au16data[1], 3 )); 116 | 117 | // Cambia el valor del PWM 118 | analogWrite( 10, au16data[2] ); //El valor de au16data[2] se escribe en la salida de PWM del pin 10 de Arduino. (siendo 0=0% y 255=100%) 119 | analogWrite( 11, au16data[3] ); 120 | 121 | // Lee las entradas analógicas (ADC) 122 | au16data[4] = analogRead( 0 ); //El valor analógico leido en el pin A0 se guarda en au16data[4]. (siendo 0=0v y 1023=5v) 123 | au16data[5] = analogRead( 1 ); 124 | 125 | // Diagnóstico de la comunicación (para debug) 126 | au16data[6] = slave.getInCnt(); //Devuelve cuantos mensajes se recibieron 127 | au16data[7] = slave.getOutCnt(); //Devuelve cuantos mensajes se transmitieron 128 | au16data[8] = slave.getErrCnt(); //Devuelve cuantos errores hubieron 129 | } 130 | -------------------------------------------------------------------------------- /examples/simple_master/simple_master.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Modbus master example 1: 3 | * The purpose of this example is to query an array of data 4 | * from an external Modbus slave device. 5 | * The link media can be USB or RS232. 6 | * 7 | * Recommended Modbus slave: 8 | * diagslave http://www.modbusdriver.com/diagslave.html 9 | * 10 | * In a Linux box, run 11 | * "./diagslave /dev/ttyUSB0 -b 19200 -d 8 -s 1 -p none -m rtu -a 1" 12 | * This is: 13 | * serial port /dev/ttyUSB0 at 19200 baud 8N1 14 | * RTU mode and address @1 15 | */ 16 | 17 | #include 18 | 19 | // data array for modbus network sharing 20 | uint16_t au16data[16]; 21 | uint8_t u8state; 22 | 23 | /** 24 | * Modbus object declaration 25 | * u8id : node id = 0 for master, = 1..247 for slave 26 | * port : serial port 27 | * u8txenpin : 0 for RS-232 and USB-FTDI 28 | * or any pin number > 1 for RS-485 29 | */ 30 | Modbus master(0,Serial,0); // this is master and RS-232 or USB-FTDI 31 | 32 | /** 33 | * This is an structe which contains a query to an slave device 34 | */ 35 | modbus_t telegram; 36 | 37 | unsigned long u32wait; 38 | 39 | void setup() { 40 | Serial.begin( 19200 ); // baud-rate at 19200 41 | master.start(); 42 | master.setTimeOut( 2000 ); // if there is no answer in 2000 ms, roll over 43 | u32wait = millis() + 1000; 44 | u8state = 0; 45 | } 46 | 47 | void loop() { 48 | switch( u8state ) { 49 | case 0: 50 | if (millis() > u32wait) u8state++; // wait state 51 | break; 52 | case 1: 53 | telegram.u8id = 1; // slave address 54 | telegram.u8fct = 3; // function code (this one is registers read) 55 | telegram.u16RegAdd = 1; // start address in slave 56 | telegram.u16CoilsNo = 4; // number of elements (coils or registers) to read 57 | telegram.au16reg = au16data; // pointer to a memory array in the Arduino 58 | 59 | master.query( telegram ); // send query (only once) 60 | u8state++; 61 | break; 62 | case 2: 63 | master.poll(); // check incoming messages 64 | if (master.getState() == COM_IDLE) { 65 | u8state = 0; 66 | u32wait = millis() + 100; 67 | } 68 | break; 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /examples/simple_slave/simple_slave.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Modbus slave example 1: 3 | * The purpose of this example is to link a data array 4 | * from the Arduino to an external device. 5 | * 6 | * Recommended Modbus Master: QModbus 7 | * http://qmodbus.sourceforge.net/ 8 | */ 9 | 10 | #include 11 | 12 | // data array for modbus network sharing 13 | uint16_t au16data[16] = { 14 | 3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 }; 15 | 16 | /** 17 | * Modbus object declaration 18 | * u8id : node id = 0 for master, = 1..247 for slave 19 | * port : serial port 20 | * u8txenpin : 0 for RS-232 and USB-FTDI 21 | * or any pin number > 1 for RS-485 22 | */ 23 | Modbus slave(1,Serial,0); // this is slave @1 and RS-232 or USB-FTDI 24 | 25 | void setup() { 26 | Serial.begin( 19200 ); // baud-rate at 19200 27 | slave.start(); 28 | } 29 | 30 | void loop() { 31 | slave.poll( au16data, 16 ); 32 | } 33 | -------------------------------------------------------------------------------- /examples/simple_slave2/simple_slave2.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Modbus slave example 2: 3 | * The purpose of this example is to link a data array 4 | * from the Arduino to an external device. 5 | * 6 | * Recommended Modbus Master: modpoll 7 | * http://www.modbusdriver.com/modpoll.html 8 | */ 9 | 10 | #include 11 | 12 | // data array for modbus network sharing 13 | uint16_t au16data[16] = { 14 | 3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 }; 15 | 16 | /** 17 | * Modbus object declaration 18 | * u8id : node id = 0 for master, = 1..247 for slave 19 | * port : serial port 20 | * u8txenpin : 0 for RS-232 and USB-FTDI 21 | * or any pin number > 1 for RS-485 22 | */ 23 | Modbus slave(1,Serial,0); // this is slave @1 and RS-232 or USB-FTDI 24 | 25 | void setup() { 26 | Serial.begin( 19200, SERIAL_8E1 ); // 19200 baud, 8-bits, even, 1-bit stop 27 | slave.start(); 28 | } 29 | 30 | void loop() { 31 | slave.poll( au16data, 16 ); 32 | } 33 | -------------------------------------------------------------------------------- /examples/software_serial_simple_master/software_serial_simple_master.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Modbus master example 2: 3 | * The purpose of this example is to query an array of data 4 | * from an external Modbus slave device. 5 | * This example is similar to "simple_master", but this example 6 | * allows you to use software serial instead of hardware serial 7 | * in case that you want to use D1 & D2 for other purposes. 8 | * The link media can be USB or RS232. 9 | 10 | The circuit: 11 | * software serial rx(D3) connect to tx pin of another device 12 | * software serial tx(D4) connect to rx pin of another device 13 | 14 | * In this example, we will use two important methods so that we can use 15 | * software serial. 16 | * 17 | * 1. Modbus::Modbus(uint8_t u8id) 18 | * This is a constructor for a Master/Slave through USB/RS232C via software serial 19 | * This constructor only specifies u8id (node address) and should be only 20 | * used if you want to use software serial instead of hardware serial. 21 | * This method is called if you create a ModBus object with only on parameter "u8id" 22 | * u8id is the node address of the arduino that will be programmed on, 23 | * 0 for master and 1..247 for slave 24 | * for example: Modbus master(0); 25 | * If you use this constructor you have to begin ModBus object by 26 | * using "void Modbus::begin(SoftwareSerial *softPort, long u32speed)". 27 | * 28 | * 2. void Modbus::begin(SoftwareSerial *sPort, long u32speed) 29 | * Initialize class object. 30 | * This is the method you have to use if you construct the ModBus object by using 31 | * Modbus::Modbus(uint8_t u8id) in order to use software serial and to avoid problems. 32 | * You have to create a SoftwareSerial object on your own, as shown in the example. 33 | * sPort is a pointer to your SoftwareSerial object, u32speed is the baud rate, in 34 | * standard increments (300..115200) 35 | 36 | created long time ago 37 | by smarmengol 38 | modified 29 July 2016 39 | by Helium6072 40 | 41 | This example code is in the public domain. 42 | */ 43 | 44 | #include 45 | #include 46 | 47 | // data array for modbus network sharing 48 | uint16_t au16data[16]; 49 | uint8_t u8state; 50 | 51 | SoftwareSerial mySerial(3, 5);//Create a SoftwareSerial object so that we can use software serial. Search "software serial" on Arduino.cc to find out more details. 52 | 53 | /** 54 | * Modbus object declaration 55 | * u8id : node id = 0 for master, = 1..247 for slave 56 | * port : serial port 57 | * u8txenpin : 0 for RS-232 and USB-FTDI 58 | * or any pin number > 1 for RS-485 59 | */ 60 | Modbus master(0, mySerial); // this is master and RS-232 or USB-FTDI via software serial 61 | 62 | /** 63 | * This is an structe which contains a query to an slave device 64 | */ 65 | modbus_t telegram; 66 | 67 | unsigned long u32wait; 68 | 69 | void setup() { 70 | mySerial.begin(9600);//use the hardware serial if you want to connect to your computer via usb cable, etc. 71 | master.start(); // start the ModBus object. 72 | master.setTimeOut( 2000 ); // if there is no answer in 2000 ms, roll over 73 | u32wait = millis() + 1000; 74 | u8state = 0; 75 | } 76 | 77 | void loop() { 78 | switch( u8state ) { 79 | case 0: 80 | if (millis() > u32wait) u8state++; // wait state 81 | break; 82 | case 1: 83 | telegram.u8id = 104; // slave address 84 | telegram.u8fct = 4; // function code (this one is registers read) 85 | telegram.u16RegAdd = 3; // start address in slave 86 | telegram.u16CoilsNo = 1; // number of elements (coils or registers) to read 87 | telegram.au16reg = au16data; // pointer to a memory array in the Arduino 88 | 89 | master.query( telegram ); // send query (only once) 90 | u8state++; 91 | break; 92 | case 2: 93 | master.poll(); // check incoming messages 94 | if (master.getState() == COM_IDLE) { 95 | u8state = 0; 96 | u32wait = millis() + 2000; 97 | Serial.println(au16data[0]);//Or do something else! 98 | } 99 | break; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For Modbus-Master-Slave 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | modbus_t KEYWORD1 9 | 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | begin KEYWORD2 14 | poll KEYWORD2 15 | getInCnt KEYWORD2 16 | getOutCnt KEYWORD2 17 | getErrCnt KEYWORD2 18 | getID KEYWORD2 19 | getState KEYWORD2 20 | query KEYWORD2 21 | setTimeOut KEYWORD2 22 | 23 | ####################################### 24 | # Instances (KEYWORD2) 25 | ####################################### 26 | Modbus KEYWORD2 27 | 28 | ####################################### 29 | # Constants (LITERAL1) 30 | ####################################### 31 | --------------------------------------------------------------------------------