mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
Added optimized write(buffer,size) method in CDC class
This commit is contained in:
parent
9b027224a0
commit
9a505d25b2
@ -211,7 +211,7 @@ void Serial_::flush(void)
|
|||||||
USBD_Flush(CDC_TX);
|
USBD_Flush(CDC_TX);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Serial_::write(uint8_t c)
|
size_t Serial_::write(const uint8_t *buffer, size_t size)
|
||||||
{
|
{
|
||||||
/* only try to send bytes if the high-level CDC connection itself
|
/* only try to send bytes if the high-level CDC connection itself
|
||||||
is open (not just the pipe) - the OS should set lineState when the port
|
is open (not just the pipe) - the OS should set lineState when the port
|
||||||
@ -224,7 +224,7 @@ size_t Serial_::write(uint8_t c)
|
|||||||
// or locks up, or host virtual serial port hangs)
|
// or locks up, or host virtual serial port hangs)
|
||||||
if (_usbLineInfo.lineState > 0)
|
if (_usbLineInfo.lineState > 0)
|
||||||
{
|
{
|
||||||
int r = USBD_Send(CDC_TX,&c,1);
|
int r = USBD_Send(CDC_TX, buffer, size);
|
||||||
|
|
||||||
if (r > 0)
|
if (r > 0)
|
||||||
{
|
{
|
||||||
@ -239,6 +239,10 @@ size_t Serial_::write(uint8_t c)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Serial_::write(uint8_t c) {
|
||||||
|
return write(&c, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// This operator is a convenient way for a sketch to check whether the
|
// This operator is a convenient way for a sketch to check whether the
|
||||||
// port has actually been configured and opened by the host (as opposed
|
// port has actually been configured and opened by the host (as opposed
|
||||||
// to just being connected to the host). It can be used, for example, in
|
// to just being connected to the host). It can be used, for example, in
|
||||||
|
@ -57,7 +57,8 @@ public:
|
|||||||
virtual int read(void);
|
virtual int read(void);
|
||||||
virtual void flush(void);
|
virtual void flush(void);
|
||||||
virtual size_t write(uint8_t);
|
virtual size_t write(uint8_t);
|
||||||
using Print::write; // pull in write(str) and write(buf, size) from Print
|
virtual size_t write(const uint8_t *buffer, size_t size);
|
||||||
|
using Print::write; // pull in write(str) from Print
|
||||||
operator bool();
|
operator bool();
|
||||||
};
|
};
|
||||||
extern Serial_ Serial;
|
extern Serial_ Serial;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user