Pages: 1 2 [3]   Go Down
Author Topic: How fast ist client.wirte() on MEGA  (Read 1754 times)
0 Members and 1 Guest are viewing this topic.
Miramar Beach, Florida
Online Online
Faraday Member
**
Karma: 147
Posts: 6039
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What are your issues with those two items?

I didn't check all the code, but this will cause problems:
Code:
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;
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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().
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Miramar Beach, Florida
Online Online
Faraday Member
**
Karma: 147
Posts: 6039
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
char *pch;
What do you expect pch to do?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@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.
« Last Edit: February 12, 2013, 08:47:22 am by markuszelg » Logged

Miramar Beach, Florida
Online Online
Faraday Member
**
Karma: 147
Posts: 6039
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: February 12, 2013, 09:24:22 am by markuszelg » Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18810
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Pages: 1 2 [3]   Go Up
Jump to: