AGHAF  4.5.5
Annecy electronique Generic Hardware Access Framework
DoKLine/main.cpp
#include <iostream>
#include <vector>
#define AGHAF_DYNAMIC_LIBRARY_INIT
#include <aghaf.h>
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, uint32_t headerSize,
uint8_t const *header, uint32_t footerSize, uint8_t const *footer,
uint32_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, uint32_t headerSize,
uint8_t const *header, uint32_t footerSize, uint8_t const *footer,
uint32_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
if (AGHAF_getDeviceCount() > 0) {
AGHAF_DeviceInfo *devicesInfo = nullptr;
uint32_t deviceInfoNumber = 0;
AGHAF_getDeviceList(&devicesInfo, &deviceInfoNumber);
AGHAF_Device device =
AGHAF_getDeviceBySN(devicesInfo[0].productNo, devicesInfo[0].serialNo);
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);
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
by this flag
Definition: aghaf_dokline_enums.h:18
@ AGHAF_STATUS_OK
The operation succeeded.
Definition: aghaf_global.h:121
@ AGHAF_KLine_MODE_DEFAULT
Definition: aghaf_kline_enums.h:59
@ AGHAF_KLine_PARAM_BAUDRATE
Definition: aghaf_kline_enums.h:90
@ AGHAF_KLine_PARAM_MODE
Definition: aghaf_kline_enums.h:100
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.
Definition: aghaf_dokline.cpp:77
AGHAF_Status AGHAF_DoKLine_Channel_setParam(AGHAF_DoKLine_Channel channel, AGHAF_DoKLine_ChannelParam param, uint32_t value)
Set the parameter from a channel.
Definition: aghaf_dokline.cpp:125
void AGHAF_DoKLine_releaseChannel(AGHAF_DoKLine_Channel channel)
Release the channel.
Definition: aghaf_dokline.cpp:87
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.
Definition: aghaf_dokline.cpp:178
AGHAF_Status AGHAF_DoKLine_Channel_start(AGHAF_DoKLine_Channel channel)
Start a channel.
Definition: aghaf_dokline.cpp:153
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.
Definition: aghaf_dokline.cpp:164
void AGHAF_KLine_setOnMsgTxCallback(AGHAF_KLine kline, AGHAF_KLine_onMsgTx callback, void *userContext)
set the callback called on a tx event
Definition: aghaf_kline.cpp:14
void AGHAF_KLine_setOn5BaudInitCallback(AGHAF_KLine kline, AGHAF_KLine_on5BaudInit callback, void *userContext)
set the callback called on a 5 baud init event
Definition: aghaf_kline.cpp:78
AGHAF_Status AGHAF_KLine_setParam(AGHAF_KLine kline, AGHAF_KLine_Param param, uint32_t value)
set a parameter from a KLine
Definition: aghaf_kline.cpp:171
void AGHAF_KLine_setOnRxErrorCallback(AGHAF_KLine kline, AGHAF_KLine_onRxError callback, void *userContext)
set the callback called on a reception error event
Definition: aghaf_kline.cpp:65
void AGHAF_KLine_setOnSomCallback(AGHAF_KLine kline, AGHAF_KLine_onSOM callback, void *userContext)
set the callback called on a SOM event
Definition: aghaf_kline.cpp:40
AGHAF_Status AGHAF_KLine_deactivate(AGHAF_KLine kline)
stop the communication with the KLine
Definition: aghaf_kline.cpp:131
uint8_t AGHAF_KLine_getCount(AGHAF_Device device)
return the number of KLines available on a device
Definition: aghaf_kline.cpp:111
void AGHAF_KLine_setOnMsgRxCallback(AGHAF_KLine kline, AGHAF_KLine_onMsgRx callback, void *userContext)
set the callback called on a rx event
Definition: aghaf_kline.cpp:27
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 bus at the index specified
Definition: aghaf_kline.cpp:91
void AGHAF_KLine_setOnTxErrorCallback(AGHAF_KLine kline, AGHAF_KLine_onTxError callback, void *userContext)
set the callback called on a transmission error event
Definition: aghaf_kline.cpp:52
AGHAF_Status AGHAF_KLine_activate(AGHAF_KLine kline)
start the communication with the KLine
Definition: aghaf_kline.cpp:121
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:241
AGHAF_Status AGHAF_openDevice(AGHAF_Device device)
Open a device.
Definition: aghaf_global.cpp:231
structure containing the informtions about a device
Definition: aghaf_global.h:215