optimize control framework using socket, support LwIP and W5500(need to add init/socket apis)

This commit is contained in:
Liu_Weichao
2023-01-06 17:25:11 +08:00
parent 9ad282c39e
commit f8b845ca62
10 changed files with 72 additions and 20 deletions

View File

@@ -3,27 +3,27 @@ choice
default CONTROL_PROTOCOL_MELSEC_1E
config CONTROL_PROTOCOL_MELSEC_1E
bool "support melsec_1e protocol, using TCP"
select BSP_USING_LWIP
bool "support melsec_1e protocol, using SOCKET"
select CONTROL_USING_SOCKET
config CONTROL_PROTOCOL_MELSEC_3E_Q_L
bool "support melsec_3e_q_l protocol, using TCP"
select BSP_USING_LWIP
bool "support melsec_3e_q_l protocol, using SOCKET"
select CONTROL_USING_SOCKET
config CONTROL_PROTOCOL_MELSEC_3E_IQ_R
bool "support melsec_3e_iq_r protocol, using TCP"
select BSP_USING_LWIP
bool "support melsec_3e_iq_r protocol, using SOCKET"
select CONTROL_USING_SOCKET
config CONTROL_PROTOCOL_MELSEC_1C
bool "support melsec_1c protocol, using SERIAL"
select BSP_USING_SERIAL_485
select CONTROL_USING_SERIAL_485
config CONTROL_PROTOCOL_MELSEC_3C
bool "support melsec_3c protocol, using SERIAL"
select BSP_USING_SERIAL_485
select CONTROL_USING_SERIAL_485
endchoice
if BSP_USING_SERIAL_485
if CONTROL_USING_SERIAL_485
if ADD_XIZI_FETURES
config CONTROL_FRAMEWORK_UART_485_DIR
int "control framework 485 direction pin number"

View File

@@ -575,7 +575,7 @@ static int MelsecTransformRecvBuffToData(MelsecReadItem *p_read_item, uint8_t *r
return 0;
}
#ifdef BSP_USING_LWIP
#ifdef CONTROL_USING_SOCKET
/**
* @description: Melsec Get Data From Socket
* @param socket - socket
@@ -675,7 +675,7 @@ void *ReceivePlcDataTask(void *parameter)
if ((PROTOCOL_MELSEC_1C == control_protocol->protocol_type) || (PROTOCOL_MELSEC_3C == control_protocol->protocol_type)) {
MelsecGetDataBySerial((MelsecReadItem *)melsec_read_item + i);
} else {
#ifdef BSP_USING_LWIP
#ifdef CONTROL_USING_SOCKET
/*only connect socket when close socket or init*/
while (ControlConnectSocket(&plc_socket) < 0) {
PrivTaskDelay(1000);
@@ -717,7 +717,7 @@ int MelsecOpen(struct ControlProtocol *control_protocol)
int MelsecClose(struct ControlProtocol *control_protocol)
{
if ((PROTOCOL_MELSEC_1C != control_protocol->protocol_type) && (PROTOCOL_MELSEC_3C != control_protocol->protocol_type)) {
#ifdef BSP_USING_LWIP
#ifdef CONTROL_USING_SOCKET
ControlDisconnectSocket(&plc_socket);
#endif
}