LIBABBAURORA  v0.2.2
A C++ library for the ABB Aurora protocol used by inverters and other devices
ABBAuroraSerial Class Reference

Low level serial methods. More...

#include <ABBAuroraSerial.h>

Public Member Functions

 ABBAuroraSerial (const unsigned char &log)
 Default constructor. More...
 
 ~ABBAuroraSerial (void)
 Default destructor. More...
 
bool Begin (const std::string &device, const speed_t &baudrate)
 Begin communication. More...
 
int ReadBytes (uint8_t *buffer, const int &length)
 Read bytes. More...
 
int WriteBytes (uint8_t const *buffer, const int &length)
 Write bytes. More...
 
void Flush (void) const
 Flush buffers. More...
 
uint16_t Word (const uint8_t &msb, const uint8_t &lsb) const
 Return word. More...
 
uint16_t Crc16 (uint8_t *data, const int &offset, const int &count) const
 Calculate checksum. More...
 
uint8_t LowByte (const uint16_t &bytes) const
 Return low byte. More...
 
uint8_t HighByte (const uint16_t &bytes) const
 Return high byte. More...
 
std::string GetErrorMessage (void)
 Get error message. More...
 

Private Attributes

int SerialPort
 Serial port number.
 
std::string ErrorMessage
 Error message string.
 
unsigned char Log
 Log level.
 

Detailed Description

Low level serial methods.

Methods to handle the serial communication between host and device

Constructor & Destructor Documentation

ABBAuroraSerial::ABBAuroraSerial ( const unsigned char &  log)

Default constructor.

Sets the log level of the class

Parameters
logset log level
ABBAuroraSerial::~ABBAuroraSerial ( void  )

Default destructor.

Closes the serial port and deletes the serial object

Member Function Documentation

bool ABBAuroraSerial::Begin ( const std::string &  device,
const speed_t &  baudrate 
)

Begin communication.

Opens the serial port and sets communication parameters

Parameters
deviceThe serial device, i.e. /dev/ttyUSB0
baudrateThe serial baud rate
uint16_t ABBAuroraSerial::Crc16 ( uint8_t *  data,
const int &  offset,
const int &  count 
) const

Calculate checksum.

Calculate a CCITT CRC 16 checksum

Parameters
dataBuffer with data
offsetStart calucation at an offset
countNumber of bytes to include
void ABBAuroraSerial::Flush ( void  ) const

Flush buffers.

Flushes/discards data which is written but not transmitted and/or data which is received but not read by the user

std::string ABBAuroraSerial::GetErrorMessage ( void  )

Get error message.

Returns the error message of a failure

uint8_t ABBAuroraSerial::HighByte ( const uint16_t &  bytes) const

Return high byte.

Return the most significant (high) byte of a word

Parameters
bytesWord to convert
uint8_t ABBAuroraSerial::LowByte ( const uint16_t &  bytes) const

Return low byte.

Return the least significant (low) byte of a word

Parameters
bytesWord to convert
int ABBAuroraSerial::ReadBytes ( uint8_t *  buffer,
const int &  length 
)

Read bytes.

Read bytes available in the input buffer

Parameters
bufferBuffer to store the bytes
lengthNumber of bytes to read
uint16_t ABBAuroraSerial::Word ( const uint8_t &  msb,
const uint8_t &  lsb 
) const

Return word.

Construct a word (2 bytes) from two single bytes

Parameters
msbMost significant (left) byte
lsbLeast significant (right) byte
int ABBAuroraSerial::WriteBytes ( uint8_t const *  buffer,
const int &  length 
)

Write bytes.

Transmit bytes to the device

Parameters
bufferBuffer with bytes to send
lengthNumber of bytes to send

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