Skip to content

Commit

Permalink
FreeModBus is now integrated with the Nuttx configuration system
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4961 42af7a65-404d-4744-a932-0658087f49c3
  • Loading branch information
patacongo committed Jul 21, 2012
1 parent 2c2d649 commit 3ca48e3
Show file tree
Hide file tree
Showing 22 changed files with 974 additions and 220 deletions.
4 changes: 4 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ menu "Network Utilities"
source "$APPSDIR/netutils/Kconfig"
endmenu

menu "ModBus"
source "$APPSDIR/modbus/Kconfig"
endmenu

menu "NSH Library"
source "$APPSDIR/nshlib/Kconfig"
endmenu
Expand Down
8 changes: 4 additions & 4 deletions include/modbus/mb.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ eMBErrorCode eMBPoll( void );
* \brief Configure the slave id of the device.
*
* This function should be called when the Modbus function <em>Report Slave ID</em>
* is enabled ( By defining MB_FUNC_OTHER_REP_SLAVEID_ENABLED in mbconfig.h ).
* is enabled (By defining CONFIG_MB_FUNC_OTHER_REP_SLAVEID_ENABLED in .config ).
*
* \param ucSlaveID Values is returned in the <em>Slave ID</em> byte of the
* <em>Report Slave ID</em> response.
Expand All @@ -234,8 +234,8 @@ eMBErrorCode eMBPoll( void );
* bytes of the <em> Report Slave ID</em> response.
* \param usAdditionalLen Length of the buffer <code>pucAdditonal</code>.
*
* \return If the static buffer defined by MB_FUNC_OTHER_REP_SLAVEID_BUF in
* mbconfig.h is to small it returns eMBErrorCode::MB_ENORES. Otherwise
* \return If the static buffer defined by CONFIG_MB_FUNC_OTHER_REP_SLAVEID_BUF
* is too small it returns eMBErrorCode::MB_ENORES. Otherwise
* it returns eMBErrorCode::MB_ENOERR.
*/
eMBErrorCode eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning,
Expand All @@ -259,7 +259,7 @@ eMBErrorCode eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning,
*
* \return eMBErrorCode::MB_ENOERR if the handler has been installed. If no
* more resources are available it returns eMBErrorCode::MB_ENORES. In this
* case the values in mbconfig.h should be adjusted. If the argument was not
* case the values in config.h should be adjusted. If the argument was not
* valid it returns eMBErrorCode::MB_EINVAL.
*/
eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode,
Expand Down
132 changes: 0 additions & 132 deletions include/modbus/mbconfig.h

This file was deleted.

20 changes: 10 additions & 10 deletions include/modbus/mbfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,43 @@
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
#endif
#if MB_FUNC_OTHER_REP_SLAVEID_BUF > 0
#ifdef CONFIG_MB_FUNC_OTHER_REP_SLAVEID_BUF
eMBException eMBFuncReportSlaveID( UCHAR * pucFrame, USHORT * usLen );
#endif

#if MB_FUNC_READ_INPUT_ENABLED > 0
#ifdef CONFIG_MB_FUNC_READ_INPUT_ENABLED
eMBException eMBFuncReadInputRegister( UCHAR * pucFrame, USHORT * usLen );
#endif

#if MB_FUNC_READ_HOLDING_ENABLED > 0
#ifdef CONFIG_MB_FUNC_READ_HOLDING_ENABLED
eMBException eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
#endif

#if MB_FUNC_WRITE_HOLDING_ENABLED > 0
#ifdef CONFIG_MB_FUNC_WRITE_HOLDING_ENABLED
eMBException eMBFuncWriteHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
#endif

#if MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED > 0
#ifdef CONFIG_MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED
eMBException eMBFuncWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
#endif

#if MB_FUNC_READ_COILS_ENABLED > 0
#ifdef CONFIG_MB_FUNC_READ_COILS_ENABLED
eMBException eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen );
#endif

#if MB_FUNC_WRITE_COIL_ENABLED > 0
#ifdef CONFIG_MB_FUNC_WRITE_COIL_ENABLED
eMBException eMBFuncWriteCoil( UCHAR * pucFrame, USHORT * usLen );
#endif

#if MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED > 0
#ifdef CONFIG_MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED
eMBException eMBFuncWriteMultipleCoils( UCHAR * pucFrame, USHORT * usLen );
#endif

#if MB_FUNC_READ_DISCRETE_INPUTS_ENABLED > 0
#ifdef CONFIG_MB_FUNC_READ_DISCRETE_INPUTS_ENABLED
eMBException eMBFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen );
#endif

#if MB_FUNC_READWRITE_HOLDING_ENABLED > 0
#ifdef CONFIG_MB_FUNC_READWRITE_HOLDING_ENABLED
eMBException eMBFuncReadWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen );
#endif

Expand Down
139 changes: 139 additions & 0 deletions modbus/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#

comment "FreeModbus"

config MB_ASCII_ENABLED
bool "Modbus ASCII support"
depends on MODBUS
default y

config MB_RTU_ENABLED
bool "Modbus RTU support"
depends on MODBUS
default y

config MB_TCP_ENABLED
bool "Modbus TCP support"
depends on MODBUS
default y

config MB_ASCII_TIMEOUT_SEC
int "Character timeout"
depends on MB_ASCII_ENABLED
default 1
---help---
Character timeout value for Modbus ASCII

The character timeout value is not fixed for Modbus ASCII and is therefore
a configuration option. It should be set to the maximum expected delay
time of the network.

config MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS
int "Timeout to wait before sending"
depends on MB_ASCII_ENABLED
default 0
---help---
Timeout to wait in ASCII prior to enabling transmitter

If defined the function calls vMBPortSerialDelay with the argument
MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS to allow for a delay before
the serial transmitter is enabled. This is required because some
targets are so fast that there is no time between receiving and
transmitting the frame. If the master is to slow with enabling its
receiver then he will not receive the response correctly.

config MB_FUNC_HANDLERS_MAX
int "Maximum number of Modbus functions"
depends on MODBUS
default 16
---help---
Maximum number of Modbus functions codes the protocol stack should support.

The maximum number of supported Modbus functions must be greater than
the sum of all enabled functions in this file and custom function
handlers. If set to small adding more functions will fail.

config MB_FUNC_OTHER_REP_SLAVEID_BUF
int "Size of Slave ID report buffer"
depends on MB_FUNC_OTHER_REP_SLAVEID_ENABLED
default 32
---help---
Number of bytes which should be allocated for the Report Slave ID command.

This number limits the maximum size of the additional segment in the
report slave id function. See eMBSetSlaveID() for more information on
how to set this value. It is only used if MB_FUNC_OTHER_REP_SLAVEID_ENABLED
is set to 1.

config MB_FUNC_OTHER_REP_SLAVEID_ENABLED
bool "Report Slave ID function"
depends on MODBUS
default y
---help---
If the Report Slave ID function should be enabled.

config MB_FUNC_READ_INPUT_ENABLED
bool "Read Input Registers function"
depends on MODBUS
default y
---help---
If the Read Input Registers function should be enabled.

config MB_FUNC_READ_HOLDING_ENABLED
bool "Read Holding Registers function"
depends on MODBUS
default y
---help---
If the Read Holding Registers function should be enabled.

config MB_FUNC_WRITE_HOLDING_ENABLED
bool "Write Single Register function"
depends on MODBUS
default y
---help---
If the Write Single Register function should be enabled.

config MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED
bool "Write Multiple registers function"
depends on MODBUS
default y
---help---
If the Write Multiple registers function should be enabled.

config MB_FUNC_READ_COILS_ENABLED
bool "Read Coils function"
depends on MODBUS
default y
---help---
If the Read Coils function should be enabled.

config MB_FUNC_WRITE_COIL_ENABLED
bool "Write Coils function"
depends on MODBUS
default y
---help---
If the Write Coils function should be enabled.

config MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED
bool "Write Multiple Coils function"
depends on MODBUS
default y
---help---
If the Write Multiple Coils function should be enabled.

config MB_FUNC_READ_DISCRETE_INPUTS_ENABLED
bool "Read Discrete Inputs function"
depends on MODBUS
default y
---help---
If the Read Discrete Inputs function should be enabled.

config MB_FUNC_READWRITE_HOLDING_ENABLED
bool "Read/Write Multiple Registers function"
depends on MODBUS
default y
---help---
If the Read/Write Multiple Registers function should be enabled.
Loading

0 comments on commit 3ca48e3

Please sign in to comment.