1.add br ppc2100 ethernet test app 2.add br ppc2100 test readme

This commit is contained in:
jqy1988 2023-05-08 15:15:41 +08:00
parent b37885b839
commit 2df93dc327
4 changed files with 181 additions and 1 deletions

View File

@ -1,3 +1,3 @@
SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c
SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c br_ppc2100.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,23 @@
# 贝加莱 PPC2100通信测试
[TOC]
## 通信接线及参数设置
* 网口
* 通过ETH1 RJ45 网口连接
* 网口参数IP192.168.250.26 Port502
* 测试的协议:Modbus TCP
## 存储区
- 贝加莱PLC与其他PLC不同没有明确类似MD等这样的存储区的概念Modbus地址取决于库函数中结构体变量索引。
## 通信测试
- 共测试BOOLINT16INT32FLOAT,DOUBLE 共五种类型数据。
- 测试BOOL型变量用功能码01测其他类型变量用功能码03。
-

View File

@ -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 br_ppc2100.c
* @brief PLC BR PPC2100 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.5.8
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlBrTest_PPC2100(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
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(ControlBrTest_PPC2100, Delta ppc2100 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,93 @@
{
"device_id": 1,
"device_name": "BR_PPC2100",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.26",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.254.0",
"port": 502
},
"protocol_type": 2,
"read_period": 2000,
"read_item_list": [
{
"value_name": "motorrun",
"value_type": 1,
"function_code": 2,
"start_address": 0,
"quantity": 1
},
{
"value_name": "motorstop",
"value_type": 1,
"function_code": 2,
"start_address": 1,
"quantity": 1
},
{
"value_name": "valueopen",
"value_type": 1,
"function_code": 1,
"start_address": 100,
"quantity": 1
},
{
"value_name": "valueclose",
"value_type": 1,
"function_code": 1,
"start_address": 101,
"quantity": 1
},
{
"value_name": "step",
"value_type": 3,
"function_code": 4,
"start_address": 100,
"quantity": 1
},
{
"value_name": "temperature",
"value_type": 9,
"function_code": 4,
"start_address": 101,
"quantity": 2
},
{
"value_name": "status",
"value_type": 4,
"function_code": 4,
"start_address": 103,
"quantity": 2
},
{
"value_name": "mode",
"value_type": 3,
"function_code": 3,
"start_address": 200,
"quantity": 1
},
{
"value_name": "setTemperature",
"value_type": 9,
"function_code": 3,
"start_address": 201,
"quantity": 2
},
{
"value_name": "setConuter",
"value_type": 4,
"function_code": 3,
"start_address": 203,
"quantity": 2
},
{
"value_name": "LrealTest",
"value_type": 8,
"function_code": 3,
"start_address": 205,
"quantity": 4
}
]
}