Loading...
  Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Bug in Time.h on: October 01, 2012, 07:15:52 pm
Doesn't dynamically allocated memory get freed when it goes out of scope? I think that how strings work, otherwise you'd need some kind of String.delete() function and Strings would really suck. I know you feel they suck anyway. Just sayin.

Time.h doesn't seem to be Arduino software. It's in the playground so perhaps I should be talking to the author.
2  Using Arduino / Programming Questions / Bug in Time.h on: September 30, 2012, 07:22:28 pm
It looks like the string functions in Time.h share a single output buffer so you may or may not get what you expect depending on timing.

Don't bitch about using sprintf(). You can reproduce the bug with Serial.print()

sprintf(adr,"%s, %s %u, %u", dayStr(weekday()), monthStr(month()), day(), year());

In this case the day of the week gets overwritten by the name of the month and prints "September September 30, 2012" If you reverse the calls the month will be overwritten by the day.
3  Using Arduino / Project Guidance / Re: Serve graphics with Eithernet Uno? on: April 26, 2012, 02:43:05 pm
The problem was that I was not sending the file length.

Thanks everyone.
4  Using Arduino / Project Guidance / Re: Serve graphics with Eithernet Uno? on: April 25, 2012, 05:55:06 pm
Thanks Nick.

Sigh. I think I'll just eliminate graphics from my server. It's not critical and the thing is already too fat. More code is not the way to go and I don't care for the idea of pre-converting the files.
5  Using Arduino / Project Guidance / Re: Serve graphics with Eithernet Uno? on: April 22, 2012, 08:43:04 pm
You might be sending too fast and overflowing the buffer. Try putting in a delay inside the client write loop.

Tried that.
Thanks
6  Using Arduino / Project Guidance / Re: Serve graphics with Eithernet Uno? on: April 22, 2012, 08:42:16 pm
Hmmm- are you base64 encoding the graphics file?

It's just a jpg file created in Photoshop that I copied to the SD card. I didn't do anything to it. I don't understand the question. It sounds like I may be missing a whole topic here. What's base64 encoding? Why would anyone do anything in base 64? Is there something I should have read?

7  Using Arduino / Project Guidance / Re: Serve graphics with Eithernet Uno? on: April 22, 2012, 08:23:11 pm
1. What does the debugging show?

2. Can you use code tags to post code? You can do that by hitting the # button above the posting area.

3. After this line:

Code:
 File source = openFile(fileName);

You don't check if the file opened OK. If not (and source is not open) then the program will likely hang.

"openFile(fileName)" has error checking built in. Currently it prints an error msg and loops forever.

Code:
Ok. I'll do this in the future.

As far as I can tell this code is ok and it sends html just fine.

The debug output just says "sending header  htm.hdr" and  "sending file index.htm"  and then when the client asks for the graphics... ""sending header  jpg.hdr" and  "sending file test.jpg"  but the graphics never arrive.
8  Using Arduino / Project Guidance / Re: Serve graphics with Eithernet Uno? on: April 22, 2012, 07:34:49 pm
Is this thread dead for some reason?
9  Using Arduino / Project Guidance / Re: Serve graphics with Eithernet Uno? on: April 11, 2012, 07:48:15 pm
Ok, I snipped out the relevant stuff.

The jpg is 35.5 KB.

Here's the calling code...
 if (strcmp(ext,"jpg")==0){
    sendHeader("jpg.hdr", client;
    sendFile(parameter, client);
    return;
  }


Here's the text from the file jpg.hdr
HTTP/1.1 200 OK
Content-Type: image/jpeg


Code to send header...
void sendHeader(char *fileName, EthernetClient *client){  // no CGI parsing
  DEBUG_PRINTLN("sending header " << fileName << "\n\n" );
  sendFile(fileName,client);
  client->print ("\n\n");  // terminator for http headers
}


Code to actually send...
void sendFile(char *fileName, EthernetClient *client){
  DEBUG_PRINTLN("sending file " << fileName << "\n" );
  File source = openFile(fileName);
  while (source.available()) {
    byte byt = source.read();
    client->write(byt);
  }
  source.close();
}



10  Using Arduino / Project Guidance / Re: Serve graphics with Eithernet Uno? on: April 11, 2012, 03:10:53 pm
I'm using the SD card. No shortage of room.

I send an html header & file and it works fine. Send a jpg header and file and it doesn't work.
11  Using Arduino / Project Guidance / Serve graphics with Eithernet Uno? on: April 11, 2012, 01:41:35 am
Should I be able to serve .jpg files? I can send text no sweat but jpg files just grind and grind and eventually time-out.
12  Development / Suggestions for the Arduino Project / Bug on: April 08, 2012, 08:32:57 pm
I'm not sure where this should go but I'm sure it's a bug.

In http://arduino.cc/en/Reference/StreamReadBytes readBytes is documented as taking either char[] or byte[] but when used with an SD File object you have to cast it to char[]. Hell it's called readBytes not readChars. Perversely enough an eithernet client wants bytes.

      This works but vice-versa fails
 
      byte bfr[outBfrSz];
      source.readBytes((char)bfr,outBfrSz);
      client->write(bfr,outBfrSz);
13  Using Arduino / Programming Questions / Re: How can I see expanded macros? on: April 06, 2012, 06:03:43 pm
Thanks for all the responses.
14  Using Arduino / Programming Questions / Re: macro for "assert"? on: April 02, 2012, 07:52:54 pm
Uh, thanks Nick. That's the most confusing .h file I've ever tried to figure out.
On my machine the failed case produces some kind of garbage on the serial port and then locks up (as it should).
Are you supposed to be able to include a message in the assert?

Here's what I'm doing...

Quote

#include <assert.h>

void setup ()
{
  Serial.begin (9600);
  Serial.println("testing");
  assert (1 == 1);
  Serial.println ("assertion passed.");
  assert (1 == 2);
//  Serial.println (" false assertion passed.");
}
void loop () {}


The fail case drives the serial monitor crazy and chops off everything after the first two letters on the screen, "te." If I comment out the second assert everything works as expected.
15  Using Arduino / Programming Questions / macro for "assert"? on: April 02, 2012, 05:19:59 pm
Does anyone have a macro to implement assertions?
Pages: [1] 2 3