| View previous topic :: View next topic |
| Author |
Message |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Sat Feb 12, 2011 4:40 am |
|
|
Back to the original problem...
I found that when the transfer hangs through the internet, the "TCPIsConnected(socket)" returns true, so I am still connected to the remote PC but "TCPIsPutReady(socket)" returns false after some time, so, my data is not sent out.
Now, when the remote PC sends me a byte of data, the PIC will continue to send out my data and "TCPIsPutReady(socket)" returns true.
Let's say that the PIC is not TCPIsPutReady. What can I do to make it ready again? Should I just wait? |
|
 |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sat Feb 12, 2011 10:26 pm |
|
|
Well, I've not had any trouble on any ports. Maybe you have an antivirus or firewall blocking things? _________________ Andrew |
|
 |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sat Feb 12, 2011 10:32 pm |
|
|
Re: TCPIsPutReady(), you are calling TCPFlush() when you want the data to go? _________________ Andrew |
|
 |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Sun Feb 13, 2011 2:52 am |
|
|
This is what I call for sending out the data:
| Code: |
int trans(){
if(TCPIsPutReady(c_socket)) {
TCPPut(c_socket,buffer[0]);
TCPPut(c_socket,buffer[1]);
TCPPut(c_socket,buffer[2]);
TCPPut(c_socket,buffer[3]);
TCPPut(c_socket,buffer[4]);
TCPFlush(c_socket);
led_err=0;
buzzer=0;
return 1;
}
else{
printf("\n\rNot PUT ready.");
led_err=1;
buzzer=1;
return 0;
}
}
|
I use the above to send 5 bytes to the PC but after a while it hangs when used through the internet.
Yesterday I found that if my PC side VB app. sends one dummy byte to the PIC every 300mS, the transfer does not hang. Maybe it needs both ends to talk to each other. Also I saw in wireshark that I have some duplicate acks when it hangs.
It should not be a firewall problem because if it was then it would not wotk at all. right?
Keep in mind that everything works perfectly in my LAN for many hours.
Finally what is the best way to send/receive data reliably though the internet?
UDP did not work at all even though I see (in wireshark) that the PIC sends the data, but I cannot receive it in any way. |
|
 |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sun Feb 13, 2011 11:19 am |
|
|
That looks fine to me, but I can't explain what happens when it gets stuck over the Internet.
For really long duration comms, I'd still recommend UDP. _________________ Andrew |
|
 |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Sun Feb 13, 2011 1:03 pm |
|
|
Andrew,
UDP finally works! the problem was that avast internet security was blocking all UDP packets even though it was disabled. Now it is uninstalled and everything is OK ;)
So, I am back at the CCS UDP example.
I have it working!
Just a question, should I always open a socket, send out my packet and then close it every time or I just open it once and send out all data for one session? The same question for receiving.
Thanks |
|
 |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sun Feb 13, 2011 10:19 pm |
|
|
Good to hear you sorted your UDP problem.
Re: Opening/closing: It depends
For receiving I keep a socket open all the time and typically send replies back on the same.
For unsolicited sending I open and close a new socket, like in the ntp_sendreq and test_send_udp functions in the earlier posts. _________________ Andrew |
|
 |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Thu Feb 17, 2011 4:53 pm |
|
|
Andrew,
UDP is working perfectly without problems.
Thank you so much for the help!
George.. |
|
 |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Thu Feb 17, 2011 8:57 pm |
|
|
That's great! Have you been able to restore Avast and keep the UDP packets? _________________ Andrew |
|
 |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Fri Feb 18, 2011 12:28 am |
|
|
No, Avast is gone! It was too heavy anyway...
Do you know how many bytes I can send with one flush? What is the size of the transmit buffer? |
|
 |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Fri Feb 18, 2011 1:28 am |
|
|
| georpo wrote: | | No, Avast is gone! It was too heavy anyway... |
Well I hope you've got some sort of firewall in place...
| Quote: | | Do you know how many bytes I can send with one flush? What is the size of the transmit buffer? |
It will be #defined in the code somewhere, but I'd say at least 1KB, possibly 1.5KB. It might even be variable! Use UDPIsPutReady() to check. _________________ Andrew |
|
 |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Fri Feb 18, 2011 2:41 pm |
|
|
Ok, thanks!!!
if you want check this:
http://georpo.dyndns.org
It is my custom PIC board that I use for TCP/UDP practice
George. |
|
 |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sat Feb 19, 2011 1:25 am |
|
|
That's a nice looking case. I bet the LCD display is handy for debugging! Here's my NTP server:
http://www.scss.com.au/family/andrew/gps/ntp/
It can be a bit challenging debugging with just a couple of LEDs, but I got there  _________________ Andrew |
|
 |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Sat Feb 19, 2011 5:39 am |
|
|
haha, my project is like a toy compared to yours.
Very nice job Andrew!
After I finish the tests I will make a pcb with green solder mask. It looks much better. Mine is a sample, it is not even plated through...
I will also change the power supply and use a 34063 because the 7805 gets hot and needs a cooler which makes the device look bad.
I made the front and back panels of FR4 1mm. It is much easier to make holes than in aluminium... |
|
 |
|