Tool/software: Code Composer Studio
Someone can give a simple example of transferring a UDP packet using the library uip 1.0?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Someone can give a simple example of transferring a UDP packet using the library uip 1.0?
Hello Vladimir,
We don't really have any UDP examples for TivaWare. If you want to use TI-RTOS for TivaC, you could look at their example for UDP Echo which is part of their Network examples for Ethernet.
Alternatively, you could reference this E2E post which has a strong list of options for implementing your own UDP example: https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/498942/1805878#1805878
Ok. i changed enet lwip example: just transmit message. I do not get anything on port 7070 Where I'm wrong? I selected my inserts
nt
main(void)
{
uint32_t ui32User0, ui32User1;
uint8_t pui8MACArray[8];
//
// Run from the PLL at 120 MHz.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Configure the device pins.
//
PinoutSet();
//
// Initialize the display driver.
//
Kentec320x240x16_SSD2119Init(g_ui32SysClock);
//
// Initialize the graphics context.
//
GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119);
//
// Draw the application frame.
//
FrameDraw(&g_sContext, "enet-lwip");
//
// Configure SysTick for a periodic interrupt.
//
ROM_SysTickPeriodSet(g_ui32SysClock / SYSTICKHZ);
ROM_SysTickEnable();
ROM_SysTickIntEnable();
//
// Initialize the file system.
//
fs_init();
//
// Configure the hardware MAC address for Ethernet Controller filtering of
// incoming packets. The MAC address will be stored in the non-volatile
// USER0 and USER1 registers.
//
ROM_FlashUserGet(&ui32User0, &ui32User1);
if((ui32User0 == 0xffffffff) || (ui32User1 == 0xffffffff))
{
//
// We should never get here. This is an error if the MAC address has
// not been programmed into the device. Exit the program.
//
GrContextForegroundSet(&g_sContext, ClrRed);
GrStringDrawCentered(&g_sContext, "MAC Address", -1,
GrContextDpyWidthGet(&g_sContext) / 2,
(GrContextDpyHeightGet(&g_sContext) / 2) - 4,
false);
GrStringDrawCentered(&g_sContext, "Not Programmed!", -1,
GrContextDpyWidthGet(&g_sContext) / 2,
(GrContextDpyHeightGet(&g_sContext) / 2) + 16,
false);
while(1)
{
}
}
//
// Convert the 24/24 split MAC address from NV ram into a 32/16 split MAC
// address needed to program the hardware registers, then program the MAC
// address into the Ethernet Controller registers.
//
pui8MACArray[0] = ((ui32User0 >> 0) & 0xff);
pui8MACArray[1] = ((ui32User0 >> 8) & 0xff);
pui8MACArray[2] = ((ui32User0 >> 16) & 0xff);
pui8MACArray[3] = ((ui32User1 >> 0) & 0xff);
pui8MACArray[4] = ((ui32User1 >> 8) & 0xff);
pui8MACArray[5] = ((ui32User1 >> 16) & 0xff);
//
// Initialze the lwIP library, using DHCP.
//
lwIPInit(g_ui32SysClock, pui8MACArray, 0, 0, 0, IPADDR_USE_AUTOIP);
void *UDPSock = udp_new();
udp_recv(UDPSock, NULL, NULL);
udp_bind(UDPSock, IP_ADDR_ANY, 7070);
udp_connect(UDPSock, IP_ADDR_ANY, 7070);
char buf[500] = "HELLO KITTY";
struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, 500, PBUF_RAM);
//struct ip_addr server;
// IP4_ADDR(&server, 192, 168, 253, 236);
//
//
// Setup the device locator service.
//
//LocatorInit();
//LocatorMACAddrSet(pui8MACArray);
//LocatorAppTitleSet("DK-TM4C129X enet_lwip");
//
// Initialize the sample httpd server.
//
//httpd_init();
//
// Set the interrupt priorities. We set the SysTick interrupt to a higher
// priority than the Ethernet interrupt to ensure that the file system
// tick is processed if SysTick occurs while the Ethernet handler is being
// processed. This is very likely since all the TCP/IP and HTTP work is
// done in the context of the Ethernet interrupt.
//
ROM_IntPrioritySet(INT_EMAC0, ETHERNET_INT_PRIORITY);
ROM_IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY);
uint32_t ui32Loop;
//
// Loop forever. All the work is done in interrupt handlers.
//
while(1)
{
p=pbuf_alloc(PBUF_TRANSPORT, 500, PBUF_RAM);
memcpy(p->payload, buf, 500);
udp_sendto(UDPSock,p,IPADDR_ANY,7070);
pbuf_free(p);
for(ui32Loop = 0; ui32Loop < 2000000; ui32Loop++)
{}
}
}
Can you try with DHCP first before you use AUTOIP?
-Done. Nothink changed. I get IP-adress 169.254.159.146. Network is configured for 169.254.159.1 mask 255.255.0.0
#define LWIP_DHCP 1 #define LWIP_AUTOIP 1
-Done. Nothink changed
struct udp_pcb *pcb; pcb = udp_new();
-Done. Nothink changed
For more LwIP questions, please directly post your questions to LwIP forum
link?