Hi all,
i am trying to send and receive UDP packet on my Hardware. I am using LPC1788 with PHY DP83848TSQ. I already test the Hardware with an example code called "easyweb" and it work. And then i try to use the example programm called "UDP Socket" and it doesn't work. I try to get the netStatus from udp_send and any other function. The net_initialize, udp_open, udp_get_socket seems work finely since it show me "Operations Succeeded". The only problem is udp_send since it show me "unspecified error". Have anyone any idea what happened? Anyway i am using ARM Keil uVision5
this is the code
#include "LPC177x_8x.h" #include "RTE_Components.h" #include "system_LPC177x_8x.h" #include "rl_net.h" #include "stdlib.h" #include "stdio.h" #include "string.h" #include "cmsis_os.h" int32_t sock_udp; osThreadId g_threadIdUDP; void disconnect_udp (uint8_t sock_udp) { udp_close(sock_udp); udp_release_socket(sock_udp); } uint32_t callback_udp (int32_t socket, const uint8_t *ip_addr, uint16_t port, const uint8_t *buf, uint32_t len) { return (0); } void udp_send_data (void) { int udp_send_status; if (sock_udp >= 0) { uint8_t dest_ip [IP4_ADDR_LEN]; uint8_t *sendbuf; dest_ip[0] = 192; dest_ip[1] = 168; dest_ip[2] = 50; dest_ip[3] = 172; sendbuf = udp_get_buf (2); sendbuf[0] = 0x01; sendbuf[1] = 0xAA; udp_send_status = udp_send (sock_udp, dest_ip, 2000, sendbuf, 2); printf("udp_send_status %i\n", udp_send_status); -> it show me 2, it means "unspecified error" } } void udp_thread(void const *arg) { int net_initialize_status; int udp_open_status; int net_main_status; //Initialize Network Component, resources and interfaces net_initialize_status = net_initialize (); printf("net_initialize %i = Operation succeeded\n", net_initialize_status); ->netStatus over here also Show me 0. It means Operation succeeded osDelay(100); //Allocate a free UDP socket, UDP_OPT_SEND_CHECKSUM = Calculate transmit checksum, UDP_OPT_VERIFY_CHECKSUM = Verify receive checksum sock_udp = udp_get_socket(0,UDP_OPT_SEND_CHECKSUM | UDP_OPT_VERIFY_CHECKSUM, callback_udp); printf("sock_udp %i socket handle number \n", sock_udp); if (sock_udp >= 0) // Initialize UDP socket and open port { //Open UDP socket for communication udp_open_status = udp_open (sock_udp, 2000); printf("udp_open_status %i = ",udp_open_status); -> netStatus show me 0, it means Operation succeeded if(udp_open_status ==0) { printf("Operation succeeded, open socket succesful netOK \n"); } else { printf("ERROR to open socket! \n"); } } while(1) { net_main_status = net_main(); //Run Network Component main function printf("net_main_status = %i \n",net_main_status); if(net_main_status == 0) printf("System is idle \n"); else printf("Another call to this function needed \n"); osDelay(50); udp_send_data(); //Send data to a remote node osDelay(100); } } #define UDPTHREAD_STACKSIZE (2048) osThreadDef (udp_thread, osPriorityNormal , 1, UDPTHREAD_STACKSIZE); int main() { g_threadIdUDP = osThreadCreate(osThread(udp_thread), NULL); while(1) { osThreadYield(); } }
Hi,
I am using latest MDK which
www.keil.com/.../group__udp__user__api.html
netStatus netUDP_Send