Pico Serial Communication Class.
More...
#include <serial.hpp>
|
| | Serial () |
| | Constructor. More...
|
| |
| int | getChar (uint32_t us=0) |
| | Gets a single character. More...
|
| |
| size_t | getBuf (void *buf, size_t len, uint32_t us) |
| | Gets a buffer. More...
|
| |
| std::string | getStr (uint32_t us=0) |
| | Gets a string (blocks until enter/0x0A). More...
|
| |
| int | getInt (uint base=10, uint32_t us=0) |
| | Gets an integer value (blocks until enter/0x0A). More...
|
| |
| float | getFloat (uint32_t us=0) |
| | Gets a float point value (blocks until enter/0x0A). More...
|
| |
| void | putChar (char c, bool flush=false) |
| | Puts a single character. More...
|
| |
| void | putBuf (const void *src, size_t len, bool flush=false) |
| | Puts a buffer of data. More...
|
| |
| void | putStr (const std::string &src, bool flush=false) |
| | Puts a string. More...
|
| |
| void | putInt (int src, uint base=10, uint digits=0, char fill=' ', bool flush=false) |
| | Puts an integer value. More...
|
| |
| void | putFloat (float src, uint precision=3, bool flush=false) |
| | Puts a float point value. More...
|
| |
| std::ostream & | out () |
| | Returns the output stream object. More...
|
| |
| std::istream & | in () |
| | Returns the input stream object. More...
|
| |
Pico Serial Communication Class.
The purpose of this class is to handle the serial communication (via UART or via USB-CDC).
◆ Serial()
◆ getChar()
| int getChar |
( |
uint32_t |
us = 0 | ) |
|
Gets a single character.
- Parameters
-
| us | Timeout, in microseconds. Default is zero (returns immediately). |
- Returns
- A single char, or PICO_ERROR_TIMEOUT if timeout is reached.
◆ getBuf()
| size_t getBuf |
( |
void * |
buf, |
|
|
size_t |
len, |
|
|
uint32_t |
us |
|
) |
| |
Gets a buffer.
- Parameters
-
| buf | Pointer to buffer that receives the data. |
| len | Size of buffer, in bytes. |
| us | Timeout, in microseconds. Default is zero (returns immediately). |
- Returns
- Number of bytes read, or zero if timeout is reached.
◆ getStr()
| std::string getStr |
( |
uint32_t |
us = 0 | ) |
|
Gets a string (blocks until enter/0x0A).
- Parameters
-
| us | Timeout, in microseconds. Default is zero (wait for a 0x0A). |
- Returns
- The string.
◆ getInt()
| int getInt |
( |
uint |
base = 10, |
|
|
uint32_t |
us = 0 |
|
) |
| |
Gets an integer value (blocks until enter/0x0A).
- Parameters
-
| base | Numerical base. Default is 10 (decimal). |
| us | Timeout, in microseconds. Default is zero (wait for a 0x0A). |
- Returns
- The numeric value.
◆ getFloat()
| float getFloat |
( |
uint32_t |
us = 0 | ) |
|
Gets a float point value (blocks until enter/0x0A).
- Parameters
-
| us | Timeout, in microseconds. Default is zero (wait for a 0x0A). |
- Returns
- The numeric value.
◆ putChar()
| void putChar |
( |
char |
c, |
|
|
bool |
flush = false |
|
) |
| |
Puts a single character.
- Parameters
-
| c | Character to write. |
| flush | If true, flushes the output. Default is false. |
◆ putBuf()
| void putBuf |
( |
const void * |
src, |
|
|
size_t |
len, |
|
|
bool |
flush = false |
|
) |
| |
Puts a buffer of data.
- Parameters
-
| src | Pointer to buffer to write. |
| len | Size of buffer, in bytes. |
| flush | If true, flushes the output. Default is false. |
◆ putStr()
| void putStr |
( |
const std::string & |
src, |
|
|
bool |
flush = false |
|
) |
| |
Puts a string.
- Parameters
-
| src | String to write. |
| flush | If true, flushes the output. Default is false. |
◆ putInt()
| void putInt |
( |
int |
src, |
|
|
uint |
base = 10, |
|
|
uint |
digits = 0, |
|
|
char |
fill = ' ', |
|
|
bool |
flush = false |
|
) |
| |
Puts an integer value.
- Parameters
-
| src | Numeric value to write. |
| base | Numerical base. Default is 10 (decimal). |
| digits | Number of min digits to format (left pad with fill). Default is zero. |
| fill | Fill character. Default is space. |
| flush | If true, flushes the output. Default is false. |
◆ putFloat()
| void putFloat |
( |
float |
src, |
|
|
uint |
precision = 3, |
|
|
bool |
flush = false |
|
) |
| |
Puts a float point value.
- Parameters
-
| src | Numeric value to write. |
| precision | Number of decimals (precision). Default is 3. |
| flush | If true, flushes the output. Default is false. |
◆ out()
Returns the output stream object.
- Returns
- Reference to the output stream object.
◆ in()
Returns the input stream object.
- Returns
- Reference to the input stream object.
The documentation for this class was generated from the following files: