Go Down

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


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((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.


Code: [Select]
// Serial over CDC (Serial1 is the physical port)

class Serial_ : public Stream
ring_buffer *_cdc_rx_buffer;
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?
Please post technical questions on the forum, not by personal message. Thanks!

More info:


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

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131