SerialPort Class Reference

Arduino Serial Interface. More...

Detailed Description

Arduino Serial Interface.

Definition at line 45 of file serialport.hpp.

#include <serialport.hpp>

Public Member Functions

 SerialPort (uart_t dev)
 Constructor maps the serial port to a RIOT UART device. More...
 
int available (void)
 Get the number of bytes (characters) available for reading from the serial port. More...
 
void begin (long speed)
 Sets the data rate in bits per second (baud) for serial data transmission. More...
 
void end (void)
 Disables serial communication, allowing the RX and TX pins to be used for general input and output. More...
 
size_t print (int val)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (int val, SerialFormat format)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (unsigned int val)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (unsigned int val, SerialFormat format)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (long val)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (long val, SerialFormat format)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (unsigned long val)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (unsigned long val, SerialFormat format)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (float val)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (float val, int format)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (char val)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t print (const char *val)
 Prints data to the serial port as human-readable ASCII text. More...
 
size_t println (int val)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (int val, SerialFormat format)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (unsigned int val)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (unsigned int val, SerialFormat format)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (long val)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (long val, SerialFormat format)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (unsigned long val)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (unsigned long val, SerialFormat format)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (float val)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (float val, int format)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (char val)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (const char *val)
 Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
size_t println (void)
 Prints a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n") More...
 
int read (void)
 Reads incoming serial data. More...
 
int write (int val)
 Writes binary data to the serial port. More...
 
int write (const char *str)
 Writes binary data to the serial port. More...
 
int write (char *buf, int len)
 Writes binary data to the serial port. More...
 

Constructor & Destructor Documentation

◆ SerialPort()

SerialPort::SerialPort ( uart_t  dev)
explicit

Constructor maps the serial port to a RIOT UART device.

Parameters
[in]devRIOT UART device

Member Function Documentation

◆ available()

int SerialPort::available ( void  )

Get the number of bytes (characters) available for reading from the serial port.

This is data that's already arrived and stored in the serial receive buffer (which holds 64 bytes). available() inherits from the Stream utility class.

Copied from https://www.arduino.cc/en/Serial/Available

Returns
The number of bytes available to read

◆ begin()

void SerialPort::begin ( long  speed)

Sets the data rate in bits per second (baud) for serial data transmission.

For communicating with the computer, use one of these rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200. You can, however, specify other rates - for example, to communicate over pins 0 and 1 with a component that requires a particular baud rate.

Copied from https://www.arduino.cc/en/Serial/Begin

Parameters
[in]speedspeed in bits per second (baud)

◆ end()

void SerialPort::end ( void  )

Disables serial communication, allowing the RX and TX pins to be used for general input and output.

To re-enable serial communication, call begin()

Copied from https://www.arduino.cc/en/Serial/End

◆ print() [1/12]

size_t SerialPort::print ( char  val)

Prints data to the serial port as human-readable ASCII text.

See also
print()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ print() [2/12]

size_t SerialPort::print ( const char *  val)

Prints data to the serial port as human-readable ASCII text.

See also
print()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ print() [3/12]

size_t SerialPort::print ( float  val)

Prints data to the serial port as human-readable ASCII text.

Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ print() [4/12]

size_t SerialPort::print ( float  val,
int  format 
)

Prints data to the serial port as human-readable ASCII text.

See also
print()
Parameters
[in]valthe value to print
[in]formatnumber of decimal places
Returns
the number of bytes written, reading that number is optional

◆ print() [5/12]

size_t SerialPort::print ( int  val)

Prints data to the serial port as human-readable ASCII text.

Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is.

Copied from https://www.arduino.cc/en/Serial/Print

Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ print() [6/12]

size_t SerialPort::print ( int  val,
SerialFormat  format 
)

Prints data to the serial port as human-readable ASCII text.

See also
print()
Parameters
[in]valthe value to print
[in]formatspecifies the number base
Returns
the number of bytes written, reading that number is optional

◆ print() [7/12]

size_t SerialPort::print ( long  val)

Prints data to the serial port as human-readable ASCII text.

Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is.

Copied from https://www.arduino.cc/en/Serial/Print

Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ print() [8/12]

size_t SerialPort::print ( long  val,
SerialFormat  format 
)

Prints data to the serial port as human-readable ASCII text.

See also
print()
Parameters
[in]valthe value to print
[in]formatspecifies the number base
Returns
the number of bytes written, reading that number is optional

◆ print() [9/12]

size_t SerialPort::print ( unsigned int  val)

Prints data to the serial port as human-readable ASCII text.

Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is.

Copied from https://www.arduino.cc/en/Serial/Print

Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ print() [10/12]

size_t SerialPort::print ( unsigned int  val,
SerialFormat  format 
)

Prints data to the serial port as human-readable ASCII text.

See also
print()
Parameters
[in]valthe value to print
[in]formatspecifies the number base
Returns
the number of bytes written, reading that number is optional

◆ print() [11/12]

size_t SerialPort::print ( unsigned long  val)

Prints data to the serial port as human-readable ASCII text.

Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is.

Copied from https://www.arduino.cc/en/Serial/Print

Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ print() [12/12]

size_t SerialPort::print ( unsigned long  val,
SerialFormat  format 
)

Prints data to the serial port as human-readable ASCII text.

See also
print()
Parameters
[in]valthe value to print
[in]formatspecifies the number base
Returns
the number of bytes written, reading that number is optional

◆ println() [1/13]

size_t SerialPort::println ( char  val)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

See also
println()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ println() [2/13]

size_t SerialPort::println ( const char *  val)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

See also
println()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ println() [3/13]

size_t SerialPort::println ( float  val)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

See also
println()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ println() [4/13]

size_t SerialPort::println ( float  val,
int  format 
)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

See also
println()
Parameters
[in]valthe value to print
[in]formatnumber of decimal places
Returns
the number of bytes written, reading that number is optional

◆ println() [5/13]

size_t SerialPort::println ( int  val)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

This command takes the same forms as print().

Copied from https://www.arduino.cc/en/Serial/Println

Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ println() [6/13]

size_t SerialPort::println ( int  val,
SerialFormat  format 
)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

See also
println()
Parameters
[in]valthe value to print
[in]formatspecifies the number base
Returns
the number of bytes written, reading that number is optional

◆ println() [7/13]

size_t SerialPort::println ( long  val)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

This command takes the same forms as print().

Copied from https://www.arduino.cc/en/Serial/Println

Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ println() [8/13]

size_t SerialPort::println ( long  val,
SerialFormat  format 
)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

See also
println()
Parameters
[in]valthe value to print
[in]formatspecifies the number base
Returns
the number of bytes written, reading that number is optional

◆ println() [9/13]

size_t SerialPort::println ( unsigned int  val)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

This command takes the same forms as print().

Copied from https://www.arduino.cc/en/Serial/Println

Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ println() [10/13]

size_t SerialPort::println ( unsigned int  val,
SerialFormat  format 
)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

See also
println()
Parameters
[in]valthe value to print
[in]formatspecifies the number base
Returns
the number of bytes written, reading that number is optional

◆ println() [11/13]

size_t SerialPort::println ( unsigned long  val)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

This command takes the same forms as print().

Copied from https://www.arduino.cc/en/Serial/Println

Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional

◆ println() [12/13]

size_t SerialPort::println ( unsigned long  val,
SerialFormat  format 
)

Prints data to the serial port as human-readable ASCII text followed by a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

See also
println()
Parameters
[in]valthe value to print
[in]formatspecifies the number base
Returns
the number of bytes written, reading that number is optional

◆ println() [13/13]

size_t SerialPort::println ( void  )

Prints a carriage return character (ASCII 13, or "\r") and a newline character (ASCII 10, or "\n")

See also
println()
Returns
the number of bytes written, reading that number is optional

◆ read()

int SerialPort::read ( void  )

Reads incoming serial data.

Copied from https://www.arduino.cc/en/Serial/Read

Returns
the first byte of incoming serial data available
-1 if no data is available

◆ write() [1/3]

int SerialPort::write ( char *  buf,
int  len 
)

Writes binary data to the serial port.

[long description]

Parameters
[in]bufan array to send as a series of bytes
[in]lenthe length of the buffer
Returns
the number of bytes written, reading that number is optional

◆ write() [2/3]

int SerialPort::write ( const char *  str)

Writes binary data to the serial port.

See also
write()
Parameters
[in]stra string to send as a series of bytes
Returns
the number of bytes written, reading that number is optional

◆ write() [3/3]

int SerialPort::write ( int  val)

Writes binary data to the serial port.

This data is sent as a byte or series of bytes; to send the characters representing the digits of a number use the print() function instead.

Copied from https://www.arduino.cc/en/Serial/Write

Parameters
[in]vala value to send as a single byte
Returns
the number of bytes written, reading that number is optional

The documentation for this class was generated from the following file: