diff --git a/APP_Framework/Applications/control_app/plc_demo/omron/json/test_recipe_nj501_fins.json b/APP_Framework/Applications/control_app/plc_demo/omron/json/test_recipe_nj501_fins.json new file mode 100644 index 000000000..28c128e42 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/omron/json/test_recipe_nj501_fins.json @@ -0,0 +1,26 @@ +{ + "device_id": 1, + "device_name": "NJ501", + "communication_type": 0, + "socket_config": { + "plc_ip": "192.168.250.22", + "local_ip": "192.168.250.233", + "gateway": "192.168.250.1", + "netmask": "255.255.255.0", + "port": 9600 + }, + "protocol_type": 5, + "read_period": 100, + "read_item_list": [ + + { + "value_name": "整型1", + "value_type": 3, + "area_char": "D", + "data_type": 1, + "start_address": 100, + "bit_address": 0, + "data_length": 1 + } + ] +} \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/omron/omron_nj501.c b/APP_Framework/Applications/control_app/plc_demo/omron/omron_nj501.c index d265aa953..cc57e6961 100644 --- a/APP_Framework/Applications/control_app/plc_demo/omron/omron_nj501.c +++ b/APP_Framework/Applications/control_app/plc_demo/omron/omron_nj501.c @@ -18,6 +18,34 @@ * @date 2022.9.27 */ - +#include + +void ControlNj501Test(void) +{ + int i = 0; + uint16_t read_data_length = 0; + uint8_t read_data[1024] = {0}; + ControlProtocolType fins_protocol = ControlProtocolFind(); + if (NULL == fins_protocol) { + printf("%s get fins protocol %p failed\n", __func__, fins_protocol); + return; + } + + printf("%s get fins protocol %p successfull\n", __func__, fins_protocol); + + if (CONTROL_REGISTERED == fins_protocol->protocol_status) { + ControlProtocolOpen(fins_protocol); + + for (;;) { + read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data)); + printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length); + i++; + PrivTaskDelay(100000); + } + + //ControlProtocolClose(fins_protocol); + } +} +PRIV_SHELL_CMD_FUNCTION(ControlNj501Test, Omron Plc FINS Demo, PRIV_SHELL_CMD_MAIN_ATTR);