diff --git a/APP_Framework/Applications/control_app/plc_demo/siemens/Makefile b/APP_Framework/Applications/control_app/plc_demo/siemens/Makefile index 54fb32baa..815382667 100755 --- a/APP_Framework/Applications/control_app/plc_demo/siemens/Makefile +++ b/APP_Framework/Applications/control_app/plc_demo/siemens/Makefile @@ -1,3 +1,3 @@ -SRC_FILES := siemens_s7_200_cn.c siemens_s7_200_smart.c siemens_s7_300.c siemens_s7_1200.c siemens_s7_1500.c +SRC_FILES := siemens_s7_200_cn.c siemens_s7_200_smart.c siemens_s7_1200.c siemens_s7_1500.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/siemens/json/test_recipe_simens_s71200.json b/APP_Framework/Applications/control_app/plc_demo/siemens/json/test_recipe_simens_s71200.json new file mode 100644 index 000000000..408eff339 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/siemens/json/test_recipe_simens_s71200.json @@ -0,0 +1,25 @@ +{ + "device_id": 1, + "device_name": "S7-1215", + "communication_type": 0, + "socket_config": { + "plc_ip": "192.168.250.5", + "local_ip": "192.168.250.233", + "gateway": "192.168.250.252", + "netmask": "255.255.255.0", + "port": 102 + }, + "protocol_type": 1, + "read_period": 100, + "read_item_list": [ + { + "value_name": "浮点数", + "value_type": 9, + "area": "DB", + "wordlen": "Real", + "db_number": 10, + "start": 32, + "amount": 1 + } + ] +} \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/siemens/siemens_s7_1200.c b/APP_Framework/Applications/control_app/plc_demo/siemens/siemens_s7_1200.c index 9cbbeae1a..f2a35f4cf 100644 --- a/APP_Framework/Applications/control_app/plc_demo/siemens/siemens_s7_1200.c +++ b/APP_Framework/Applications/control_app/plc_demo/siemens/siemens_s7_1200.c @@ -18,3 +18,28 @@ * @date 2023.3.27 */ +#include +void ControlS71200Test(void) +{ + int i = 0; + uint16_t read_data_length = 0; + uint8_t read_data[1024] = {0}; + ControlProtocolType s7_protocol = ControlProtocolFind(); + if (NULL == s7_protocol) { + printf("%s get s7 protocol %p failed\n", __func__, s7_protocol); + return; + } + printf("%s get s7 protocol %p successfull\n", __func__, s7_protocol); + if (CONTROL_REGISTERED == s7_protocol->protocol_status) { + ControlProtocolOpen(s7_protocol); + for (;;) { + read_data_length = ControlProtocolRead(s7_protocol, read_data, sizeof(read_data)); + printf("%s read [%d] s7 data %d using receipe file\n", __func__, i, read_data_length); + i++; + memset(read_data, 0, sizeof(read_data)); + PrivTaskDelay(10000); + } + } +} + +PRIV_SHELL_CMD_FUNCTION(ControlS71200Test, Siemens Plc S7_1215 Demo, PRIV_SHELL_CMD_MAIN_ATTR); \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/siemens/siemens_s7_300.c b/APP_Framework/Applications/control_app/plc_demo/siemens/siemens_s7_300.c deleted file mode 100644 index 88d09209e..000000000 --- a/APP_Framework/Applications/control_app/plc_demo/siemens/siemens_s7_300.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2022 AIIT XUOS Lab - * XiUOS is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -/** - * @file siemens_s7_300.c - * @brief PLC SIEMENS S7-300 app - * @version 3.0 - * @author AIIT XUOS Lab - * @date 2023.3.27 - */ -