Schedule table contains only one sporadic frame.
The sporadic frame is associatted with unconditional frames 0x22, 0x23 and 0x24.
#include <array>
#include <iostream>
#include <thread>
#include <vector>
#define AGHAF_DYNAMIC_LIBRARY_INIT
#include <iomanip>
#include <iostream>
void onLinMasterTx(uint64_t timestamp, uint8_t fid, uint8_t datalen,
uint8_t const *data, void *userContext) {
(void)timestamp;
(void)userContext;
std::cout << __FUNCTION__ << std::endl;
std::cout << "datalen: " << static_cast<int>(datalen) << std::endl;
std::cout << "fid: " << static_cast<int>(fid) << std::endl;
if (data != nullptr) {
std::cout << "0x";
for (uint8_t i = 0; i < datalen; ++i) {
std::cout << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<int>(data[i]);
}
std::cout << std::endl;
} else {
std::cout << "no data" << std::endl;
}
}
void onLinMasterRx(uint64_t timestamp, uint8_t fid, uint8_t datalen,
uint8_t const *data, void *userContext) {
(void)timestamp;
(void)userContext;
std::cout << __FUNCTION__ << std::endl;
std::cout << "datalen: " << static_cast<int>(datalen) << std::endl;
std::cout << "fid: " << static_cast<int>(fid) << std::endl;
std::cout << "0x";
for (uint8_t i = 0; i < datalen; ++i) {
std::cout << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<int>(data[i]);
}
std::cout << std::endl;
}
void *userContext) {
(void)timestamp;
(void)userContext;
std::cout << __FUNCTION__ << std::endl;
std::cout << "error: " << static_cast<int>(error) << std::endl;
}
void onLinSlaveTx(uint64_t timestamp, uint8_t fid, uint8_t datalen,
uint8_t const *data, void *userContext) {
(void)timestamp;
(void)userContext;
std::cout << __FUNCTION__ << std::endl;
std::cout << "datalen: " << static_cast<int>(datalen) << std::endl;
std::cout << "fid: " << static_cast<int>(fid) << std::endl;
if (data != nullptr) {
std::cout << "0x";
for (uint8_t i = 0; i < datalen; ++i) {
std::cout << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<int>(data[i]);
}
std::cout << std::endl;
} else {
std::cout << "no data" << std::endl;
}
}
void onLinSlaveRx(uint64_t timestamp, uint8_t fid, uint8_t datalen,
uint8_t const *data, void *userContext) {
(void)timestamp;
(void)userContext;
std::cout << __FUNCTION__ << std::endl;
std::cout << "datalen: " << static_cast<int>(datalen) << std::endl;
std::cout << "fid: " << static_cast<int>(fid) << std::endl;
std::cout << "0x";
for (uint8_t i = 0; i < datalen; ++i) {
std::cout << std::hex << std::setw(2) << std::setfill('0')
<< static_cast<int>(data[i]);
}
std::cout << std::endl;
}
void *userContext) {
(void)timestamp;
(void)userContext;
std::cout << __FUNCTION__ << std::endl;
std::cout << "error: " << static_cast<int>(error) << std::endl;
}
int main() {
#ifdef _WIN32
AGHAF_loadLibrary(AGHAF_DEFAULT_FILENAME);
#endif
if (count > 0) {
uint32_t deviceInfoNumber = 0;
if (deviceInfoNumber > 1) {
devicesInfo[0].serialNo);
devicesInfo[1].serialNo);
if (linCount1 > 0 && linCount2 > 0) {
std::array<uint8_t, 3> spos = {0x22, 0x23, 0x24};
std::array<uint8_t, 4> spoFrame22 = {0x00, 0x01, 0x02, 0x03};
std::array<uint8_t, 5> spoFrame23 = {0x00, 0x01, 0x02, 0x03, 0x04};
std::array<uint8_t, 6> spoFrame24 = {0x00, 0x01, 0x02,
0x03, 0x05, 0x06};
linMaster, 0, 2, static_cast<uint8_t>(spos.size()), spos.data());
0, static_cast<uint8_t>(spoFrame22.size()),
spoFrame22.data());
0, static_cast<uint8_t>(spoFrame22.size()),
nullptr);
0, static_cast<uint8_t>(spoFrame23.size()),
spoFrame23.data());
0, static_cast<uint8_t>(spoFrame23.size()),
nullptr);
0, static_cast<uint8_t>(spoFrame24.size()),
spoFrame24.data());
0, static_cast<uint8_t>(spoFrame24.size()),
nullptr);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
spoFrame22[0] = 0x0A;
static_cast<uint8_t>(spoFrame22.size()),
spoFrame22.data());
std::this_thread::sleep_for(std::chrono::milliseconds(100));
spoFrame23[1] = 0x0B;
static_cast<uint8_t>(spoFrame23.size()),
spoFrame23.data());
std::this_thread::sleep_for(std::chrono::milliseconds(100));
spoFrame24[2] = 0x0C;
static_cast<uint8_t>(spoFrame24.size()),
spoFrame24.data());
std::this_thread::sleep_for(std::chrono::milliseconds(100));
spoFrame22[3] = 0x0D;
spoFrame23[3] = 0x0D;
spoFrame24[3] = 0x0D;
static_cast<uint8_t>(spoFrame24.size()),
spoFrame24.data());
std::this_thread::sleep_for(std::chrono::milliseconds(100));
static_cast<uint8_t>(spoFrame22.size()),
spoFrame22.data());
static_cast<uint8_t>(spoFrame23.size()),
spoFrame23.data());
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
}
#ifdef _WIN32
AGHAF_unloadLibrary();
#endif
return 0;
}
AGHAF_LIN_Error
enumerator to describe the error on the bus
Definition: aghaf_lin_enums.h:33
@ AGHAF_LIN_MODE_MASTER
LIN master.
Definition: aghaf_lin_enums.h:81
@ AGHAF_LIN_MODE_SLAVE
LIN slave.
Definition: aghaf_lin_enums.h:80
@ AGHAF_LIN_FRAME_KIND_SUBSCRIBE
Receive the response.
Definition: aghaf_lin_enums.h:89
@ AGHAF_LIN_FRAME_KIND_PUBLISH
Transmits the response.
Definition: aghaf_lin_enums.h:88
@ AGHAF_LIN_SCHEDULE_KIND_LOOP
Schedule table run in loop.
Definition: aghaf_lin_enums.h:95
@ AGHAF_LIN_PARAM_BAUDRATE
Definition: aghaf_lin_enums.h:119
@ AGHAF_LIN_PARAM_MODE
Definition: aghaf_lin_enums.h:113
void AGHAF_LIN_setOnMessageTxCallback(AGHAF_LIN lin, AGHAF_LIN_onMessageTx callback, void *userContext)
Set the callback called on tx event.
Definition: aghaf_lin.cpp:14
AGHAF_Status AGHAF_LIN_SCHEDULE_configure(AGHAF_LIN lin, uint8_t scheduleIndex, AGHAF_LIN_ScheduleKind kind)
AGHAF_LIN_SCHEDULE_configure.
Definition: aghaf_lin.cpp:303
void * AGHAF_LIN
handle on a LIN bus
Definition: aghaf_lin.h:22
AGHAF_Status AGHAF_LIN_activate(AGHAF_LIN lin)
Start the communication with the LIN.
Definition: aghaf_lin.cpp:107
AGHAF_Status AGHAF_LIN_deactivate(AGHAF_LIN lin)
Stop the communication with the LIN.
Definition: aghaf_lin.cpp:117
AGHAF_Status AGHAF_LIN_SCHEDULE_addSporadic(AGHAF_LIN lin, uint8_t scheduleIndex, uint8_t timeBaseCount, uint8_t nbSpo, uint8_t *idList)
Add a sporadic frame in a schedule.
Definition: aghaf_lin.cpp:255
AGHAF_Status AGHAF_LIN_SCHEDULE_stop(AGHAF_LIN lin)
Stop the schedule currently executed on the LIN.
Definition: aghaf_lin.cpp:326
AGHAF_Status AGHAF_LIN_configureFrame(AGHAF_LIN lin, uint8_t fid, AGHAF_LIN_FrameKind kind, uint8_t publishFlags, uint8_t dataLen, uint8_t const *initialData)
Configure the frame associated with the frame identifier.
Definition: aghaf_lin.cpp:201
void AGHAF_LIN_setOnMessageRxCallback(AGHAF_LIN lin, AGHAF_LIN_onMessageRx callback, void *userContext)
Set the callback called on rx event.
Definition: aghaf_lin.cpp:27
AGHAF_LIN AGHAF_LIN_get(AGHAF_Device device, uint8_t index)
Return the LIN bus at the index specified.
Definition: aghaf_lin.cpp:77
AGHAF_Status AGHAF_LIN_SCHEDULE_start(AGHAF_LIN lin, uint8_t scheduleIndex)
Start a schedule.
Definition: aghaf_lin.cpp:316
AGHAF_Status AGHAF_LIN_setParam(AGHAF_LIN lin, AGHAF_LIN_Param param, uint32_t value)
Set a parameter from a LIN.
Definition: aghaf_lin.cpp:156
AGHAF_Status AGHAF_LIN_updateFrame(AGHAF_LIN lin, uint8_t fid, uint8_t dataLen, uint8_t const *data)
Update the datas associated to a frame identifier.
Definition: aghaf_lin.cpp:183
void AGHAF_LIN_setOnErrorCallback(AGHAF_LIN lin, AGHAF_LIN_onError callback, void *userContext)
Set the callback called on an error event.
Definition: aghaf_lin.cpp:40
uint8_t AGHAF_LIN_getCount(AGHAF_Device device)
Return the number of LINs available on a device.
Definition: aghaf_lin.cpp:97
uint32_t AGHAF_getDeviceCount()
Return the number of devices onnected.
Definition: aghaf_global.cpp:105
AGHAF_Status AGHAF_getDeviceList(AGHAF_DeviceInfo **devices, uint32_t *size)
Provide the list of devices connected.
Definition: aghaf_global.cpp:117
AGHAF_Device AGHAF_getDeviceBySN(const char *productNumber, const char *serialNumber)
Return the handle on the specified device.
Definition: aghaf_global.cpp:145
void AGHAF_freeDeviceList(AGHAF_DeviceInfo *devices)
Free the memory allocated with AGHAF_getDeviceList.
Definition: aghaf_global.cpp:126
void * AGHAF_Device
handle on an exxotest device
Definition: aghaf_global.h:175
AGHAF_Status AGHAF_closeDevice(AGHAF_Device device)
close the device
Definition: aghaf_global.cpp:237
AGHAF_Status AGHAF_openDevice(AGHAF_Device device)
Open a device.
Definition: aghaf_global.cpp:227
structure containing the informtions about a device
Definition: aghaf_global.h:215