AGHAF 5.0.9
Annecy electronique Generic Hardware Access Framework
Loading...
Searching...
No Matches
DoKLine/main.cpp
#define AGHAF_DYNAMIC_LIBRARY_INIT
#include <aghaf.h>
#include <iostream>
#include <vector>
void onMessageTx(uint64_t timestamp, uint8_t flags, uint16_t dataLen,
uint8_t const* data, void* userContext) {
(void)timestamp;
(void)flags;
(void)dataLen;
(void)data;
(void)userContext;
}
void onMessageRx(uint64_t timestamp, uint8_t flags, uint16_t dataLen,
uint8_t const* data, void* userContext) {
(void)timestamp;
(void)flags;
(void)dataLen;
(void)data;
(void)userContext;
}
void onSOM(uint64_t timestamp, void* userContext) {
(void)timestamp;
(void)userContext;
}
void onTxError(uint64_t timestamp, AGHAF_KLine_Error error, void* userContext) {
(void)timestamp;
(void)error;
(void)userContext;
}
void onRxError(uint64_t timestamp, AGHAF_KLine_Error error, void* userContext) {
(void)timestamp;
(void)error;
(void)userContext;
}
void on5BaudInit(uint64_t timestamp, uint8_t flags, uint16_t dataLen,
uint8_t const* data, void* userContext) {
(void)timestamp;
(void)flags;
(void)dataLen;
(void)data;
(void)userContext;
}
void onMsgTx(uint64_t timestamp, uint8_t flags, uint16_t headerSize,
uint8_t const* header, uint16_t footerSize, uint8_t const* footer,
uint16_t dataSize, uint8_t const* data, void* userContext) {
(void)timestamp;
(void)flags;
(void)headerSize;
(void)header;
(void)footerSize;
(void)footer;
(void)dataSize;
(void)data;
(void)userContext;
}
void onMsgRx(uint64_t timestamp, uint8_t flags, uint16_t headerSize,
uint8_t const* header, uint16_t footerSize, uint8_t const* footer,
uint16_t dataSize, uint8_t const* data, void* userContext) {
(void)timestamp;
(void)flags;
(void)headerSize;
(void)header;
(void)footerSize;
(void)footer;
(void)dataSize;
(void)data;
(void)userContext;
}
void onMsgTxErr(uint64_t timestamp, AGHAF_DoKLine_Error error,
void* userContext) {
(void)timestamp;
(void)error;
(void)userContext;
}
int main() {
#ifdef _WIN32
AGHAF_loadLibrary(AGHAF_DEFAULT_FILENAME);
#endif
uint32_t deviceCount = 0;
AGHAF_getDeviceCount(&deviceCount);
if (deviceCount > 0) {
AGHAF_DeviceInfo* devicesInfo = nullptr;
uint32_t deviceInfoNumber = 0;
AGHAF_getDeviceList(&devicesInfo, &deviceInfoNumber);
AGHAF_Device device = nullptr;
AGHAF_getDeviceBySN(devicesInfo[0].productNo, devicesInfo[0].serialNo,
&device);
AGHAF_freeDeviceList(devicesInfo);
if (AGHAF_KLine_getCount(device) > 0) {
AGHAF_KLine kline = AGHAF_KLine_get(device, 0);
AGHAF_KLine_setOnMsgTxCallback(kline, &onMessageTx, nullptr);
AGHAF_KLine_setOnMsgRxCallback(kline, &onMessageRx, nullptr);
AGHAF_KLine_setOnSomCallback(kline, &onSOM, nullptr);
AGHAF_KLine_setOnTxErrorCallback(kline, &onTxError, nullptr);
AGHAF_KLine_setOnRxErrorCallback(kline, &onRxError, nullptr);
AGHAF_KLine_setOn5BaudInitCallback(kline, &on5BaudInit, nullptr);
// KLine configuration -------------------------------
// KLine configuration -------------------------------
std::vector<uint8_t> dataToSend;
dataToSend.push_back(0x01);
static_cast<uint32_t>(dataToSend.size()),
dataToSend.data());
} else {
std::cerr << "no KLine on this device" << '\n';
}
} else {
std::cerr << "device is used by another application" << '\n';
}
} else {
std::cerr << "no exxotest device connected" << '\n';
}
#ifdef _WIN32
AGHAF_unloadLibrary();
#endif
return 0;
}
@ AGHAF_DoKLine_CHANNEL_DIR_2WAY
2-way channel
Definition aghaf_dokline_enums.h:36
@ AGHAF_DoKLine_CHANNEL_PARAM_DIRECTION
Definition aghaf_dokline_enums.h:76
@ AGHAF_DoKLine_CHANNEL_PARAM_REQ_SRC_ADDR
Definition aghaf_dokline_enums.h:103
@ AGHAF_DoKLine_CHANNEL_PARAM_REQ_TGT_ADDR
Definition aghaf_dokline_enums.h:97
@ AGHAF_DoKLine_CHANNEL_PARAM_MODE
Definition aghaf_dokline_enums.h:81
@ AGHAF_DoKLine_CHANNEL_PARAM_RSP_TGT_ADDR
Definition aghaf_dokline_enums.h:117
@ AGHAF_DoKLine_CHANNEL_PARAM_RSP_SRC_ADDR
Definition aghaf_dokline_enums.h:124
AGHAF_DoKLine_Error
List of possible errors in DoKLine.
Definition aghaf_dokline_enums.h:26
@ AGHAF_DoKLine_CHANNEL_MODE_DEFAULT
Definition aghaf_dokline_enums.h:56
#define AGHAF_DoKLine_MSG_EVENT_DATA
Definition aghaf_dokline_enums.h:18
@ AGHAF_STATUS_OK
The operation succeeded.
Definition aghaf_global.h:29
@ AGHAF_KLine_MODE_DEFAULT
Definition aghaf_kline_enums.h:74
@ AGHAF_KLine_PARAM_BAUDRATE
Definition aghaf_kline_enums.h:105
@ AGHAF_KLine_PARAM_MODE
Definition aghaf_kline_enums.h:115
AGHAF_KLine_Error
List of possible errors in KLine.
Definition aghaf_kline_enums.h:28
AGHAF_DoKLine_Channel AGHAF_DoKLine_createChannel(AGHAF_KLine kline)
Create a channel.
void AGHAF_DoKLine_releaseChannel(AGHAF_DoKLine_Channel channel)
Release the channel.
AGHAF_Status AGHAF_DoKLine_Channel_send(AGHAF_DoKLine_Channel channel, uint8_t flags, uint32_t dataLen, uint8_t const *data)
Send on the DoKLine channel in parameter.
AGHAF_Status AGHAF_DoKLine_Channel_start(AGHAF_DoKLine_Channel channel)
Start a channel.
AGHAF_Status AGHAF_DoKLine_Channel_setParam(AGHAF_DoKLine_Channel channel, AGHAF_DoKLine_ChannelParam type, uint32_t value)
Set the parameter from a channel.
void * AGHAF_DoKLine_Channel
handle on a DoKLine channel
Definition aghaf_dokline.h:22
AGHAF_Status AGHAF_DoKLine_Channel_stop(AGHAF_DoKLine_Channel channel)
Stop a channel.
AGHAF_Status AGHAF_KLine_setParam(AGHAF_KLine kline, AGHAF_KLine_Param type, uint32_t value)
set a parameter from a KLine
void AGHAF_KLine_setOnMsgTxCallback(AGHAF_KLine kline, AGHAF_KLine_onMsgTx callback, void *userContext)
set the callback called on a tx event
void AGHAF_KLine_setOn5BaudInitCallback(AGHAF_KLine kline, AGHAF_KLine_on5BaudInit callback, void *userContext)
set the callback called on a 5 baud init event
void AGHAF_KLine_setOnRxErrorCallback(AGHAF_KLine kline, AGHAF_KLine_onRxError callback, void *userContext)
set the callback called on a reception error event
void AGHAF_KLine_setOnSomCallback(AGHAF_KLine kline, AGHAF_KLine_onSOM callback, void *userContext)
set the callback called on a SOM event
AGHAF_Status AGHAF_KLine_deactivate(AGHAF_KLine kline)
stop the communication with the KLine
uint8_t AGHAF_KLine_getCount(AGHAF_Device device)
return the number of KLines available on a device
void AGHAF_KLine_setOnMsgRxCallback(AGHAF_KLine kline, AGHAF_KLine_onMsgRx callback, void *userContext)
set the callback called on a rx event
void * AGHAF_KLine
handle on KLine
Definition aghaf_kline.h:22
AGHAF_KLine AGHAF_KLine_get(AGHAF_Device device, uint8_t index)
return the KLine at the index specified
void AGHAF_KLine_setOnTxErrorCallback(AGHAF_KLine kline, AGHAF_KLine_onTxError callback, void *userContext)
set the callback called on a transmission error event
AGHAF_Status AGHAF_KLine_activate(AGHAF_KLine kline)
start the communication with the KLine
AGHAF_Status AGHAF_getDeviceCount(uint32_t *count)
Return the number of devices onnected.
AGHAF_Status AGHAF_getDeviceList(AGHAF_DeviceInfo **devices, uint32_t *size)
Provide the list of devices connected.
void AGHAF_uninitialize(void)
Uninitialize Aghaf library.
void AGHAF_freeDeviceList(AGHAF_DeviceInfo *devices)
Free the memory allocated with AGHAF_getDeviceList.
void * AGHAF_Device
handle on an exxotest device
Definition aghaf_global.h:87
void AGHAF_initialize(void)
Initialize Aghaf library.
AGHAF_Status AGHAF_getDeviceBySN(char const *productNumber, char const *serialNumber, AGHAF_Device *device)
Return the handle on the specified device.
AGHAF_Status AGHAF_closeDevice(AGHAF_Device device)
close the device
AGHAF_Status AGHAF_openDevice(AGHAF_Device device)
Open a device.
structure containing the informtions about a device
Definition aghaf_global.h:127