diff --git a/APP_Framework/Applications/control_app/plc_demo/Makefile b/APP_Framework/Applications/control_app/plc_demo/Makefile index e6f45b376..747b6d28b 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 ge xinje inovance +SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance keyence include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/inovance/Makefile b/APP_Framework/Applications/control_app/plc_demo/inovance/Makefile index 5b7f58eef..8e129e1af 100644 --- a/APP_Framework/Applications/control_app/plc_demo/inovance/Makefile +++ b/APP_Framework/Applications/control_app/plc_demo/inovance/Makefile @@ -1,3 +1,3 @@ -SRC_FILES := inovance_am401_cpu1608tn_ethernet.c +SRC_FILES := inovance_am401_cpu1608tn_ethernet.c inovance_am401_cpu1608tn_uart.c include $(KERNEL_ROOT)/compiler.mk \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/inovance/inovance_am401_cpu1608tn_uart.c b/APP_Framework/Applications/control_app/plc_demo/inovance/inovance_am401_cpu1608tn_uart.c new file mode 100644 index 000000000..b7b26d14c --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/inovance/inovance_am401_cpu1608tn_uart.c @@ -0,0 +1,64 @@ +/* + * 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 inovance_am401_cpu1608tn_ethernet.c + * @brief PLC inovance am401 app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2023.5.15 + */ + +#include + +extern int Adapter4GActive(void); + +void ControlInovanceam401UartTest(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(ControlInovanceam401UartTest, inovance am401 uart Demo, PRIV_SHELL_CMD_MAIN_ATTR); + + diff --git a/APP_Framework/Applications/control_app/plc_demo/inovance/test_recipe_inovance_am401_uart.json b/APP_Framework/Applications/control_app/plc_demo/inovance/test_recipe_inovance_am401_uart.json new file mode 100644 index 000000000..04595c49a --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/inovance/test_recipe_inovance_am401_uart.json @@ -0,0 +1,80 @@ +{ + "device_id": 1, + "device_name": "INOVANCE_am401_RTU", + "communication_type": 1, + "serial_config": { + "station": 1, + "baud_rate": 9600, + "data_bits": 8, + "stop_bits": 1, + "check_mode":3 + }, + "protocol_type": 3, + "read_period": 2000, + "read_item_list": [ + { + "value_name": "q00", + "value_type": 1, + "function_code": 1, + "start_address": 0, + "quantity": 1 + }, + { + "value_name": "q01", + "value_type": 1, + "function_code": 1, + "start_address":1, + "quantity": 1 + }, + { + "value_name": "q10", + "value_type": 1, + "function_code": 1, + "start_address": 8, + "quantity": 1 + }, + { + "value_name": "mw100", + "value_type": 3, + "function_code": 3, + "start_address": 100, + "quantity": 1 + }, + { + "value_name": "mw101", + "value_type": 3, + "function_code": 3, + "start_address": 101, + "quantity": 1 + }, + { + "value_name": "md200", + "value_type": 4, + "function_code": 3, + "start_address": 400, + "quantity": 2 + }, + { + "value_name": "md201", + "value_type": 4, + "function_code": 3, + "start_address": 402, + "quantity": 2 + }, + { + "value_name": "md300", + "value_type": 9, + "function_code": 3, + "start_address": 600, + "quantity": 2 + }, + { + "value_name": "md301", + "value_type": 9, + "function_code": 3, + "start_address": 602, + "quantity": 2 + } + + ] +} \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/keyence/Makefile b/APP_Framework/Applications/control_app/plc_demo/keyence/Makefile new file mode 100755 index 000000000..6c12e6405 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/keyence/Makefile @@ -0,0 +1,3 @@ +SRC_FILES := kv_8000.c + +include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/keyence/README.md b/APP_Framework/Applications/control_app/plc_demo/keyence/README.md new file mode 100644 index 000000000..547da53c4 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/keyence/README.md @@ -0,0 +1,22 @@ +# KEYENCE 通信测试 + +[TOC] + +## 通信接线及参数设置 + +* 网口 + + *Mosbus TCP协议,IP:192.168.250.40,Port:502 + +## 存储区 + +- 存储区ZF区。 + +## 通信测试 + +(1)共测试INT16类型数据。 + +(2)测试ZF区数据。 + +(3)D区数据测试,用功能码03和06,以字为单位读写。如读写ZF1,则配方文件中起始地址则直接写1即可。 + diff --git a/APP_Framework/Applications/control_app/plc_demo/keyence/kv_8000.c b/APP_Framework/Applications/control_app/plc_demo/keyence/kv_8000.c new file mode 100644 index 000000000..f4e633f05 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/keyence/kv_8000.c @@ -0,0 +1,53 @@ +/* + * 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 kv_8000.c + * @brief PLC KEYENCE KV-8000 app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2023.4.12 + */ + +#include +void ControlKV8000Test(void) +{ + int i, j = 0; + int read_data_length = 0; + uint8_t read_data[128] = {0}; + ControlProtocolType modbus_tcp_protocol = ControlProtocolFind(); + if (NULL == modbus_tcp_protocol) { + printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol); + return; + } + printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol); + + if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) { + ControlProtocolOpen(modbus_tcp_protocol); + for (;;) { + read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data)); + printf("%s read [%d] modbus tcp 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_tcp_protocol); + } +} +PRIV_SHELL_CMD_FUNCTION(ControlKV8000Test, KEYENCE Plc KV_8000 Demo, PRIV_SHELL_CMD_MAIN_ATTR); + + diff --git a/APP_Framework/Applications/control_app/plc_demo/keyence/test_recipe_KV_8000.json b/APP_Framework/Applications/control_app/plc_demo/keyence/test_recipe_KV_8000.json new file mode 100644 index 000000000..a308badbb --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/keyence/test_recipe_KV_8000.json @@ -0,0 +1,37 @@ +{ + "device_id": 1, + "device_name": "GJ2", + "communication_type": 0, + "socket_config": { + "plc_ip": "192.168.250.40", + "local_ip": "192.168.250.233", + "gateway": "192.168.250.1", + "netmask": "255.255.255.0", + "port": 502 + }, + "protocol_type": 2, + "read_period": 100, + "read_item_list": [ + { + "value_name": "ZF0", + "value_type": 3, + "function_code": 3, + "start_address": 0, + "quantity": 1 + }, + { + "value_name": "ZF1", + "value_type": 3, + "function_code": 3, + "start_address": 1, + "quantity": 1 + }, + { + "value_name": "ZF2", + "value_type": 3, + "function_code": 3, + "start_address": 2, + "quantity": 1 + } + ] +} \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/schneider/README.md b/APP_Framework/Applications/control_app/plc_demo/schneider/README.md new file mode 100644 index 000000000..46f0558bf --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/schneider/README.md @@ -0,0 +1,21 @@ +# SCHNEIDER M241通信测试 + +[TOC] + +## 通信接线及参数设置 + +* 串口 + * M241支持2路485串口,本次采用的是serial2。波特率:9600,数据位:8位,停止位:1位,校验:偶校验 + +## 存储区 + +- 存储区MW区。 + +## 通信测试 + +(1)共测试INT16共1种类型数据。 + +(2)测试MW区数据。 + +(3)MW区数据测试,用功能码03,以字为单位读取。如读MW100,则配方文件中起始地址则直接写100即可。 + diff --git a/APP_Framework/Applications/control_app/plc_demo/xinje/README.md b/APP_Framework/Applications/control_app/plc_demo/xinje/README.md new file mode 100644 index 000000000..bd9d268a9 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/xinje/README.md @@ -0,0 +1,23 @@ +# XINJIE 通信测试 + +[TOC] + +## 通信接线及参数设置 + +* 网口 + + *Mosbus TCP协议,IP:192.168.250.32,Port:502 + +## 存储区 + +- 存储区M、D区。 + +## 通信测试 + +(1)共测试BOOL,INT16共2种类型数据。 + +(2)测试M区及D区数据。 + +(3)D区数据测试,用功能码03和06,以字为单位读写。如读写D500,则配方文件中起始地址则直接写500即可。 + +(4)M区数据测试,用功能码01和05,以位为单位读写。如读写M19,则配方文件中起始地址则直接写19即可。