|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
|
Posted: Thu Jul 29, 2004 3:32 am |
|
|
Hi, puppie:
I can delay up to 2000 msec, no problem. When my_Stack_Task() got message from remote_TCP_server, it will call this _callback_function_
Code: | void process_message_from_TCP_server(void)
{
char c;
#if Debug_TCP
printf("\r\nTCP_server_action_%u = %u, mail_state = %u", tcp_act_count,TCP_server_action,mail_state);
printf("\r\nTCP_client_state= %u", TCP_client_state );
#endif
#if I_want_to_send_MAIL
if ( remote_TCP_server_port == SMTP_PORT ) do_SMTP_send_email();
else
#endif
{
if ( TCP_client_state == TCP_CONNECTING ) // got SYN ACK, start ...
// sending message to remote_TCP_SERVER
{
printf( nic_putc, "task started at%s", start_time ); // send to NIC, RTL8019AS
printf( nic_putc, "message sent at "); print_current_time_to_net();
delay_ms(2000); // <-- no problem, man
}
else
{
if ( TCP_client_state == TCP_CONNECTED ) printf("\r\nTCP_server: ");
while ( nic_getc(&c) ) putc(c); // printout message from remote_TCP_SERVER
// --- If you want to send out more than one TCP packet, put it here ----
//
#if I_want_TCP_continue
if ( TCP_client_state == TCP_CONNECTED && ++tcp_act_count < 4 )
{
printf( nic_putc, "Round_%u \r\n", tcp_act_count );
delay_ms(1500); // <-- no problem, man
}
else
#endif
TCP_client_action = TFIN + TACK; // finish communication
}
}
#if Debug_TCP
printf("\r\nTCP_client_action= %u\r\n", TCP_client_action );
#endif
}
|
In order to delay 2000 msec, I also extended the timeout limit written in my PC_TCP_SERVER (Visual BASIC) from 5 to 50 sec, and timeout limit in my PIC from 10 to 30 sec, otherwise, I can only delay 500 msec in the test code above. Well, I think 500 msec is enough for you. My system clock is running by Timer_ISR, any number between 0.1 ~ 100 msec will be fine for my system.
I am really curious if Microchip's TCP/IP stack can do it.
Many things might be related:
1. Is the following part of the StackTask() in Microchip's stack, and you can NOT put your ProcessIO() or even a delay_ms(10) over there ?
Code: |
switch(smState)
{
case SM_CONNECT_WAIT:
...
case SM_CONNECTED:
...
|
2. The system clock, Tick.c in Microchip's stack, might not be happy if it is not based on Timer_ISR, or, in case you are using delay_ms(200). I have no idea how Tick.c is coded, but, TCP_client_task need a system clock to count timeout and to perform TCP_re_transmit. Maybe you can try to update the system clock once every 1 msec in your ProcessIO().
3. The driver for RTL8019AS, MAC.c in Microchip's stack, might have ... well, I really don't know how they handle the overrun situation, it is the very bottom layer. I hope it is not the problem in your case.
The very bottom line, get another PIC to do those ProcessIO(), etc, and let the PICDEM.net be the Gateway to Internet.
My code started from http://www.iosoft.co.uk, it is written in CCS and Hi-Tech, it works on the PICDEM.net demo board.
Best wishes |
|
|
Guest
|
|
Posted: Thu Jul 29, 2004 3:48 am |
|
|
Hi, puppie:
Which version of CCS are you using?
make sure your delay_ms() did the correct delay and also the system clock.
delay_us() has bug in PCH 3.191 ~ 3.202 (or 203 ?)
Becareful ! |
|
|
puppie7777
Joined: 09 Jun 2004 Posts: 25 Location: Monterey, CA
|
|
Posted: Sun Aug 01, 2004 7:54 pm |
|
|
My ccs version is PCH 3.184.
The stacktask of microchip looks like:
Code: |
switch(smStack)
{
case SM_STACK_IDLE:
case SM_STACK_MAC:
... ...
break;
case SM_STACK_IP:
... ...
break;
case SM_STACK_TCP:
... ...
break;
}
|
This is the orginal code of Microchip tcp/ip stack.
My problem seems that when the data (received from server) arrived my pic Rx PIN, and it happens to be in the time of delay, the hardware will "discard" the data, or it will get the data missing partly (can not get the complete packet of ppp frame). |
|
|
puppie7777
Joined: 09 Jun 2004 Posts: 25 Location: Monterey, CA
|
|
Posted: Sun Aug 01, 2004 8:07 pm |
|
|
actually at the very beginning i also tried on the iosoft's code, but seems no luck, so later on i switched to microchip's one.
the Tick.c in microchip's stack did use Timer_ISR.
one more thing i need to consult:
in order to recognise a ppp frame, i have to check the incoming byte from Rx PIN, and i marked "0x7E" as end of packet, "0xFF" as start of packet. now seems to get problem on it, because later when it goes to TCP layer, i will get a lot of chance of get a "0xFF" as window in tcp header, it makes me confuse to recognise the "ppp packet" ... .... |
|
|
Guest
|
|
Posted: Mon Aug 02, 2004 3:37 am |
|
|
puppie7777 wrote: | My ccs version is PCH 3.184.
The stacktask of microchip looks like:
Code: |
switch(smStack)
{
case SM_STACK_IDLE:
case SM_STACK_MAC:
... ...
break;
case SM_STACK_IP:
... ...
break;
case SM_STACK_TCP:
... ...
break;
}
|
This is the orginal code of Microchip tcp/ip stack.
My problem seems that when the data (received from server) arrived my pic Rx PIN, and it happens to be in the time of delay, the hardware will "discard" the data, or it will get the data missing partly (can not get the complete packet of ppp frame). |
1. If you are using SLIP for your MAC layer and the MACISR (inside the timer ISR, HighISR(void) ) is fast enough (set by TICKS_PER_SECOND, default 10) , you should not miss any data, right ? What is your value for TICKS_PER_SECOND ? Try to print out some debug information to find out when Rx data is discarded.
2. The location where I put my time consuming ProcessIO() is somewhere inside the HandleTCPSeg(), right after ps->smState = TCP_EST; when SYN_ACK received. try adding some delay_ms(50) over there to see if that will cause problem.
3. Check TCPTick() in Tcp.c, that is where timeout event get handled. Since the default value of TCP_START_TIMEOUT_VAL is 60 seconds, it shall not be the problem.
That's all what I can think of.
Best wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|