VivicoreSerial library
Classes | Public Member Functions | List of all members
VivicoreSerial Class Reference

This class is for branch to talk with core. More...

#include <VivicoreSerial.h>

Public Member Functions

bool begin (const uint32_t branch_type, const uint16_t user_version, const dcInfo_t *dc_info, const uint8_t dc_num, const uint16_t min_lib_buildno=0)
 
AvailableNum_t available (void)
 
ScalerData_t read (void)
 
RawData_t readRaw (void)
 
bool write (const uint8_t dc_n, const int32_t data_scaler)
 
bool writeRaw (const uint8_t *data, const size_t data_len, const dataType_t data_type=DATA_TYPE_DCDT)
 
bool flush (void)
 
void end (void)
 

Detailed Description

This class is for branch to talk with core.

Member Function Documentation

◆ available()

AvailableNum_t VivicoreSerial::available ( void  )

Before using read or readRaw, the number of available data should be checked with this API. This API returns AvailableNum_t as the following.

Returns
Number of scaler and raw data received from core. 0 is no data available.

◆ begin()

bool VivicoreSerial::begin ( const uint32_t  branch_type,
const uint16_t  user_version,
const dcInfo_t dc_info,
const uint8_t  dc_num,
const uint16_t  min_lib_buildno = 0 
)

This API initializes this library instance and store configuration to communicate with core by the arguments and write API. This API returns error in any case of the following conditions.

Parameters
[in]branch_typeBranch type value
[in]user_versionVersion number for user program
[in]dc_infoPointer to buffer of DC info array
[in]dc_numNumber of DC info array
[in]min_lib_buildno(Optional) Minimum required library build number which is defined as LIBRARY_VER_BUILD_NO
Returns
true if no error, or another in error case.

◆ end()

void VivicoreSerial::end ( void  )

This API terminates talking with core as the following sequence.

  1. Wait for transmission of outgoing data
  2. Disable UART to talk with core
  3. Drop all received data

◆ flush()

bool VivicoreSerial::flush ( void  )

This API encodes the data stored by write. This API sends the encoded data which is succeeded to be encoded or raw data stored by writeRaw, and waits to finish sending. This API does nothing and returns if no data to send.

Returns
true if no error, or another in error case of DataCodeTranslator::encode.

◆ read()

ScalerData_t VivicoreSerial::read ( void  )

This API returns data including decoded DC number, scaler value, and success information. Before calling this API, it is necessary to check if there is available data with available. This API returns false in ScalerData_t::success and does nothing in any case of the following conditions.

This API returns false in ScalerData_t::success but also returns the stored data in any case of the following conditions.

  • data_scaler is out of range between DC min and DC max specified on DC info by begin
  • dc_n is for DC_NATURE_OUT specified on DC info by begin
  • dc_n is for DC_TYPE_BINARY specified on DC info by begin
Returns
Read data from core. ScalerData_t::success is true if no error. false in another case.

◆ readRaw()

RawData_t VivicoreSerial::readRaw ( void  )

This API stores raw data received from core. The raw data is equivalent to the received packet body. Before calling this API, it is necessary to check if there is available data with available. This API returns false in RawData_t::success and does nothing in any case of the following conditions.

Returns
Read data from core. RawData_t::success is true if no error. false in another case.

◆ write()

bool VivicoreSerial::write ( const uint8_t  dc_n,
const int32_t  data_scaler 
)

This API stores scaler data to be sent to core corresponding to DC number. It is necessary to call flush after calling this API to send the stored data to core, or to call this API before begin to override data_ini in DC info as samle code implemented on examples/06_slider/06_slider.ino file. The stored value specified by DC number can be overwritten if this API was called multiple times. This API returns error and does not store the specified data in any case of the following conditions.

  • dc_n is out of range between 1 to the maximum value NUM_MAX_DC in specification
Parameters
[in]dc_nDC number corresponding to data_scaler
[in]data_scalerScaler data to be sent to core
Returns
true if no error, or another in error case.
Warning
This API should not be used with writeRaw in user probram on a *.ino file. If you do that, the program may behave unintentionally.

◆ writeRaw()

bool VivicoreSerial::writeRaw ( const uint8_t *  data,
const size_t  data_len,
const dataType_t  data_type = DATA_TYPE_DCDT 
)

This API stores raw data to be sent to core. The raw data is equivalent to the sending packet body. It is necessary to call flush to send the stored data to core. The stored data can be overwritten if this API was called multiple times. This API returns error but stores data truncated with the internal buffer size in any case of the following conditions.

Parameters
[in]dataPointer to buffer of raw data to be sent to core
[in]data_lenSize of buffer of raw data to be sent to core
[in]data_typeType of raw data to be sent to core
Returns
true if no error, or another in error case.
Warning
This API now supports DATA_TYPE_DCDT only.
This API should not be used with write in user probram on a *.ino file. If you do that, the program may behave unintentionally.

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