MakeBlock Drive Updated Updated library for MakeBlock Ranger

Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
MeSerial Class Reference

Driver for serial. More...

`#include <src/MeSerial.h>`

Inheritance diagram for MeSerial:
[legend]
Collaboration diagram for MeSerial:
[legend]

## Public Member Functions
| MeSerial (void)
| MeSerial (uint8_t port)
| MeSerial (uint8_t receivePin, uint8_t transmitPin, bool inverse_logic=false)
void | setHardware (bool mode)
void | begin (long baudrate)
size_t | write (uint8_t byte)
int | read ()
int | available ()
int16_t | poll (void)
void | end (void)
bool | listen (void)
bool | isListening (void)
void | sendString (char *str)
void | printf (char *fmt,...)
boolean | dataLineAvailable (void)
String | readDataLine (void)
String | concatenateWith (String s1, String s2)
char | letterOf (int i, String s)
int | stringLength (String s)
boolean | equalString (String s1, String s2)
float | getValue (String key)
Public Member Functions inherited from MePort
| MePort (void)
| MePort (uint8_t port)
| MePort (uint8_t port, uint8_t slot)
uint8_t | getPort (void)
uint8_t | getSlot (void)
bool | dRead1 (uint8_t mode=INPUT)
bool | dRead2 (uint8_t mode=INPUT)
bool | dpRead1 (void)
bool | dpRead2 (void)
void | dWrite1 (bool value)
void | dWrite2 (bool value)
int16_t | aRead1 (void)
int16_t | aRead2 (void)
void | aWrite1 (int16_t value)
void | aWrite2 (int16_t value)
void | reset (uint8_t port)
void | reset (uint8_t port, uint8_t slot)
uint8_t | pin1 (void)
uint8_t | pin2 (void)
uint8_t | pin (void)
uint8_t | pin (uint8_t port, uint8_t slot)
Public Member Functions inherited from SoftwareSerial
| SoftwareSerial (uint8_t receivePin, uint8_t transmitPin, bool inverse_logic=false)
void | begin (long speed)
bool | listen ()
void | end ()
bool | isListening ()
bool | stopListening ()
bool | overflow ()
int | peek ()
virtual void | flush ()
| operator bool ()

## Protected Attributes
bool | _hard
bool | _polling
bool | _scratch
int16_t | _bitPeriod
int16_t | _byte
long | _lastTime
char | buffer [64]
String | lastLine
int | bufferIndex
Protected Attributes inherited from MePort
uint8_t | s1
uint8_t | s2
uint8_t | _port
uint8_t | _slot

## Additional Inherited Members
Static Public Member Functions inherited from SoftwareSerial
static void | handle_interrupt () __attribute__((__always_inline__))

## Detailed Description

Driver for serial.

Class: MeSerial

Description
  Declaration of Class MeSerial.

Copyright (C), 2012-2016, MakeBlock

## Constructor & Destructor Documentation

## ◆ MeSerial() [1/3]

MeSerial::MeSerial | ( | void |  | ) |

Alternate Constructor which can call your own function to map the serial to arduino port, no pins are used or initialized here. hardware serial will be used by default.

Parameters

  [in] | None |

## ◆ MeSerial() [2/3]

MeSerial::MeSerial | ( | uint8_t | port | ) |

Alternate Constructor which can call your own function to map the serial to arduino port, If the hardware serial was selected, we will used the hardware serial.

Parameters

  [in] | port | - RJ25 port from PORT_1 to M2

## ◆ MeSerial() [3/3]

MeSerial::MeSerial | ( | uint8_t | receivePin,
|  | uint8_t | transmitPin,
|  | bool | inverse_logic = `false`
| ) |  |

Alternate Constructor which can call your own function to map the serial to arduino port, If the hardware serial was selected, we will used the hardware serial.

Parameters

  [in] | receivePin | - the rx pin of serial(arduino port)
  [in] | transmitPin | - the tx pin of serial(arduino port)
  [in] | inverse_logic | - Whether the Serial level need inv.

## Member Function Documentation

## ◆ available()

int16_t MeSerial::available | ( | void |  | ) |
| virtual

Function
  available

Description
  Get the number of bytes (characters) available for reading from a software serial port. This is data that's already arrived and stored in the serial receive buffer.

Output
  None

Returns
  The number of bytes available to read

Others
  None

Reimplemented from SoftwareSerial.

## ◆ begin()

void MeSerial::begin | ( | long | baudrate | ) |

Function
  begin

Description
  Sets the speed (baud rate) for the serial communication. Supported baud rates are 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, and 115200.

Parameters

  [in] | baudrate | - he baud rate (long)

Output
  None

Returns
  None

Others
  None

## ◆ end()

void MeSerial::end | ( | void |  | ) |

Function
  end

Description
  Stop listening and release the object

Output
  None

Returns
  None

Others
  None

## ◆ isListening()

bool MeSerial::isListening | ( | void |  | ) |

Function
  isListening

Description
  Tests to see if requested software serial port is actively listening.

Output
  None

Returns
  Returns true if we were actually listening.

Others
  None

## ◆ listen()

bool MeSerial::listen | ( | void |  | ) |

Function
  listen

Description
  Enables the selected software serial port to listen, used for software serial. Only one software serial port can listen at a time; data that arrives for other ports will be discarded. Any data already received is discarded during the call to listen() (unless the given instance is already listening).

Output
  None

Returns
  This function sets the current object as the "listening" one and returns true if it replaces another

Others
  None

## ◆ poll()

int16_t MeSerial::poll | ( | void |  | ) |

Function
  poll

Description
  If we used the serial as software serial port, and set the _polling mask true. we beed use this function to read the serial data.

Output
  None

Returns
  The character read, or -1 if none is available

Others
  None

## ◆ printf()

void MeSerial::printf | ( | char * | fmt,
|  |  | ...
| ) |  |

Function
  printf

Description
  Printf format string (of which "printf" stands for "print formatted") refers to a control parameter used by a class of functions in the string-processing libraries of various programming languages.

Parameters

  [in] | fmt | - A string that specifies the format of the output. The formatting string determines what additional arguments you need to provide.

Output
  None

Returns
  None

Others
  None

## ◆ read()

int16_t MeSerial::read | ( | void |  | ) |
| virtual

Function
  read

Description
  Return a character that was received on the RX pin of the software serial port. Note that only one SoftwareSerial instance can receive incoming data at a time (select which one with the listen() function).

Output
  None

Returns
  The character read, or -1 if none is available

Others
  None

Reimplemented from SoftwareSerial.

Reimplemented in MeVoice.

## ◆ sendString()

void MeSerial::sendString | ( | char * | str | ) |

Function
  sendString

Description
  Send a string as a series of bytes, used for printf().

Parameters

  [in] | str | - A string to send as a series of bytes

Output
  None

Returns
  None

Others
  None

## ◆ setHardware()

void MeSerial::setHardware | ( | bool | mode | ) |

Function
  setHardware

Description
  if need change the hardware and software serial, this function can be used.

Parameters

  [in] | mode | - if need use hardware serial this value should set to true, or set it false.

Output
  None

Returns
  None

Others
  None

## ◆ write()

size_t MeSerial::write | ( | uint8_t | byte | ) |
| virtual

Function
  write

Description
  Writes binary data to the serial port. This data is sent as a byte or series of bytes;

Parameters

  [in] | byte | - a value to send as a single byte

Output
  None

Returns
  it will return the number of bytes written, though reading that number is optional

Others
  None

Reimplemented from SoftwareSerial.

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

- src/MeSerial.h
- src/MeSerial.cpp