From a590d902f5b46ff4e1895387564a3cd98b65922a Mon Sep 17 00:00:00 2001 From: "Wien.b" <18058767332@163.com> Date: Wed, 18 Jan 2023 18:48:36 -0800 Subject: [PATCH 1/4] create a new folder called xinje --- APP_Framework/Applications/control_app/plc_demo/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP_Framework/Applications/control_app/plc_demo/Makefile b/APP_Framework/Applications/control_app/plc_demo/Makefile index afa145fbc..57c90a56c 100755 --- a/APP_Framework/Applications/control_app/plc_demo/Makefile +++ b/APP_Framework/Applications/control_app/plc_demo/Makefile @@ -1,3 +1,3 @@ -SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens +SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens xinje include $(KERNEL_ROOT)/compiler.mk From f55da28789c727cd09741c2f0b5339c85fc6161d Mon Sep 17 00:00:00 2001 From: "Wien.b" <18058767332@163.com> Date: Tue, 31 Jan 2023 23:50:23 -0800 Subject: [PATCH 2/4] new two plc in xinje --- .../plc_demo/schneider/schneider_m241.c | 2 +- .../control_app/plc_demo/xinje/Makefile | 3 +++ .../control_app/plc_demo/xinje/xdh-60t4-e.c | 20 +++++++++++++++++++ .../control_app/plc_demo/xinje/xsdh-60a32-e.c | 19 ++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 APP_Framework/Applications/control_app/plc_demo/xinje/Makefile create mode 100644 APP_Framework/Applications/control_app/plc_demo/xinje/xdh-60t4-e.c create mode 100644 APP_Framework/Applications/control_app/plc_demo/xinje/xsdh-60a32-e.c diff --git a/APP_Framework/Applications/control_app/plc_demo/schneider/schneider_m241.c b/APP_Framework/Applications/control_app/plc_demo/schneider/schneider_m241.c index 2121da530..fe64929c6 100644 --- a/APP_Framework/Applications/control_app/plc_demo/schneider/schneider_m241.c +++ b/APP_Framework/Applications/control_app/plc_demo/schneider/schneider_m241.c @@ -15,7 +15,7 @@ * @brief PLC SCHNEIDER M241 app * @version 3.0 * @author AIIT XUOS Lab - * @date 2022.9.27 + * @date 2023.2.1 */ diff --git a/APP_Framework/Applications/control_app/plc_demo/xinje/Makefile b/APP_Framework/Applications/control_app/plc_demo/xinje/Makefile new file mode 100755 index 000000000..fcf6b1e27 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/xinje/Makefile @@ -0,0 +1,3 @@ +SRC_FILES := xsdh-60a32-e.c xdh-60t4-e.c + +include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/xinje/xdh-60t4-e.c b/APP_Framework/Applications/control_app/plc_demo/xinje/xdh-60t4-e.c new file mode 100644 index 000000000..9abf2800b --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/xinje/xdh-60t4-e.c @@ -0,0 +1,20 @@ +/* + * 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 mitsubishi_fx3u.c + * @brief PLC MITSUBISHI FX3U app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022.9.27 + */ + diff --git a/APP_Framework/Applications/control_app/plc_demo/xinje/xsdh-60a32-e.c b/APP_Framework/Applications/control_app/plc_demo/xinje/xsdh-60a32-e.c new file mode 100644 index 000000000..1872af036 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/xinje/xsdh-60a32-e.c @@ -0,0 +1,19 @@ +/* + * 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 mitsubishi_fx3u.c + * @brief PLC MITSUBISHI FX3U app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022.9.27 + */ From 0ebfda21f7debfd775fdcabcfb7f538c97473e93 Mon Sep 17 00:00:00 2001 From: "Wien.b" <18058767332@163.com> Date: Thu, 9 Feb 2023 22:32:21 -0800 Subject: [PATCH 3/4] new a demo named schneider_m241.c --- .../control_app/plc_demo/omron/Makefile | 2 +- .../control_app/plc_demo/omron/omron_cp1h.c | 20 +++++++++ .../control_app/plc_demo/omron/omron_cp1l.c | 19 ++++++++ .../plc_demo/schneider/m241_recipe.json | 30 +++++++++++++ .../plc_demo/schneider/schneider_m241.c | 43 ++++++++++++++++++- .../control_app/plc_demo/xinje/xdh-60t4-e.c | 2 +- .../control_app/plc_demo/xinje/xsdh-60a32-e.c | 2 +- 7 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1h.c create mode 100644 APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1l.c create mode 100644 APP_Framework/Applications/control_app/plc_demo/schneider/m241_recipe.json diff --git a/APP_Framework/Applications/control_app/plc_demo/omron/Makefile b/APP_Framework/Applications/control_app/plc_demo/omron/Makefile index 0bd99da9d..ccc3487f7 100755 --- a/APP_Framework/Applications/control_app/plc_demo/omron/Makefile +++ b/APP_Framework/Applications/control_app/plc_demo/omron/Makefile @@ -1,3 +1,3 @@ -SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c +SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c omron_cp1h.c omron_cp1l.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1h.c b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1h.c new file mode 100644 index 000000000..ba28d4533 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1h.c @@ -0,0 +1,20 @@ +/* + * 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 omron_cj2m.c + * @brief PLC OMRON CJ2M app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022.9.27 + */ + diff --git a/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1l.c b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1l.c new file mode 100644 index 000000000..08c4366f6 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1l.c @@ -0,0 +1,19 @@ +/* + * 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 omron_cj2m.c + * @brief PLC OMRON CJ2M app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022.9.27 + */ diff --git a/APP_Framework/Applications/control_app/plc_demo/schneider/m241_recipe.json b/APP_Framework/Applications/control_app/plc_demo/schneider/m241_recipe.json new file mode 100644 index 000000000..d87b89834 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/schneider/m241_recipe.json @@ -0,0 +1,30 @@ +{ + "device_id": 1, + "device_name": "m241", + "communication_type": 1, + "serial_config": { + "station": 1, + "baud_rate": 9600, + "data_bits": 8, + "stop_bits": 1, + "check_mode": 3 + }, + "protocol_type": 3, + "read_period": 100, + "read_item_list": [ + { + "value_name": "MW0", + "value_type": 3, + "function_code": 3, + "start_address": 0, + "quantity": 1 + }, + { + "value_name": "MW1", + "value_type": 3, + "function_code": 3, + "start_address": 1, + "quantity": 1 + } + ] +} \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/schneider/schneider_m241.c b/APP_Framework/Applications/control_app/plc_demo/schneider/schneider_m241.c index fe64929c6..60fb1d2b6 100644 --- a/APP_Framework/Applications/control_app/plc_demo/schneider/schneider_m241.c +++ b/APP_Framework/Applications/control_app/plc_demo/schneider/schneider_m241.c @@ -18,6 +18,47 @@ * @date 2023.2.1 */ - +#include + +extern int Adapter4GActive(void); + +void ControlM241Test(void) +{ + int i, j = 0; + int read_data_length = 0; + uint8_t read_data[128] = {0}; + + #ifdef CONNECTION_ADAPTER_4G + Adapter4GActive(); + #endif + + ControlProtocolType modbus_rtu_protocol = ControlProtocolFind(); + if (NULL == modbus_rtu_protocol) { + printf("%s get modbus rtu protocol %p failed\n", __func__, modbus_rtu_protocol); + return; + } + + printf("%s get modbus rtu protocol %p successfull\n", __func__, modbus_rtu_protocol); + + if (CONTROL_REGISTERED == modbus_rtu_protocol->protocol_status) { + ControlProtocolOpen(modbus_rtu_protocol); + + for (;;) { + read_data_length = ControlProtocolRead(modbus_rtu_protocol, read_data, sizeof(read_data)); + printf("%s read [%d] modbus rtu data %d using receipe file\n", __func__, i, read_data_length); + if (read_data_length) { + for (j = 0; j < read_data_length; j ++) { + printf("j %d data 0x%x\n", j, read_data[j]); + } + } + i++; + memset(read_data, 0, sizeof(read_data)); + PrivTaskDelay(10000); + } + + //ControlProtocolClose(modbus_rtu_protocol); + } +} +PRIV_SHELL_CMD_FUNCTION(ControlM241Test, Schneider M241 Demo, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Applications/control_app/plc_demo/xinje/xdh-60t4-e.c b/APP_Framework/Applications/control_app/plc_demo/xinje/xdh-60t4-e.c index 9abf2800b..823be9644 100644 --- a/APP_Framework/Applications/control_app/plc_demo/xinje/xdh-60t4-e.c +++ b/APP_Framework/Applications/control_app/plc_demo/xinje/xdh-60t4-e.c @@ -15,6 +15,6 @@ * @brief PLC MITSUBISHI FX3U app * @version 3.0 * @author AIIT XUOS Lab - * @date 2022.9.27 + * @date 2023.2.1 */ diff --git a/APP_Framework/Applications/control_app/plc_demo/xinje/xsdh-60a32-e.c b/APP_Framework/Applications/control_app/plc_demo/xinje/xsdh-60a32-e.c index 1872af036..ed106879b 100644 --- a/APP_Framework/Applications/control_app/plc_demo/xinje/xsdh-60a32-e.c +++ b/APP_Framework/Applications/control_app/plc_demo/xinje/xsdh-60a32-e.c @@ -15,5 +15,5 @@ * @brief PLC MITSUBISHI FX3U app * @version 3.0 * @author AIIT XUOS Lab - * @date 2022.9.27 + * @date 2023.3.1 */ From 572cbd201ac68f8ddb42c4e253cea3fe0c73dc92 Mon Sep 17 00:00:00 2001 From: "Wien.b" <18058767332@163.com> Date: Fri, 10 Feb 2023 02:36:57 -0800 Subject: [PATCH 4/4] new a demo named omron_cp1l.c --- .../control_app/plc_demo/omron/omron_cp1l.c | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1l.c b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1l.c index 08c4366f6..814af8f3b 100644 --- a/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1l.c +++ b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cp1l.c @@ -11,9 +11,38 @@ */ /** - * @file omron_cj2m.c - * @brief PLC OMRON CJ2M app + * @file omron_.cp1l.c + * @brief PLC OMRON CP1L app * @version 3.0 * @author AIIT XUOS Lab - * @date 2022.9.27 + * @date 2023.2.10 */ +#include + +void ControlOmronCP1LTest(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(ControlOmronCP1LTest, Omron Plc FINS Demo, PRIV_SHELL_CMD_MAIN_ATTR); \ No newline at end of file