VivicoreSerial library
|
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) |
This class is for branch to talk with core.
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.
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.
[in] | branch_type | Branch type value |
[in] | user_version | Version number for user program |
[in] | dc_info | Pointer to buffer of DC info array |
[in] | dc_num | Number of DC info array |
[in] | min_lib_buildno | (Optional) Minimum required library build number which is defined as LIBRARY_VER_BUILD_NO |
void VivicoreSerial::end | ( | void | ) |
This API terminates talking with core as the following sequence.
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.
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.
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.
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.
[in] | dc_n | DC number corresponding to data_scaler |
[in] | data_scaler | Scaler data to be sent to core |
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.
[in] | data | Pointer to buffer of raw data to be sent to core |
[in] | data_len | Size of buffer of raw data to be sent to core |
[in] | data_type | Type of raw data to be sent to core |