Hi all,
I'm using UV5 to communicate by TCP/sockets with a remote PC. I use the BSD_Client exemple and change a few things (GPIO, IP, PORTs) to communicate with my PC program. It work but only for a 30 seconds, after that the communication stop for like 10 seconds and start again...
#include "cmsis_os.h" /* CMSIS RTOS definitions */ #include "rl_net.h" /* Network definitions */ //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- // <h>Remote IP Address // ==================== // // <o>IP1: Address byte 1 <0-255> // Default: 192 #define IP1 192 // <o>IP2: Address byte 2 <0-255> // Default: 168 #define IP2 168 // <o>IP3: Address byte 3 <0-255> // Default: 0 #define IP3 1 // <o>IP4: Address byte 4 <0-255> // Default: 100 #define IP4 62 // </h> // <o>Remote Port <1-65535> // Do not set number of port too small, // maybe it is already used. // Default: 1001 #define PORT_NUM 5001 // <o>Communication Protocol <0=> Stream (TCP) <1=> Datagram (UDP) // Selecet a protocol for sending data. #define PROTOCOL 0 // <o>LED Blinking speed <1-100> // Blinking speed = SPEED * 100ms // Default: 2 #define SPEED 1 //------------- <<< end of configuration section >>> ----------------------- #define BLINKLED 0x01 /* Command for blink the leds */ #if (PROTOCOL == 0) #define SOCKTYPE SOCK_STREAM #else #define SOCKTYPE SOCK_DGRAM #endif static void Client (void const *arg); osThreadDef(Client, osPriorityRealtime, 2, 0); /*---------------------------------------------------------------------------- Thread 'Client': BSD Client socket process *---------------------------------------------------------------------------*/ static void Client (void const *arg) { SOCKADDR_IN addr; int sock, res; char dbuf[4]; while (1) { sock = socket (AF_INET, SOCKTYPE, IPPROTO_TCP ); addr.sin_port = htons(PORT_NUM); addr.sin_family = PF_INET; addr.sin_addr.s_b1 = IP1; addr.sin_addr.s_b2 = IP2; addr.sin_addr.s_b3 = IP3; addr.sin_addr.s_b4 = IP4; connect (sock, (SOCKADDR *)&addr, sizeof (addr)); while (1) { dbuf[0] = 'O'; dbuf[1] = 'S'; dbuf[2] = 'C'; res = send (sock, (char *)&dbuf, 2, 0); if (res < 0) { break; } osDelay (100 * SPEED); } closesocket (sock); } } /*---------------------------------------------------------------------------- Main Thread 'main': Run Network *---------------------------------------------------------------------------*/ int main (void) { // LED_Initialize (); // init_display (); net_initialize (); // Create networking task osThreadCreate (osThread(Client), NULL); while(1) { net_main (); osThreadYield (); } }
Any ideas about what is happening?
Luis Felipe
Which version of the middleware are you using? In Middleware v6.50 we have solved an issue that could cause site effects like this.
Refer to: http://www.keil.com/pack/doc/mw/Network/html/netw_revhist.html - corrected receive frame queue overflow processing in Ethernet interface