Skip to content

Commit

Permalink
add module definition
Browse files Browse the repository at this point in the history
  • Loading branch information
loogg committed Jan 7, 2024
1 parent a819bd8 commit 50bda72
Show file tree
Hide file tree
Showing 27 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ agile_modbus_slave_handle(ctx, read_len, 0, agile_modbus_slave_util_callback, &s

- Interface calling process

![SlaveCallback](./figures/SlaveCallback.jpg)
![agile_modbus_slave_util_callback](./figures/agile_modbus_slave_util_callback.png)

- Introduction to `agile_modbus_slave_util_map`

Expand Down
Binary file modified doc/doxygen/Agile_Modbus.chm
Binary file not shown.
5 changes: 3 additions & 2 deletions doc/doxygen/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ GENERATE_CHI = NO
# and project file content.
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.

CHM_INDEX_ENCODING = GB2312
CHM_INDEX_ENCODING =

# The BINARY_TOC flag controls whether a binary table of contents is generated
# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
Expand Down Expand Up @@ -2287,7 +2287,8 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED =
PREDEFINED = AGILE_MODBUS_USING_RTU=1 \
AGILE_MODBUS_USING_TCP=1

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
Binary file modified doc/doxygen/figures/ModbusPollRTUConnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/doxygen/figures/ModbusPollTCPConnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/doxygen/figures/ModbusSlaveRTUConnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/doxygen/figures/SlaveCallback.jpg
Binary file not shown.
Binary file modified doc/doxygen/figures/VirtualCom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/doxygen/output/figures/ModbusPollRTUConnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/doxygen/output/figures/ModbusPollTCPConnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/doxygen/output/figures/ModbusSlaveRTUConnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/doxygen/output/figures/SlaveCallback.jpg
Binary file not shown.
Binary file modified doc/doxygen/output/figures/VirtualCom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions doc/doxygen/output/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<div class="headertitle"><div class="title">Agile Modbus </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p ><a class="anchor" id="md_D__Tools_agile_modbus_README"></a> </p>
<div class="textblock"><p ><a class="anchor" id="md_C__Users_25440_Desktop_agile_modbus_README"></a> </p>
<h1><a class="anchor" id="autotoc_md20"></a>
1. Introduction</h1>
<p >Agile Modbus is a lightweight modbus protocol stack that meets the needs of users in any scenario.</p>
Expand Down Expand Up @@ -197,9 +197,9 @@ <h3><a class="anchor" id="autotoc_md28"></a>
<li><p class="startli">Introduction to <code>agile_modbus_slave_handle</code></p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> <a class="code hl_function" href="group___slave___operation___functions.html#ga9ddc38e7ac14384c02b07b8927165247">agile_modbus_slave_handle</a>(<a class="code hl_struct" href="structagile__modbus.html">agile_modbus_t</a> *ctx, <span class="keywordtype">int</span> msg_length, uint8_t slave_strict,</div>
<div class="line"> <a class="code hl_typedef" href="group___slave___exported___types.html#gae66e6077fe07d589d91121ac8874541a">agile_modbus_slave_callback_t</a> slave_cb, <span class="keyword">const</span> <span class="keywordtype">void</span> *slave_data, <span class="keywordtype">int</span> *frame_length)</div>
<div class="ttc" id="agroup___slave___exported___types_html_gae66e6077fe07d589d91121ac8874541a"><div class="ttname"><a href="group___slave___exported___types.html#gae66e6077fe07d589d91121ac8874541a">agile_modbus_slave_callback_t</a></div><div class="ttdeci">int(* agile_modbus_slave_callback_t)(agile_modbus_t *ctx, struct agile_modbus_slave_info *slave_info, const void *data)</div><div class="ttdoc">Slave callback function.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00251">agile_modbus.h:251</a></div></div>
<div class="ttc" id="agroup___slave___exported___types_html_gae66e6077fe07d589d91121ac8874541a"><div class="ttname"><a href="group___slave___exported___types.html#gae66e6077fe07d589d91121ac8874541a">agile_modbus_slave_callback_t</a></div><div class="ttdeci">int(* agile_modbus_slave_callback_t)(agile_modbus_t *ctx, struct agile_modbus_slave_info *slave_info, const void *data)</div><div class="ttdoc">Slave callback function.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00265">agile_modbus.h:265</a></div></div>
<div class="ttc" id="agroup___slave___operation___functions_html_ga9ddc38e7ac14384c02b07b8927165247"><div class="ttname"><a href="group___slave___operation___functions.html#ga9ddc38e7ac14384c02b07b8927165247">agile_modbus_slave_handle</a></div><div class="ttdeci">int agile_modbus_slave_handle(agile_modbus_t *ctx, int msg_length, uint8_t slave_strict, agile_modbus_slave_callback_t slave_cb, const void *slave_data, int *frame_length)</div><div class="ttdoc">slave data processing</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8c_source.html#l01203">agile_modbus.c:1203</a></div></div>
<div class="ttc" id="astructagile__modbus_html"><div class="ttname"><a href="structagile__modbus.html">agile_modbus</a></div><div class="ttdoc">Agile Modbus structure.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00203">agile_modbus.h:203</a></div></div>
<div class="ttc" id="astructagile__modbus_html"><div class="ttname"><a href="structagile__modbus.html">agile_modbus</a></div><div class="ttdoc">Agile Modbus structure.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00217">agile_modbus.h:217</a></div></div>
</div><!-- fragment --><p class="startli">msg_length: The length of data received after <code>waiting for the end of data reception</code>.</p>
<p class="startli">slave_strict: slave address strictness check (0: Do not judge whether the address is consistent, it will be processed by user callback; 1: The address must be consistent, otherwise the callback will not be called and the response data will not be packaged).</p>
<p class="startli">slave_cb: <code>agile_modbus_slave_callback_t</code> type callback function, implemented and passed in by the user. If it is NULL, all function codes can respond and are successful, but the register data is still 0.</p>
Expand All @@ -213,7 +213,7 @@ <h3><a class="anchor" id="autotoc_md28"></a>
<li><p class="startli">Introduction to <code>agile_modbus_slave_callback_t</code></p>
<div class="fragment"><div class="line"> </div>
<div class="line"><span class="keyword">typedef</span> int (*<a class="code hl_typedef" href="group___slave___exported___types.html#gae66e6077fe07d589d91121ac8874541a">agile_modbus_slave_callback_t</a>)(<a class="code hl_struct" href="structagile__modbus.html">agile_modbus_t</a> *ctx, <span class="keyword">struct </span><a class="code hl_struct" href="structagile__modbus__slave__info.html">agile_modbus_slave_info</a> *slave_info, <span class="keyword">const</span> <span class="keywordtype">void</span> *data);</div>
<div class="ttc" id="astructagile__modbus__slave__info_html"><div class="ttname"><a href="structagile__modbus__slave__info.html">agile_modbus_slave_info</a></div><div class="ttdoc">Agile Modbus slave information structure.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00232">agile_modbus.h:232</a></div></div>
<div class="ttc" id="astructagile__modbus__slave__info_html"><div class="ttname"><a href="structagile__modbus__slave__info.html">agile_modbus_slave_info</a></div><div class="ttdoc">Agile Modbus slave information structure.</div><div class="ttdef"><b>Definition:</b> <a href="agile__modbus_8h_source.html#l00246">agile_modbus.h:246</a></div></div>
</div><!-- fragment --><p class="startli"><code><a class="el" href="structagile__modbus__slave__info.html" title="Agile Modbus slave information structure.">agile_modbus_slave_info</a></code>:</p>
<p class="startli">sft: Contains slave address and function code attributes, which can be used in callbacks</p>
<p class="startli">rsp_length: response data length pointer, its value needs to be updated when processing <code>special function code</code> in the callback, otherwise <b>not allowed to change</b></p>
Expand Down Expand Up @@ -310,7 +310,7 @@ <h3><a class="anchor" id="autotoc_md29"></a>
<p class="startli">Users need to implement the definitions of <code>bits</code>, <code>input_bits</code>, <code>registers</code> and <code>input_registers</code>. If a register is defined as NULL, the function code corresponding to the register can respond and is successful, but the register data is all 0.</p>
</li>
<li><p class="startli">Interface calling process</p>
<p class="startli"><img src="./figures/SlaveCallback.jpg" alt="SlaveCallback" class="inline"/></p>
<p class="startli"><img src="./figures/agile_modbus_slave_util_callback.png" alt="agile_modbus_slave_util_callback" class="inline"/></p>
</li>
</ul>
</li>
Expand Down
Binary file modified examples/figures/ModbusPollRTUConnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/ModbusPollTCPConnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/ModbusSlaveRTUConnection.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/figures/VirtualCom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed figures/SlaveCallback.jpg
Binary file not shown.
Binary file added figures/agile_modbus_slave_util_callback.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion inc/agile_modbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ extern "C" {
* @{
*/

/** @defgroup Modbus_Module_Definition Modbus Module Definition
* @{
*/
#ifndef AGILE_MODBUS_USING_RTU
#define AGILE_MODBUS_USING_RTU 1
#endif /* AGILE_MODBUS_USING_RTU */

#ifndef AGILE_MODBUS_USING_TCP
#define AGILE_MODBUS_USING_TCP 1
#endif /* AGILE_MODBUS_USING_TCP */
/**
* @}
*/

/** @defgroup COMMON_Exported_Constants Common Exported Constants
* @{
*/
Expand All @@ -50,7 +64,7 @@ extern "C" {
/** @defgroup Modbus_Constants Modbus Constants
* @{
*/
#define AGILE_MODBUS_VERSION_STRING "AMB_1.1.0" /**< Agile Modbus version number */
#define AGILE_MODBUS_VERSION_STRING "AMB_1.1.3" /**< Agile Modbus version number */

#define AGILE_MODBUS_BROADCAST_ADDRESS 0 /**< Modbus broadcast address */

Expand Down Expand Up @@ -349,8 +363,13 @@ uint16_t agile_modbus_slave_register_get(uint8_t *buf, int index);
*/

/* Include RTU and TCP module */
#if AGILE_MODBUS_USING_RTU
#include "agile_modbus_rtu.h"
#endif /* AGILE_MODBUS_USING_RTU */

#if AGILE_MODBUS_USING_TCP
#include "agile_modbus_tcp.h"
#endif /* AGILE_MODBUS_USING_TCP */

#ifdef __cplusplus
}
Expand Down
4 changes: 4 additions & 0 deletions inc/agile_modbus_rtu.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#ifndef __PKG_AGILE_MODBUS_RTU_H
#define __PKG_AGILE_MODBUS_RTU_H

#if AGILE_MODBUS_USING_RTU

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -76,4 +78,6 @@ int agile_modbus_rtu_init(agile_modbus_rtu_t *ctx, uint8_t *send_buf, int send_b
}
#endif

#endif /* AGILE_MODBUS_USING_RTU */

#endif /* __PKG_AGILE_MODBUS_RTU_H */
6 changes: 5 additions & 1 deletion inc/agile_modbus_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#ifndef __PKG_AGILE_MODBUS_TCP_H
#define __PKG_AGILE_MODBUS_TCP_H

#if AGILE_MODBUS_USING_TCP

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -80,4 +82,6 @@ int agile_modbus_tcp_init(agile_modbus_tcp_t *ctx, uint8_t *send_buf, int send_b
}
#endif

#endif
#endif /* AGILE_MODBUS_USING_TCP */

#endif /* __PKG_AGILE_MODBUS_TCP_H */
5 changes: 5 additions & 0 deletions src/agile_modbus_rtu.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/

#include "agile_modbus.h"

#if AGILE_MODBUS_USING_RTU

#include "agile_modbus_rtu.h"

/** @defgroup RTU RTU
Expand Down Expand Up @@ -289,3 +292,5 @@ int agile_modbus_rtu_init(agile_modbus_rtu_t *ctx, uint8_t *send_buf, int send_b
/**
* @}
*/

#endif /* AGILE_MODBUS_USING_RTU */
5 changes: 5 additions & 0 deletions src/agile_modbus_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/

#include "agile_modbus.h"

#if AGILE_MODBUS_USING_TCP

#include "agile_modbus_tcp.h"

/** @defgroup TCP TCP
Expand Down Expand Up @@ -224,3 +227,5 @@ int agile_modbus_tcp_init(agile_modbus_tcp_t *ctx, uint8_t *send_buf, int send_b
/**
* @}
*/

#endif /* AGILE_MODBUS_USING_TCP */

0 comments on commit 50bda72

Please sign in to comment.