add three PLC test demo and readme

This commit is contained in:
Wien.b 2023-11-23 23:23:08 -08:00
parent b82bdaea6b
commit d3c7d7ce9f
42 changed files with 522 additions and 158 deletions

View File

@ -1,5 +1,4 @@
SRC_DIR := plc_demo
SRC_DIR += modbus_tcp_server_demo
ifeq ($(CONFIG_RESOURCES_LWIP),y)

View File

@ -1,55 +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 freemodbustcpserver.c
* @brief PLC fREEMODBUSTCP SERVER app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.7.31
*/
#include <control.h>
void ControlMtcpsTest(void)
{
int i, j = 1;
int read_data_length = 0;
uint8_t read_data[128] = {0};
ControlProtocolType freemodbus_tcp_protocol = ControlProtocolFind();
if (NULL == freemodbus_tcp_protocol) {
printf("%s get freemodbus tcp protocol %p failed\n", __func__, freemodbus_tcp_protocol);
return;
}
printf("%s get freemodbus tcp protocol %p successfull\n", __func__, freemodbus_tcp_protocol);
printf("%4X %4X %4X\n",freemodbus_tcp_protocol->name,freemodbus_tcp_protocol->recipe,freemodbus_tcp_protocol->done);
if (CONTROL_REGISTERED == freemodbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(freemodbus_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(ControlMtcpsTest, M Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -1,3 +1,3 @@
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance keyence ab
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance keyence ab abb
include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,3 +1,3 @@
SRC_FILES := ab_l30.c
SRC_FILES := ab_l30erm.c ab_micro850.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,91 @@
# AB_850通信测试
[TOC]
## 通信接线及参数设置
* 网口
*Mosbus TCP协议IP192.168.250.56Port502
## 存储区
- 存储区D区
## JSON配方设计
* AB_850类型PLC需要配置控制器映射
![](./image/modbus映射.png)
* 共测试Word和real共2种类型数据,real型数据有2个Word组成以下为JSON文件解释。
- ```json
{
"device_id": 1, //设备ID默认是1此参数无效
"device_name": "AB_850", //设备名称,自定义
"communication_type": 0, //通讯协议类型 0是以太网1是串口
"socket_config": { //以太网配置
"plc_ip": "192.168.250.56", //PLC的IP地址
"local_ip": "192.168.250.233", //矽达通IP地址设定
"gateway": "192.168.250.1", //矽达通的网关地址设定
"netmask": "255.255.255.0", //矽达通子网掩码设定
"port":502 //端口号设定
},
"protocol_type": 2, //通讯协议2代表modbus-tcp协议
"read_period": 100, //交互周期ms
"read_item_list": [
{
"value_name": "CON_DATA[0]", //变量名称,自定义
"value_type": 1, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 1, //功能码。1是读线圈
"start_address": 0, //起始地址
"data_length": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "CON_DATA[1]", //变量名称,自定义
"value_type": 1, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 1, //功能码。1是读
"start_address": 1, //起始地址偏移1位106*8+1=849
"data_length": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "CON_INT", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 3, //功能码。3是读
"start_address": 2, //起始地址偏移2位
"data_length": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "CON_ARRAY[0]_1", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 3, //功能码。3是读
"start_address": 3, //起始地址偏移3位
"data_length": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "CON_ARRAY[0]_2", //变量名称,自定义,CON_ARRAY[0]_1和CON_ARRAY[0]_2组成real型数据
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 3, //功能码。3是读
"start_address": 4, //起始地址偏移4位
"data_length": 1 //默认是1代表读取1个数据类型长度
}
]
}
```
## 通信测试
(1) 新增1个通信demo命名为ab_micro850.c
(2) 复制modbus_tcp样例代码程序到ab_micro850.c文件中
(3) void **ControlAB850Test**(void) 更改函数名;
(4) PRIV_SHELL_CMD_FUNCTION(**ControlAB850Test**, AB Plc micro850 Demo**, PRIV_SHELL_CMD_MAIN_ATTR);更改测试指令;
(5) 剪裁配置完成后,用过烧写器下载至矽数通中,重启后完成测试。

View File

@ -0,0 +1,71 @@
# AB_L30ERM通信测试
[TOC]
## 通信接线及参数设置
* 网口
*Ethernet/ip协议IP192.168.250.57Port44818
## 存储区
- Ethernet/ip协议是根据变量名称搜索寄存器地址
## JSON配方设计
* 本实例共测试Word和real共2种类型数据以下为JSON文件解释。
- ```json
{
"device_id": “ab_l30”, //
"device_name": "robot", //设备名称,自定义
"communication_type": 0, //通讯协议类型 0是以太网1是串口
"socket_config": { //以太网配置
"plc_ip": "192.168.250.37", //PLC的IP地址
"local_ip": "192.168.250.123", //矽达通IP地址设定
"gateway": "192.168.250.1", //矽达通的网关地址设定
"netmask": "255.255.255.0", //矽达通子网掩码设定
"port":502 //端口号设定
},
"protocol_type": 12, //通讯协议12代表ethernet/ip协议
"read_period": 100, //交互周期ms
"read_item_list": [
{
"value_name": "L30_SPEED", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"wordlen": "WORD", //以WORD方式传输
"amount": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "L30_TORQUE", //变量名称,自定义
"value_type": 9, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"wordlen": 2, //以WORD方式传输
"amount": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "D", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"wordlen": 3, //以WORD方式传输
"amount": 1 //默认是1代表读取1个数据类型长度
}
]
}
```
## 通信测试
(1) 新增1个通信demo命名为ab_l30erm.c
(2) 复制modbus_tcp样例代码程序到ab_l30erm.c文件中
(3) void **ControlABL30Test**(void) 更改函数名;
(4) PRIV_SHELL_CMD_FUNCTION(**ControlABL30Test**, AB Plc l30ermDemo**, PRIV_SHELL_CMD_MAIN_ATTR);更改测试指令;
(5) 剪裁配置完成后,用过烧写器下载至矽数通中,重启后完成测试。

View File

@ -15,12 +15,12 @@
* @brief PLC ABB L30 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.8.27
*/
#include <control.h>
void Controlabl30Test(void)
void ControlABL30Test(void)
{
int i = 0;
uint16_t read_data_length = 0;
@ -45,4 +45,4 @@ void Controlabl30Test(void)
//ControlProtocolClose(CIP_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(Controlabl30Test, Ab Plc CIP Demo, PRIV_SHELL_CMD_MAIN_ATTR);
PRIV_SHELL_CMD_FUNCTION(ControlABL30Test, Ab Plc CIP Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,52 @@
/*
* 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 ab_micro850.c
* @brief PLC AB MICRO850 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.10.5
*/
#include <control.h>
void ControlAB850Test(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(ControlAB850Test, AB Plc MICRO850 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,34 @@
{
"device_id": "ab_l30",
"device_name": "robot",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.57",
"local_ip": "192.168.250.123",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 44818
},
"protocol_type": 12,
"read_period": 100,
"read_item_list": [
{
"value_name": "L30_SPEED",
"value_type": 3,
"wordlen": "WORD",
"amount": 1
},
{
"value_name": "L30_TORQUE",
"value_type": 9,
"wordlen": "WORD",
"amount": 1
},
{
"value_name": "D",
"value_type": 3,
"wordlen": "WORD",
"amount": 1
}
]
}

View File

@ -0,0 +1,51 @@
{
"device_id": 1,
"device_name": "AB_850",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.32",
"local_ip": "192.168.250.56",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 502
},
"protocol_type": 2,
"read_period": 100,
"read_item_list": [
{
"value_name": "D106.0",
"value_type": 1,
"function_code": 1,
"start_address": 848,
"quantity": 1
},
{
"value_name": "D106.1",
"value_type": 1,
"function_code": 1,
"start_address":849,
"quantity": 1
},
{
"value_name": "D100",
"value_type": 3,
"function_code": 3,
"start_address": 100,
"quantity": 1
},
{
"value_name": "D102",
"value_type": 3,
"function_code": 3,
"start_address": 102,
"quantity": 1
},
{
"value_name": "D103",
"value_type": 3,
"function_code": 3,
"start_address": 103,
"quantity": 1
}
]
}

View File

@ -1,3 +1,3 @@
SRC_FILES := freemodbustcpserver.c
SRC_FILES := abb_pm5630.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,87 @@
# ABB通信测试
[TOC]
## 通信接线及参数设置
* 网口
*Mosbus TCP协议IP192.168.250.58Port502
## 存储区
- 存储区MW区
## JSON配方设计
* 共测试Word和real共2种类型数据,real型数据有2个Word组成以下为JSON文件解释。
- ```json
{
"device_id": 1, //设备ID默认是1此参数无效
"device_name": "ABB_PM5630", //设备名称,自定义
"communication_type": 0, //通讯协议类型 0是以太网1是串口
"socket_config": { //以太网配置
"plc_ip": "192.168.250.58", //PLC的IP地址
"local_ip": "192.168.250.233", //矽达通IP地址设定
"gateway": "192.168.250.1", //矽达通的网关地址设定
"netmask": "255.255.255.0", //矽达通子网掩码设定
"port":502 //端口号设定
},
"protocol_type": 2, //通讯协议2代表modbus-tcp协议
"read_period": 100, //交互周期ms
"read_item_list": [
{
"value_name": "MW0", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 3, //功能码。3是读
"start_address": 0, //起始地址
"data_length": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "MW1", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 3, //功能码。3是读
"start_address": 1, //起始地址偏移1位
"data_length": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "MW10", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 3, //功能码。3是读
"start_address": 10, //起始地址偏移10位
"data_length": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "MD20_1", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 3, //功能码。3是读
"start_address": 20, //起始地址偏移20位
"data_length": 1 //默认是1代表读取1个数据类型长度
},
{
"value_name": "MD20_2", //变量名称,自定义,MD20_1和MD20_2组成real型数据
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"function_code": 3, //功能码。3是读
"start_address": 21, //起始地址偏移21位
"data_length": 1 //默认是1代表读取1个数据类型长度
}
]
}
```
## 通信测试
(1) 新增1个通信demo命名为abb_pm5630.c
(2) 复制modbus_tcp样例代码程序到abb_pm5630.c文件中
(3) void **ControlABBPM5630Test**(void) 更改函数名;
(4) PRIV_SHELL_CMD_FUNCTION(**ControlABBPM5630Test**, ABB Plc PM5630 Demo**, PRIV_SHELL_CMD_MAIN_ATTR);更改测试指令;
(5) 剪裁配置完成后,用过烧写器下载至矽数通中,重启后完成测试。

View File

@ -0,0 +1,52 @@
/*
* 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 abb_pm5630.c
* @brief PLC ABB pm5630 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.10.20
*/
#include <control.h>
void ControlABBPM5630Test(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(ControlABBPM5630Test, ABB Plc PM5630 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

View File

@ -0,0 +1,51 @@
{
"device_id": 1,
"device_name": "ABB_PM5630",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.32",
"local_ip": "192.168.250.58",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 502
},
"protocol_type": 2,
"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
},
{
"value_name": "MW10",
"value_type": 3,
"function_code": 3,
"start_address": 10,
"quantity": 1
},
{
"value_name": "MD20_1",
"value_type": 3,
"function_code": 3,
"start_address":20,
"quantity": 1
},
{
"value_name": "MD20_2",
"value_type": 3,
"function_code": 3,
"start_address":21,
"quantity": 1
}
]
}

View File

@ -21,4 +21,3 @@ config CONNECTION_ADAPTER_FREEMODBUSTCP
if CONNECTION_ADAPTER_FREEMODBUSTCP
source "$APP_DIR/Framework/connection/industrial_network/freemodbus_tcp/Kconfig"
endif

View File

@ -1,92 +0,0 @@
void LwipTcpRecvTest(void)
{
uint8_t enet_port = 0; ///< test enet port 0
lwip_config_net(enet_port, lwip_ipaddr, lwip_netmask, lwip_gwaddr);
uint8_t *recv_data;
socklen_t sin_size;
int sock = -1, connected, bytes_received, i;
struct sockaddr_in server_addr, client_addr;
fd_set readset;
struct timeval timeout;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
KPrintf("[%s:%d] Socket error!\n", __FILE__, __LINE__);
goto __exit;
}
recv_data = (uint8_t *)malloc(128);
if (recv_data == NULL) {
KPrintf("No memory!\n");
goto __exit;
}
//configure tcp server param
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(tcp_server_port);
server_addr.sin_addr.s_addr = INADDR_ANY;
memset(&(server_addr.sin_zero), 0x0, sizeof(server_addr.sin_zero));
if (bind(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1) {
KPrintf("Unable to bind!\n");
goto __exit;
}
if (listen(sock, 5) == -1) {
KPrintf("Listen error!\n");
goto __exit;
}
timeout.tv_sec = 30;
timeout.tv_usec = 0;
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) ==-1) {
KPrintf("setsockopt failed!");
goto __exit;
}
while (1) {
FD_ZERO(&readset);
FD_SET(sock, &readset);
if (select(sock + 1, &readset, NULL, NULL, &timeout) == 0) {
continue;
}
sin_size = sizeof(struct sockaddr_in);
connected = accept(sock, (struct sockaddr *)&client_addr, &sin_size);
while (1) {
bytes_received = recv(connected, recv_data, 128, 0);
if (bytes_received == 0) {
KPrintf("client disconnected (%s, %d)\n",inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));
break;
} else if (bytes_received < 0) {
KPrintf("recv error, client: (%s, %d)\n",inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));
break;
} else {
KPrintf("new client connected from (%s, %d)\n",inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));
KPrintf("recv data length %d Bytes\n", bytes_received);
for (i = 0; i < bytes_received; i ++) {
KPrintf("data 0x%x\n", recv_data[i]);
}
if (i = bytes_received) {
KPrintf("\r\n");
memset(recv_data, 0, sizeof(recv_data));
}
}
}
if (connected >= 0) {
closesocket(connected);
connected = -1;
break;
}
__exit:
if (sock >= 0) closesocket(sock);
if (recv_data) free(recv_data);
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) |
SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),TCPRecv, LwipTcpRecvTest, TCP Recv message);

View File

@ -112,7 +112,6 @@ int MBServer()
MdelayKTask(100);
}
}
return iExitCode;
}

View File

@ -14,3 +14,11 @@ if CONTROL_PROTOCOL_MODBUS_UART
source "$APP_DIR/Framework/control/ipc_protocol/modbus_uart/Kconfig"
endif
config CONTROL_PROTOCOL_ETHERCAT
bool "Using ethercat control protocol"
default n
select CONTROL_USING_SOCKET
if CONTROL_PROTOCOL_ETHERCAT
source "$APP_DIR/Framework/control/ipc_protocol/ethercat/Kconfig"
endif

View File

@ -6,5 +6,9 @@ ifeq ($(CONFIG_CONTROL_PROTOCOL_MODBUS_UART), y)
SRC_DIR := modbus_uart
endif
ifeq ($(CONFIG_CONTROL_PROTOCOL_ETHERCAT), y)
SRC_DIR := ethercat
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -33,5 +33,6 @@ config CONTROL_PROTOCOL_CIP
default n
select CONTROL_USING_SOCKET
if CONTROL_PROTOCOL_CIP
source "$APP_DIR/Framework/control/plc_protocol/cip/Kconfig"
source "$APP_DIR/Framework/control/plc_protocol/ethernet_ip_cip/Kconfig"
endif

View File

@ -15,7 +15,7 @@ ifeq ($(CONFIG_CONTROL_PROTOCOL_S7), y)
endif
ifeq ($(CONFIG_CONTROL_PROTOCOL_CIP), y)
SRC_DIR := cip
SRC_DIR := ethernet_ip_cip
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,2 +1,3 @@
SRC_FILES := $(wildcard ./*.c)
include $(KERNEL_ROOT)/compiler.mk

View File

@ -57,6 +57,7 @@ typedef enum
PROTOCOL_MELSEC_3C,
PROTOCOL_FREEMODBUS_TCP_SERVER,
PROTOCOL_CIP,
PROTOCOL_ETHERCAT,
PROTOCOL_END
}ProtocolType;
@ -116,6 +117,7 @@ int ControlProtocolIoctl(struct ControlProtocol *control_protocol, int cmd, void
/*Control Framework new certain Protocol*/
ControlProtocolType control_protocol;
#ifdef __cplusplus
}
#endif

View File

@ -57,6 +57,10 @@ extern int FreeModbusTcpServerInit(struct ControlRecipe *p_recipe);
extern int CipProtocolInit(struct ControlRecipe *p_recipe);
#endif
#ifdef CONTROL_PROTOCOL_ETHERCAT
extern int EthercatProtocolInit(struct ControlRecipe *p_recipe);
#endif
/*
CONTROL FRAMEWORK READ DATA FORMAT:
| HEAD |device_id|read data length|read item count| data |
@ -103,6 +107,11 @@ static struct ControlProtocolInitParam protocol_init[] =
#ifdef CONTROL_PROTOCOL_CIP
{ PROTOCOL_CIP, CipProtocolInit },
#endif
#ifdef CONTROL_PROTOCOL_ETHERCAT
{ PROTOCOL_ETHERCAT, EthercatProtocolInit },
#endif
{ PROTOCOL_END, NULL },
};