Go Down

Topic: Serial.write() on Leonard is diffrent from Uno and others (Read 2 times) previous topic - next topic

mnoriaki

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


Nick Gammon

Edit USBAPI.h.

Find the class: Serial_

Add this line:

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

Now it compiles without errors.

eg.

Code: [Select]
//================================================================================
//================================================================================
// 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?
http://www.gammon.com.au/electronics

mnoriaki

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

mellis


Go Up