diff --git a/APP_Framework/Applications/control_app/plc_demo/Makefile b/APP_Framework/Applications/control_app/plc_demo/Makefile index 097c9f7d4..73996e63f 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 keyence panasonic fatek ab abb +SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance keyence panasonic fatek ab abb koyo include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/koyo/Makefile b/APP_Framework/Applications/control_app/plc_demo/koyo/Makefile new file mode 100755 index 000000000..3a35a392d --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/koyo/Makefile @@ -0,0 +1,3 @@ +SRC_FILES := koyo_nk1cpu40.c + +include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/koyo/image/21573525-8FF0-44F3-BA01-0AF32D1E73D0.png b/APP_Framework/Applications/control_app/plc_demo/koyo/image/21573525-8FF0-44F3-BA01-0AF32D1E73D0.png new file mode 100644 index 000000000..135c5bcb0 Binary files /dev/null and b/APP_Framework/Applications/control_app/plc_demo/koyo/image/21573525-8FF0-44F3-BA01-0AF32D1E73D0.png differ diff --git a/APP_Framework/Applications/control_app/plc_demo/koyo/koyo_nk1cpu40.c b/APP_Framework/Applications/control_app/plc_demo/koyo/koyo_nk1cpu40.c new file mode 100644 index 000000000..c0e603d5c --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/koyo/koyo_nk1cpu40.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 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 koyo_nk1cpu40.c + * @brief PLC AB MICRO850 app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2024.07.03 + */ + +#include + +void ControlKoyoNK1CPU40Test(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(ControlKoyoNK1CPU40Test, Koyo Plc NK1CPU40 Demo, PRIV_SHELL_CMD_MAIN_ATTR); \ No newline at end of file