Added FSM for TFTP client in main loop, and WIZNET standard TCP/UDP

loopback
This commit is contained in:
maxxir
2019-03-31 20:30:09 +04:00
parent c99b2d6822
commit 81e2295950
3 changed files with 126 additions and 83 deletions

View File

@@ -24,7 +24,7 @@ int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port)
getSn_DIPR(sn, destip);
destport = getSn_DPORT(sn);
printf("%d:Connected - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport);
PRINTF("%d:Connected - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport);
#endif
setSn_IR(sn,Sn_IR_CON);
}
@@ -55,12 +55,12 @@ int32_t loopback_tcps(uint8_t sn, uint8_t* buf, uint16_t port)
#endif
if((ret = disconnect(sn)) != SOCK_OK) return ret;
#ifdef _LOOPBACK_DEBUG_
printf("%d:Socket Closed\r\n", sn);
PRINTF("%d:Socket Closed\r\n", sn);
#endif
break;
case SOCK_INIT :
#ifdef _LOOPBACK_DEBUG_
printf("%d:Listen, TCP server loopback, port [%d]\r\n", sn, port);
PRINTF("%d:Listen, TCP server loopback, port [%u]\r\n", sn, port);
#endif
if( (ret = listen(sn)) != SOCK_OK) return ret;
break;
@@ -102,7 +102,7 @@ int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destpo
if(getSn_IR(sn) & Sn_IR_CON) // Socket n interrupt register mask; TCP CON interrupt = connection with peer is successful
{
#ifdef _LOOPBACK_DEBUG_
printf("%d:Connected to - %d.%d.%d.%d : %d\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport);
PRINTF("%d:Connected to - %d.%d.%d.%d : %u\r\n",sn, destip[0], destip[1], destip[2], destip[3], destport);
#endif
setSn_IR(sn, Sn_IR_CON); // this interrupt should be write the bit cleared to '1'
}
@@ -140,13 +140,13 @@ int32_t loopback_tcpc(uint8_t sn, uint8_t* buf, uint8_t* destip, uint16_t destpo
#endif
if((ret=disconnect(sn)) != SOCK_OK) return ret;
#ifdef _LOOPBACK_DEBUG_
printf("%d:Socket Closed\r\n", sn);
PRINTF("%d:Socket Closed\r\n", sn);
#endif
break;
case SOCK_INIT :
#ifdef _LOOPBACK_DEBUG_
printf("%d:Try to connect to the %d.%d.%d.%d : %d\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport);
PRINTF("%d:Try to connect to the %d.%d.%d.%d : %u\r\n", sn, destip[0], destip[1], destip[2], destip[3], destport);
#endif
if( (ret = connect(sn, destip, destport)) != SOCK_OK) return ret; // Try to TCP connect to the TCP server (destination)
break;
@@ -186,7 +186,7 @@ int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port)
if(ret <= 0)
{
#ifdef _LOOPBACK_DEBUG_
printf("%d: recvfrom error. %ld\r\n",sn,ret);
PRINTF("%d: recvfrom error. %ld\r\n",sn,ret);
#endif
return ret;
}
@@ -198,7 +198,7 @@ int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port)
if(ret < 0)
{
#ifdef _LOOPBACK_DEBUG_
printf("%d: sendto error. %ld\r\n",sn,ret);
PRINTF("%d: sendto error. %ld\r\n",sn,ret);
#endif
return ret;
}
@@ -213,7 +213,7 @@ int32_t loopback_udps(uint8_t sn, uint8_t* buf, uint16_t port)
if((ret = socket(sn, Sn_MR_UDP, port, 0x00)) != sn)
return ret;
#ifdef _LOOPBACK_DEBUG_
printf("%d:Opened, UDP loopback, port [%d]\r\n", sn, port);
PRINTF("%d:Opened, UDP loopback, port [%u]\r\n", sn, port);
#endif
break;
default :

View File

@@ -6,6 +6,8 @@ extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
#include "../../globals.h"
/* Loopback test debug message printout enable */
#define _LOOPBACK_DEBUG_