Pages: 1 [2]   Go Down
Author Topic: Arduino HTTP server sending malformed packets  (Read 1391 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Offline Offline
Brattain Member
*****
Karma: 480
Posts: 18720
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here:

Code:
/* Print a string from Program Memory directly to save RAM */
void printProgStr (__FlashStringHelper * str)
{
  char * p = (char *) str;
  if (!p) return;  // no string, uh oh!

  char buf [strlen_P (p) + 1];  // dynamic allocation ;)
  byte i = 0;
  char c;
  while ((c = pgm_read_byte(p++)))
    buf [i++] = c;
  buf [i] = 0;
 
  Serial.println (buf);
} // end of printProgStr

void setup ()
{
  Serial.begin (115200);
  printProgStr (F("but does it get goat's blood out?"));
  Serial.println ();
}  // end of setup

void loop () {}

That buffers up the string so you can then do a single write on it (instead of the Serial.println that I have).
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, with a little bit of tweaking, that did it! I didn't realize there was a "pgm_read_byte()" function, that really helped.
Logged

Pages: 1 [2]   Go Up
Jump to: