Pages: [1]   Go Down
Author Topic: Serial.write() on Leonard is diffrent from Uno and others  (Read 2183 times)
0 Members and 1 Guest are viewing this topic.
Japan
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I found that following two statements can be compiled for Uno and Duemilanove (probably for all mega168 and 328s) but not for Leonard with Arduino-IDE 1.0.1.

Serial.write("test");
Serial.write((const uint8_t*)"test\n", 5);

Is this a bug or the feature?

// Noriaki Mitsunaga

Logged

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

Edit USBAPI.h.

Find the class: Serial_

Add this line:

Code:
  using Print::write; // pull in write(str) and write(buf, size) from Print

Now it compiles without errors.

eg.

Code:
//================================================================================
//================================================================================
// Serial over CDC (Serial1 is the physical port)

class Serial_ : public Stream
{
private:
ring_buffer *_cdc_rx_buffer;
public:
void begin(uint16_t baud_count);
void end(void);

virtual int available(void);
virtual void accept(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
virtual size_t write(uint8_t);
        using Print::write; // pull in write(str) and write(buf, size) from Print    <-------- add this
operator bool();
};
extern Serial_ Serial;

Sounds like a bug, who knows?
Logged


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

After adding  "using Print::write;" to USBAPI.h works fine.

Thank you.

> Sounds like a bug, who knows?

Maybe fixed in future release ?

// Noriaki Mitsunaga
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Issue opened here: http://code.google.com/p/arduino/issues/detail?id=958
Logged

Pages: [1]   Go Up
Jump to: