Other Parts Discussed in Thread: TM4C1294KCPDT, SYSBIOS
Processor is a TM4C1294KCPDT TIVA on a proprietary PCBA. Using NDK version 2.24.03.35 and TI-RTOS version 2.14.0.10. The TIVA board is on a 10/100 ethernet LAN using DHCP. A PC is also on the network. The network is physically isolated with the only other device on the network being a router.
Our proprietary PC application sends out a broadcast packet (Destination IP=255.255.255.255, Destination MAC=FF:FF:FF:FF:FF:FF); Source Port is 23, Destination Port is 23. The packet has four bytes of data (total packet length is 46 bytes. I have confirmed this using WIRESHARK.) Unfortunately, the TIVA does not seem to receive this packet. By this I mean that the fdSelect in the code below does not return. The TIVA board will, however, still respond to a ping to the IP address it received from the DHCP server.
I have tried this with the NDK priority in my app.cfg file set to both high and low priority via XCONF.
Here are the priorities for the various tasks running:
// TASK Priorities
#define HandpadAction_Task_Priority 0x01
#define Housekeeping_Task_Priority 0x02
#define I2C_Eeprom_Task_Priority 0x03
// NDK Low Task Priority 0x04 (changed to this value via XCONF)
#define RS485Scan_Task_Priority 0x05
#define TrajectGen_Task_Priority 0x06
#define Parser_Task_Priority 0x07
// NDK Normal Task Priority 0x09 (changed to this value via XCONF)
#define Netbios_Task_Priority 0x0B
#define USBResponse_Task_Priority 0x0B
#define Socket_Task_Priority 0x0B
#define TelnetResponse_Task_Priority 0x0B
#define HTTPResponse_Task_Priority 0x0B
#define RS485Response_Task_Priority 0x0B
// NDK High Task Priority 0x0D (changed to this value via XCONF)
// NDK Kernal Task Priority 0x0F (changed to this value via XCONF)
The following function is called after the TIVA has received an IP address:
//*****************************************************************************
//
// Routine to spawn the UDP Discovery Request Handler Task.
// This is called after an IP address has been received from the network
// DHCP server
//
//*****************************************************************************
void SpawnNetbiosTask(void)
{
Error_Block eb;
// Initialize error reporting object
Error_init(&eb);
// Initialize Netbios Task Parameters
// (Hint: arg0 will be the port that this task listens to)
Task_Params_init(&Netbios_Task_Params);
Netbios_Task_Params.stackSize = Netbios_Task_Stack_Size;
Netbios_Task_Params.priority = Netbios_Task_Priority;
Netbios_Task_Params.arg0 = UDPPORT;
// Launch the Netbios Task
Netbios_Task_Handle = Task_create((Task_FuncPtr)Netbios_Task_Handler, &Netbios_Task_Params, &eb);
if (Netbios_Task_Handle == NULL) {
System_printf("Task_create(Netbios Task Create) failed!\n");
System_flush();
BIOS_exit(0);
}
}// End: void SpawnNetbiosTask(void)
This is the task handler. I have confirmed that it runs to the fdSelect function, enters that function, but never returns:
//======================================================================================
//======================================================================================
//
// ========= NETBIOS TASK HANDLER ==========
//
//======================================================================================
//======================================================================================
void Netbios_Task_Handler(void)
{
int i_bytesRcvd, i_bytesSent, i_status, i_addrlen, i_error;
SOCKET s_UdpSocket;
fd_set s_readSet;
struct sockaddr_in s_localAddr, s_clientAddr;
char pc_rx_buffer[UDPPACKETSIZE], pc_tx_buffer[UDPPACKETSIZE];
char ps_netbios_name[NETBIOS_NAME_LEN+1];
NETBIOS_HDR* ps_netbios_hdr;
NETBIOS_NAME_HDR* ps_netbios_name_hdr;
NETBIOS_RESP* ps_resp;
System_printf("Beginning NetbiosTask\n");
System_flush();
// Create socket to listen for PC's discovery UDP broadcast packets
fdOpenSession(TaskSelf());
s_UdpSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (INVALID_SOCKET == s_UdpSocket)
{
i_error = fdError();
switch( i_error )
{..... error reporting code ....}
}
// Specify what addresses to listen for....
memset(&s_localAddr, 0, sizeof(s_localAddr));
s_localAddr.sin_family = AF_INET;
s_localAddr.sin_port = UDPPORT; <<<======= This is defined as 23 elsewhere
s_localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
i_status = bind(s_UdpSocket, (struct sockaddr *)&s_localAddr, sizeof(s_localAddr));
if (-1 == i_status)
{
i_error = fdError();
switch( i_error )
{..... error reporting code ....}
}
// Loop looking for discovery broadcast UDP packets from the PC application
do
{
// readSet and addrlen are value-result arguments, which must be reset
// in between each select() and recvfrom() call
FD_ZERO(&s_readSet);
FD_SET(s_UdpSocket, &s_readSet);
i_addrlen = sizeof(s_clientAddr);
// Wait forever for the reply -- fdSelect(nfds, readfds, writefds, exceptfds, timeout)
i_status = fdSelect(1, &s_readSet, NULL, NULL, NULL); <<<==== This function never returns even when broadcast UDP packets are sent
if (-1 == i_status) // Error
i_error = fdError();
switch( i_error )
{..... error reporting code ....}
Suggestions on how to proceed?
Tom Farmer