The friendly Operating System for the Internet of Things
SerialPort Class Reference

Arduino Serial Interface. More...

Detailed Description

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 (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 (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...
 
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 ( uart_t  dev)
explicit
Parameters
[in]devRIOT UART device

Member Function Documentation

int SerialPort::available ( void  )

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
void SerialPort::begin ( long  speed)

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)
void SerialPort::end ( void  )

To re-enable serial communication, call begin()

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

size_t SerialPort::print ( int  val)

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
size_t SerialPort::print ( int  val,
SerialFormat  format 
)
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
size_t SerialPort::print ( float  val)
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional
size_t SerialPort::print ( float  val,
int  format 
)
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
size_t SerialPort::print ( char  val)
See also
print()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional
size_t SerialPort::print ( const char *  val)
See also
print()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional
size_t SerialPort::println ( int  val)

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
size_t SerialPort::println ( int  val,
SerialFormat  format 
)
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
size_t SerialPort::println ( float  val)
See also
println()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional
size_t SerialPort::println ( float  val,
int  format 
)
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
size_t SerialPort::println ( char  val)
See also
println()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional
size_t SerialPort::println ( const char *  val)
See also
println()
Parameters
[in]valthe value to print
Returns
the number of bytes written, reading that number is optional
int SerialPort::read ( void  )

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

Returns
the first byte of incoming serial data available
-1 if no data is available
int SerialPort::write ( int  val)

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
int SerialPort::write ( const char *  str)
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
int SerialPort::write ( char *  buf,
int  len 
)

[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

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