Pages: [1]   Go Down
Author Topic: Bug  (Read 928 times)
0 Members and 1 Guest are viewing this topic.
Santa Cruz California
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
"When I hear of Schrödinger's cat, I reach for my gun " (Stephen Hawking)
View Profile
Bug
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
« Last Edit: April 08, 2012, 08:38:53 pm by TheNorm » Logged

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

I noticed this too using the Serial.readBytes() function (which is inherited from the Stream library).  I didn't want to use chars because I don't want 0xff == -1.  I overloaded the Stream::readBytes() function in Stream.cpp and Stream.h to have a char * as well as a byte * version, and now it compiles happily using a byte array.
Logged

Pages: [1]   Go Up
Jump to: