Go Down

Topic: How fast ist client.wirte() on MEGA (Read 1 time) previous topic - next topic

SurferTim

What are your issues with those two items?

I didn't check all the code, but this will cause problems:
Code: [Select]
char tBuf[41];

       // if the current tCount == 40
       if(tCount < 41) {
         // set the last member of the array to c
         tBuf[tCount] = c;
         // this increments tCount to 41
         tCount++;
         // this overflows the array
         tBuf[tCount] = 0;


markuszelg


You just insist on ignoring the advice to get rid of Strings. Why?

Your answer belongs to your answer #2? So, I understood doing the array for the incoming data on Serial3 - what I didnt had implemented yesterday. What is not common with the XML-Header data? One may put the string into flash memory with F().

markuszelg


What are your issues with those two items?

I dont get your question. This part works pretty stable. The function gets only the first 41 chars from the http header. But this section absolutly not belongs to my streaming-issue nor to the reboot phenomenon.

SurferTim


This part works pretty stable. The function gets only the first 41 chars from the http header. But this section absolutly not belongs to my streaming-issue nor to the reboot phenomenon.

The function gets the first 41 characters, but overflows the array with the zero terminator (42nd character). You are probably putting that zero terminator in this variable.
Code: [Select]
char *pch;

What do you expect pch to do?

markuszelg

#34
Feb 12, 2013, 02:27 pm Last Edit: Feb 12, 2013, 02:47 pm by markuszelg Reason: 1
@SurferTim: Maybe I'm totaly wrong here. My loop will write at the end of the while tBuff[41]=0, what I understoot is the terminator like '\0' in char. Not?

The char *pch? For strstr C-function. Works stable, no? Is my point to the first occurence of "dev=" in client HTTP GET request. Works stable as stones.

SurferTim

tBuf has 41 elements in the array, which are tBuf[0] to tBuf[40].

tBuf[41] is outside that array. It has a habit of putting that overflow into the next variable you declared, which in your case would be a pointer. If you put 0 in that pointer, that will now point to memory location zero. Assigning anything to that memory location will cause problems. In the "good old days" of the IBM PC, that would throw the "divide by zero" error. In your case, it might restart the program.

markuszelg

#36
Feb 12, 2013, 03:19 pm Last Edit: Feb 12, 2013, 03:24 pm by markuszelg Reason: 1

tBuf has 41 elements in the array, which are tBuf[0] to tBuf[40].

Very unprofessional on my site. I forgot having char array which are different declared than the int array :-)
I was thinking of having a new feature: restart. This would be an other topic: How do a program a restart? Jumping to 0? Hmm... maybe not the stable way.

Back to the streaming-issue. Any ideas?

PeterH


Back to the streaming-issue. Any ideas?


You seem to have found and fixed numerous bugs which might be related. Can you recap what the symptoms of the remaining problem are, and post the latest version of the code with all the other bugs corrected?
I only provide help via the forum - please do not contact me for private consultancy.

markuszelg

Right, I should fix the code first. Next step is update of buffering serial3 input stream for sending array string to client. I will update soon.

Nick Gammon

To back up PaulS:

Please note that, at present, the String library has bugs as discussed here and here.

In particular, the dynamic memory allocation used by the String class may fail and cause random crashes.

I recommend reworking your code to manage without String. Use C-style strings instead (strcpy, strcat, strcmp, etc.).

Alternatively, install the fix described here:
  http://arduino.cc/forum/index.php/topic,145765
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up