Lines Matching full:the
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 * This module defines the interface for the application. It contains
42 * the basic functions and types required to use the Modbus Master protocol stack.
43 * A typical application will want to call eMBMasterInit() first. If the device
45 * the protocol stack. In the main loop the function eMBMasterPoll() must be called
46 * periodically. The time interval between pooling depends on the configured
48 * and the task should always call the function eMBMasterPoll().
53 * // Enable the Modbus Protocol Stack.
57 * // Call the main polling loop of the Modbus Master protocol stack.
67 * \brief Use the default Modbus Master TCP port (502)
73 * \brief Errorcodes used by all function in the Master request.
97 * \brief Initialize the Modbus Master protocol stack.
99 * This functions initializes the ASCII or RTU module and calls the
100 * init functions of the porting layer to prepare the hardware. Please
101 * note that the receiver is still disabled and no Modbus frames are
105 * \param ucPort The port to use. E.g. 1 for COM1 on windows. This value
107 * \param ulBaudRate The baudrate. E.g. 19200. Supported baudrates depend
108 * on the porting layer.
111 * \return If no error occurs the function returns eMBErrorCode::MB_ENOERR.
112 * The protocol is then in the disabled state and ready for activation
113 * by calling eMBMasterEnable( ). Otherwise one of the following error codes
115 * - eMBErrorCode::MB_EPORTERR IF the porting layer returned an error.
121 * \brief Initialize the Modbus Master protocol stack for Modbus TCP.
123 * This function initializes the Modbus TCP Module. Please note that
126 * \param usTCPPort The TCP port to listen on.
127 * \return If the protocol stack has been initialized correctly the function
128 * returns eMBErrorCode::MB_ENOERR. Otherwise one of the following error
130 * - eMBErrorCode::MB_EINVAL If the slave address was not valid. Valid
131 * slave addresses are in the range 1 - 247.
132 * - eMBErrorCode::MB_EPORTERR IF the porting layer returned an error.
137 * \brief Release resources used by the protocol stack.
139 * This function disables the Modbus Master protocol stack and release all
140 * hardware resources. It must only be called when the protocol stack
144 * get an callback must define the macro MB_PORT_HAS_CLOSE to 1.
146 * \return If the resources where released it return eMBErrorCode::MB_ENOERR.
147 * If the protocol stack is not in the disabled state it returns
153 * \brief Enable the Modbus Master protocol stack.
155 * This function enables processing of Modbus Master frames. Enabling the protocol
156 * stack is only possible if it is in the disabled state.
158 * \return If the protocol stack is now in the state enabled it returns
159 * eMBErrorCode::MB_ENOERR. If it was not in the disabled state it
165 * \brief Disable the Modbus Master protocol stack.
169 * \return If the protocol stack has been disabled it returns
170 * eMBErrorCode::MB_ENOERR. If it was not in the enabled state it returns
176 * \brief The main pooling loop of the Modbus Master protocol stack.
178 * This function must be called periodically. The timer interval required
179 * is given by the application dependent Modbus slave timeout. Internally the
180 * function calls xMBMasterPortEventGet() and waits for an event from the receiver or
183 * \return If the protocol stack is not in the enabled state the function
193 * The callback handler supplied is responsible for interpreting the Modbus PDU and
194 * the creation of an appropriate response. In case of an error it should return
195 * one of the possible Modbus exceptions which results in a Modbus exception frame
196 * sent by the protocol stack.
198 * \param ucFunctionCode The Modbus function code for which this handler should
199 * be registers. Valid function codes are in the range 1 to 127.
200 * \param pxHandler The function handler which should be called in case
204 * \return eMBErrorCode::MB_ENOERR if the handler has been installed. If no
206 * case the values in mbconfig.h should be adjusted. If the argument was not
216 * The protocol stack does not internally allocate any memory for the
217 * registers. This makes the protocol stack very small and also usable on
218 * low end targets. In addition the values don't have to be in the memory
220 * Whenever the protocol stack requires a value it calls one of the callback
221 * function with the register address and the number of registers to read
222 * as an argument. The application should then read the actual register values
223 * (for example the ADC voltage) and should store the result in the supplied
225 * If the protocol stack wants to update a register value because a write
226 * register function was received a buffer with the new register values is
227 * passed to the callback function. The function should then use these values
228 * to update the application register values.
232 * \brief Callback function used if the value of a <em>Input Register</em>
233 * is required by the protocol stack. The starting register address is given
234 * by \c usAddress and the last register is given by <tt>usAddress +
237 * \param pucRegBuffer A buffer where the callback function should write
238 * the current value of the modbus registers to.
239 * \param usAddress The starting address of the register. Input registers
240 * are in the range 1 - 65535.
241 * \param usNRegs Number of registers the callback function must supply.
243 * \return The function must return one of the following error codes:
246 * - eMBErrorCode::MB_ENOREG If the application does not map an coils
247 * within the requested address range. In this case a
255 * read or written by the protocol stack. The starting register address
256 * is given by \c usAddress and the last register is given by
259 * \param pucRegBuffer If the application registers values should be updated the
260 * buffer points to the new registers values. If the protocol stack needs
261 * to now the current values the callback function should write them into
263 * \param usAddress The starting address of the register.
265 * \param eMode If eMBRegisterMode::MB_REG_WRITE the application register
266 * values should be updated from the values in the buffer. For example
267 * this would be the case when the Modbus master has issued an
269 * If the value eMBRegisterMode::MB_REG_READ the application should copy
270 * the current values into the buffer \c pucRegBuffer.
272 * \return The function must return one of the following error codes:
275 * - eMBErrorCode::MB_ENOREG If the application does not map an coils
276 * within the requested address range. In this case a
284 * read or written by the protocol stack. If you are going to use
285 * this function you might use the functions xMBUtilSetBits( ) and
288 * \param pucRegBuffer The bits are packed in bytes where the first coil
289 * starting at address \c usAddress is stored in the LSB of the
290 * first byte in the buffer <code>pucRegBuffer</code>.
291 * If the buffer should be written by the callback function unused
294 * \param usAddress The first coil number.
296 * \param eMode If eMBRegisterMode::MB_REG_WRITE the application values should
297 * be updated from the values supplied in the buffer \c pucRegBuffer.
298 * If eMBRegisterMode::MB_REG_READ the application should store the current
299 * values in the buffer \c pucRegBuffer.
301 * \return The function must return one of the following error codes:
304 * - eMBErrorCode::MB_ENOREG If the application does not map an coils
305 * within the requested address range. In this case a
313 * read by the protocol stack.
315 * If you are going to use his function you might use the functions
318 * \param pucRegBuffer The buffer should be updated with the current
319 * coil values. The first discrete input starting at \c usAddress must be
320 * stored at the LSB of the first byte in the buffer. If the requested number
321 * is not a multiple of eight the remaining bits should be set to zero.
322 * \param usAddress The starting address of the first discrete input.
324 * \return The function must return one of the following error codes:
327 * - eMBErrorCode::MB_ENOREG If the application does not map an coils
328 * within the requested address range. In this case a