[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] help. pcb->next = pcb!
From: |
Eric Shufro |
Subject: |
[lwip-users] help. pcb->next = pcb! |
Date: |
Mon, 11 Oct 2004 00:32:37 -0400 |
For some reason, the pcb I use to transmit data gets its next pointer set to
itself! As a result, loops that rely on pcb=somepcb; pcb!=NULL;
pcb=pcb->next become infinite loops!
I tried to trace this down without much luck. What could the problem be?
Thanks.
Here is some trace output as well...
tcp_connect to port 3000
tcp_enqueue(pcb=24F0, arg=0, len=0, flags=2, copy=0)
tcp_enqueue: queueing 6553:6554 (0x2)
tcp_output_segment: 6553:6553
tcp_write(pcb=24F0, arg=3030, len=25, copy=1)
tcp_enqueue(pcb=24F0, arg=3030, len=25, flags=0, copy=1)
tcp_enqueue: queueing 6554:6579 (0x0)
tcp_output_segment: 6554:6579
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_output: nothing to send (0)
tcp_receive: window update 65510
tcp_close: closing in state State: ESTABLISHED
tcp_enqueue(pcb=24F0, arg=0, len=0, flags=1, copy=1)
tcp_enqueue: queueing 6579:6580 (0x1)
tcp_output_segment: 6579:6579
tcp_output: nothing to send (0)
tcp_receive: window update 65510
tcp_close: closing in state State: FIN_WAIT_2
tcp_output: nothing to send (0)
TCP connection closed 3000 -> 4097.
tcp_pcb_purge
tcp_close: closing in state State: TIMtcp_slowtmr: no active pcbs
At this point it becomes stuck in tcp_slowtmr, under the infinite loop
conditions mentioned above.
The way i setup to send the data is like this starting from the ISR which
signals the send task to do its work... sorry about the formatting. <shrug>
Thanks for the help,
-eric
****************************************************************************
*****************************
* TASK: Send received RS232 data via TCP to the host
****************************************************************************
*****************************
*/
void tcpSendData(struct netif *netif)
{
volatile err_t err;
INT8U i;
rs232ReadySem = sys_sem_new(0);
SCI0CR2 = 0x2C; /* enable SCI0
receive interrupts */
if(*eeIdentFlag > 0)
/* if identification is enabled, */
{
for(i=0; i<5;i++)
/* copy the mac address into the */
rs232Data[i] = eeMACAddr[i];
/* data buffer to be transmitted */
rs232DataIndex = 6; /* initialize the
data index to point to the next available location */
}
else
rs232DataIndex = 0; /* initialize the
data index to point to the next available location */
while(TRUE)
{
OSSemPend(rs232ReadySem, 0, &err);
//sys_sem_wait(rs232ReadySem);
/* if awakened figure out transmit options and do a */
/* tcpwrite rs232 data to the correct destination */
IP4_ADDR(&tempIP, *eeDestIP1, *(eeDestIP1+1), *(eeDestIP1+2),
*(eeDestIP1+3));
err = tcp_connect(packTxPCB, &tempIP, *((INT16U *)eeDestPort),
tcpOutConnEstab);
}
}
/*
****************************************************************************
*****************************
* Outgoing TCP connection estabolished
****************************************************************************
*****************************
*/
err_t tcpOutConnEstab(void *arg, struct tcp_pcb *packTxPCB, err_t err)
{
err_t result;
result = tcp_write(packTxPCB, &rs232Data[0], 25, 1);
tcp_sent(packTxPCB, packDataSentOK); /* register call
back for host recieved the data ok */
if(*eeIdentFlag > 0)
rs232DataIndex = 6;
/* if ident is on, preserve the first 5 bytes of the */
else
/* data array, the MAC Address is stored there */
rs232DataIndex = 0; /* reset the pointer
into the array */
SCI0CR2 = 0x2C; /* re-enable SCI0
Receiver Interrupts */
return result;
}
/*
****************************************************************************
*****************************
* data was transmitted and received by the remote host
****************************************************************************
*****************************
*/
err_t packDataSentOK (void *arg, struct tcp_pcb *packTxPCB, u16_t len)
{
tcp_close(packTxPCB);
return ERR_OK;
}
/*
****************************************************************************
*****************************
* SCI0 - Serial Port Receive
Interrupt
****************************************************************************
*****************************
*/
#pragma CODE_SEG __NEAR_SEG INTERRUPT_ROUTINES
#pragma TRAP_PROC
interrupt void SCI0RxTxISR(void)
{
if( ((SCI0SR1 & 0x20) == 0x20) && rs232DataIndex < rs232InBufSize) /*
if the interrupt indicates a received byte */
{ /*
and the data array is not full */
rs232Data[rs232DataIndex++] = SCI0DRL; /*
add the new data byte to the array */
/* and increment the point to the next location */
if(rs232DataIndex == 25) /*
did we receive the last byte from the host? */
{
SCI0CR2 = 0x0C; /*
disable rs232 receive interrupts (SR re-enables it */
OSIntNesting++; /*
notify the OS about the interrupt */
if (OSIntNesting == 1)
{
__asm{
ldy OSTCBCur /*
OSTCBCur->OSTCBStkPtr = Stack Pointer */
sts 0,y
}
}
OSSemPost(rs232ReadySem);
//sys_sem_signal(rs232ReadySem);
/* signal the TCP tx task that there is work to do. */
OSIntExit();
}
}
}
#pragma CODE_SEG DEFAULT
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-users] help. pcb->next = pcb!,
Eric Shufro <=