Skip to content

Commit db91426

Browse files
fengzerozflyfish30
authored andcommitted
the basic info(plugin name, type, kind...) of the plugin is read from the dynamic library
add dynamic library search path configuration, install to /etc/ld.so.conf.d/ dynamic library search path priority: 1. driver.path in neuron.yaml 2. os path
1 parent e116ee4 commit db91426

30 files changed

+200
-305
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ if(NOT DISABLE_UT)
182182
add_subdirectory(tests)
183183
endif()
184184

185+
186+
install(FILES "${CMAKE_SOURCE_DIR}/neuron.conf" DESTINATION /etc/ld.so.conf.d)
185187
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
186188
DESTINATION include/neuron
187189
FILES_MATCHING
@@ -195,4 +197,4 @@ install(FILES "${CMAKE_SOURCE_DIR}/cmake/neuron-config.cmake"
195197
DESTINATION lib/cmake/neuron)
196198
install(TARGETS neuron-base neuron
197199
LIBRARY DESTINATION lib
198-
RUNTIME DESTINATION bin)
200+
RUNTIME DESTINATION bin)

docs/json-api/neu_json_plugin.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
{
22
"add_plugin_req": {
3-
"kind": 1,
4-
"node_type": 1,
5-
"name": "plugin_name",
63
"lib_name": "plugin_name.so"
74
},
85
"del_plugin_req": {
96
"id": 1
107
},
11-
"update_plugin_req": {
12-
"kind": 1,
13-
"node_type": 1,
14-
"name": "plugin_name",
15-
"lib_name": "plugin_name.so"
16-
},
178
"get_plugin_req": {
189
"id": 1
1910
},

include/json/neu_json_plugin.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ extern "C" {
3232
#endif
3333

3434
typedef struct {
35-
char * name;
36-
int64_t kind;
37-
char * lib_name;
38-
int64_t node_type;
35+
char *lib_name;
3936
} neu_json_add_plugin_req_t;
4037

4138
int neu_json_decode_add_plugin_req(char * buf,
@@ -73,17 +70,6 @@ typedef struct {
7370

7471
int neu_json_encode_get_plugin_resp(void *json_object, void *param);
7572

76-
typedef struct {
77-
char * name;
78-
int64_t kind;
79-
char * lib_name;
80-
int64_t node_type;
81-
} neu_json_update_plugin_req_t;
82-
83-
int neu_json_decode_update_plugin_req(char * buf,
84-
neu_json_update_plugin_req_t **result);
85-
void neu_json_decode_update_plugin_req_free(neu_json_update_plugin_req_t *req);
86-
8773
#ifdef __cplusplus
8874
}
8975
#endif

include/neu_adapter.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ typedef struct plugin_lib_info {
221221

222222
/* NEU_REQRESP_ADD_PLUGIN_LIB */
223223
typedef struct neu_cmd_add_plugin_lib_t {
224-
plugin_kind_e plugin_kind;
225-
neu_node_type_e node_type;
226-
const char * plugin_name;
227-
const char * plugin_lib_name;
224+
const char *plugin_lib_name;
228225
} neu_cmd_add_plugin_lib_t;
229226

230227
/* NEU_REQRESP_DEL_PLUGIN_LIB */

include/neu_errcodes.h

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,29 @@ typedef enum {
7070
NEU_ERR_INVALID_TOKEN = 1008,
7171
NEU_ERR_INVALID_USER_OR_PASSWORD = 1009,
7272

73-
NEU_ERR_PLUGIN_NAME_NOT_FOUND = 2000,
74-
NEU_ERR_NODE_TYPE_INVALID = 2001,
75-
NEU_ERR_NODE_EXIST = 2002,
76-
NEU_ERR_NODE_NOT_EXIST = 2003,
77-
NEU_ERR_GRP_CONFIG_NOT_EXIST = 2004,
78-
NEU_ERR_TAG_NOT_EXIST = 2005,
79-
NEU_ERR_TAG_ATTRIBUTE_NOT_SUPPORT = 2006,
80-
NEU_ERR_NODE_SETTING_INVALID = 2007,
81-
NEU_ERR_NODE_SETTING_NOT_FOUND = 2008,
82-
NEU_ERR_GRP_CONFIG_IN_USE = 2009,
83-
NEU_ERR_NODE_NOT_READY = 2010,
84-
NEU_ERR_NODE_IS_RUNNING = 2011,
85-
NEU_ERR_NODE_NOT_RUNNING = 2012,
86-
NEU_ERR_NODE_IS_STOPED = 2013,
87-
NEU_ERR_GRP_NOT_SUBSCRIBE = 2014,
88-
NEU_ERR_TAG_TYPE_NOT_SUPPORT = 2015,
89-
NEU_ERR_GRP_CONFIG_EXIST = 2016,
90-
NEU_ERR_TAG_NAME_EXIST = 2017,
91-
NEU_ERR_TAG_LIST_NOT_EXIST = 2018,
92-
NEU_ERR_TAG_ADDRESS_FORMAT_INVALID = 2019,
73+
NEU_ERR_PLUGIN_NAME_NOT_FOUND = 2000,
74+
NEU_ERR_NODE_TYPE_INVALID = 2001,
75+
NEU_ERR_NODE_EXIST = 2002,
76+
NEU_ERR_NODE_NOT_EXIST = 2003,
77+
NEU_ERR_GRP_CONFIG_NOT_EXIST = 2004,
78+
NEU_ERR_TAG_NOT_EXIST = 2005,
79+
NEU_ERR_TAG_ATTRIBUTE_NOT_SUPPORT = 2006,
80+
NEU_ERR_NODE_SETTING_INVALID = 2007,
81+
NEU_ERR_NODE_SETTING_NOT_FOUND = 2008,
82+
NEU_ERR_GRP_CONFIG_IN_USE = 2009,
83+
NEU_ERR_NODE_NOT_READY = 2010,
84+
NEU_ERR_NODE_IS_RUNNING = 2011,
85+
NEU_ERR_NODE_NOT_RUNNING = 2012,
86+
NEU_ERR_NODE_IS_STOPED = 2013,
87+
NEU_ERR_GRP_NOT_SUBSCRIBE = 2014,
88+
NEU_ERR_TAG_TYPE_NOT_SUPPORT = 2015,
89+
NEU_ERR_GRP_CONFIG_EXIST = 2016,
90+
NEU_ERR_TAG_NAME_EXIST = 2017,
91+
NEU_ERR_TAG_LIST_NOT_EXIST = 2018,
92+
NEU_ERR_TAG_ADDRESS_FORMAT_INVALID = 2019,
93+
NEU_ERR_PLUGIN_LIBRARY_NOT_FOUND = 2020,
94+
NEU_ERR_PLUGIN_LIBRARY_INFO_INVALID = 2021,
95+
NEU_ERR_PLUGIN_LIBRARY_NAME_CONFLICT = 2022,
9396

9497
NEU_ERR_DEVICE_CONNECTION_FAILURE = 3000,
9598
NEU_ERR_DEVICE_READ_FAILURE = 3001,

include/neu_plugin.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ typedef struct neu_plugin_module {
5858
const char * module_name;
5959
const char * module_descr;
6060
const neu_plugin_intf_funs_t *intf_funs;
61+
neu_node_type_e type;
62+
plugin_kind_e kind;
6163
} neu_plugin_module_t;
6264

6365
inline static neu_plugin_common_t *
@@ -118,10 +120,8 @@ void neu_plugin_response_trans_data(neu_plugin_t * plugin,
118120
neu_node_id_t neu_plugin_self_node_id(neu_plugin_t *plugin);
119121
const char * neu_plugin_self_node_name(neu_plugin_t *plugin);
120122

121-
intptr_t neu_system_add_plugin(neu_plugin_t *plugin, plugin_kind_e kind,
122-
neu_node_type_e node_type,
123-
const char * plugin_name,
124-
const char * plugin_lib_name);
123+
intptr_t neu_system_add_plugin(neu_plugin_t *plugin,
124+
const char * plugin_lib_name);
125125
intptr_t neu_system_del_plugin(neu_plugin_t *plugin, plugin_id_t plugin_id);
126126
intptr_t neu_system_update_plugin(neu_plugin_t *plugin, plugin_kind_e kind,
127127
neu_node_type_e node_type,

neuron.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# neuron driver default configuration
2+
/usr/local/lib/neuron

neuron.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
lib_path: ./
1+
driver:
2+
path: ./
23
web:
34
host: 0.0.0.0
45
port: 7000

plugins/modbus/modbus_tcp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,9 @@ static const neu_plugin_intf_funs_t plugin_intf_funs = {
736736

737737
const neu_plugin_module_t neu_plugin_module = {
738738
.version = NEURON_PLUGIN_VER_1_0,
739-
.module_name = "neuron-modbus-tcp-plugin",
739+
.module_name = "modbus-tcp-plugin",
740740
.module_descr = "modbus tcp driver plugin",
741741
.intf_funs = &plugin_intf_funs,
742+
.kind = PLUGIN_KIND_SYSTEM,
743+
.type = NEU_NODE_TYPE_DRIVER,
742744
};

plugins/mqtt/command/command.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,6 @@ void command_response_handle(mqtt_response_t *response)
241241
}
242242
break;
243243
}
244-
case NEU_MQTT_OP_UPDATE_PLUGIN: {
245-
neu_json_update_plugin_req_t *req = NULL;
246-
rc = neu_json_decode_update_plugin_req(json_str, &req);
247-
if (0 == rc) {
248-
ret_str = command_plugin_update(plugin, mqtt, req);
249-
neu_json_decode_update_plugin_req_free(req);
250-
}
251-
break;
252-
}
253244
case NEU_MQTT_OP_DELETE_PLUGIN: {
254245
neu_json_del_plugin_req_t *req = NULL;
255246
rc = neu_json_decode_del_plugin_req(json_str, &req);

0 commit comments

Comments
 (0)