개인사정으로 답변이 늦었습니다.!
도움감사드립니다.
수정된 부분 코드 첨부드립니다.
1. void uart_to_ether(uint8_t sock) 수정 된 부분
if((netinfo->remote_ip[0] == 0x00) && (netinfo->remote_ip[1] == 0x00) && (netinfo->remote_ip[2] == 0x00) && (netinfo->remote_ip[3] == 0x00))
{
if((peerip[0] == 0x00) && (peerip[1] == 0x00) && (peerip[2] == 0x00) && (peerip[3] == 0x00))
{
if(serial->serial_debug_en) printf(" > SEG:UDP_MODE:DATA SEND FAILED - UDP Peer IP/Port required (0.0.0.0)\r\n");
}
else
{
// UDP 1:N mode
/**
******************************************************************************
* @author yhlee
* @date Jan-2020
* @description : each server1 & server2 send the data include their last of
ip address to MCU thoruogh wiz750sr
g_send_buf[05] contained peerip[3]
ex> server1 ip : 192.168.1.81
server1 send packet 59 59 00 08 00 51 xx xx xx ..
(51 means hex 0x51 so it's 81)
and then MCU send ack packet 59 59 00 08 00 51 xx xx xx ..
wiz750sr get these packet to g_send_buf[]
g_send_buf[05] could decied whether module send the data to
server1 or server2
******************************************************************************
**/
if(g_send_buf[05] == peerip_1[3]){
setSn_DHAR(sock, mac_1);
memcpy(peerip, peerip_1, 4);
peer1_seqence_flag = 1;
peer2_seqence_flag = 0;
}
else if(g_send_buf[05] == peerip_2[3]){
setSn_DHAR(sock, mac_2);
memcpy(peerip, peerip_2, 4);
peer1_seqence_flag = 0;
peer2_seqence_flag = 1;
}
sent_len = (int16_t)sendto(sock, g_send_buf, len, peerip, peerport);
if(g_send_buf[05] == peerip_1[3]){
getSn_DHAR(sock, mac_1);
if((mac_1[0] == 0x00) && (mac_1[1] == 0x00) && (mac_1[2] == 0x00) && (mac_1[3] == 0x00) && (mac_1[4] == 0x00) && (mac_1[5] == 0x00))
{
if(serial->serial_debug_en) printf("ARP1 Inspction Error %2x:%2x:%2x:%2x:%2x:%2x\r\n",mac_1[0],mac_1[1],mac_1[2],mac_1[3],mac_1[4],mac_1[5]);
}
else mac_flag1 = 1;
}
else if(g_send_buf[05] == peerip_2[3]) {
getSn_DHAR(sock, mac_2);
if((mac_2[0] == 0x00) && (mac_2[1] == 0x00) && (mac_2[2] == 0x00) && (mac_2[3] == 0x00) && (mac_2[4] == 0x00) && (mac_2[5] == 0x00))
{
if(serial->serial_debug_en) printf("ARP2 Inspction Error %2x:%2x:%2x:%2x:%2x:%2x\r\n",mac_2[0],mac_2[1],mac_2[2],mac_2[3],mac_2[4],mac_2[5]);
}
else mac_flag2 = 1;
}
if(serial->serial_debug_en) {
if(peer1_seqence_flag)
{
printf(" > UDP Peer IP/Port1: %d.%d.%d.%d : %d\r\n", peerip_1[0], peerip_1[1], peerip_1[2], peerip_1[3], peerport);
printf("RECV ARP packet1 from %2x:%2x:%2x:%2x:%2x:%2x\r\n",mac_1[0],mac_1[1],mac_1[2],mac_1[3],mac_1[4],mac_1[5]);
}
else if(peer2_seqence_flag)
{
printf(" > UDP Peer IP/Port2: %d.%d.%d.%d : %d\r\n", peerip_2[0], peerip_2[1], peerip_2[2], peerip_2[3], peerport);
printf("RECV ARP packet2 from %2x:%2x:%2x:%2x:%2x:%2x\r\n",mac_2[0],mac_2[1],mac_2[2],mac_2[3],mac_2[4],mac_2[5]);
}
}
/*********************************************************************************/
}
}
<void ether_to_uart(uint8_t sock)> 에서 수정된 부분
case SOCK_UDP: // UDP_MODE
e2u_size = recvfrom(sock, g_recv_buf, len, peerip, &peerport);
if((memcmp(peerip_1, peerip, 4) != 0) && (!peerip_flag1))// yhlee
{
memcpy(peerip_1, peerip, 4);
peerip_flag1 = 1;
if(serial->serial_debug_en) {
//printf(" > UDP Peer IP/Port1: %d.%d.%d.%d : %d\r\n", peerip_1[0], peerip_1[1], peerip_1[2], peerip_1[3], peerport);
}
}
else if((memcmp(peerip_1, peerip, 4) == 0) && (peerip_flag1))// yhlee
{
memcpy(peerip_1, peerip, 4);
peerip_flag1 = 1;
if(serial->serial_debug_en) {
//printf(" > UDP Peer IP/Port1: %d.%d.%d.%d : %d\r\n", peerip_1[0], peerip_1[1], peerip_1[2], peerip_1[3], peerport);
}
}
else if((memcmp(peerip_2, peerip, 4) != 0) && (!peerip_flag2))
{
memcpy(peerip_2, peerip, 4);
peerip_flag2 = 1;
if(serial->serial_debug_en) {
//printf(" > UDP Peer IP/Port2: %d.%d.%d.%d : %d\r\n", peerip_2[0], peerip_2[1], peerip_2[2], peerip_2[3], peerport);
}
}
else if((memcmp(peerip_1, peerip, 4) != 0) && (memcmp(peerip_2, peerip, 4) != 0) && (peerip_flag1) && (peerip_flag2))
{
memcpy(peerip_1, peerip, 4);
peerip_flag1 = 1;
if(serial->serial_debug_en) {
//printf(" > UDP Peer IP/Port1: %d.%d.%d.%d : %d\r\n", peerip_1[0], peerip_1[1], peerip_1[2], peerip_1[3], peerport);
}
}
/*if(memcmp(peerip_tmp, peerip, 4) != 0)
{
memcpy(peerip_tmp, peerip, 4);
if(serial->serial_debug_en) printf(" > UDP Peer IP/Port: %d.%d.%d.%d : %d\r\n", peerip[0], peerip[1], peerip[2], peerip[3], peerport);
}*/
break;
<int32_t sendto(uint8_t sn, uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port)> 에서 수정된 부분
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
setSUBR(0);
#endif
if(peer1_seqence_flag && mac_flag1) setSn_CR(sn,Sn_CR_SEND_MAC); // yhlee
else if(peer2_seqence_flag && mac_flag2) setSn_CR(sn,Sn_CR_SEND_MAC); // yhlee
else setSn_CR(sn,Sn_CR_SEND); // yhlee
//setSn_CR(sn,Sn_CR_SEND);
/* wait to process the command... */
while(getSn_CR(sn));
#if _WIZCHIP_ == 5200 // for W5200 ARP errata
setSUBR((uint8_t*)"\x00\x00\x00\x00");
#endif
이상 입니다. 검토 부탁드립니다.