AGHAF  4.5.6
Annecy electronique Generic Hardware Access Framework
ADC/main.cpp
#include <iostream>
#define AGHAF_DYNAMIC_LIBRARY_INIT
#include <aghaf.h>
void onConversion(uint64_t timestamp, int32_t value,
AGHAF_ADC_TriggerState state, void *userContext) {
(void)timestamp;
(void)value;
(void)state;
(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_ADC_getCount(device) > 0) {
AGHAF_ADC adc = AGHAF_ADC_get(device, 0);
AGHAF_ADC_setOnConversionCallback(adc, &onConversion, nullptr);
int32_t value = 0;
AGHAF_ADC_getLastConversion(adc, &value, &triggerState);
} else {
std::cerr << "no CAN 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_ADC_TRIG_STATE_NONE
No triggering occurred.
Definition: aghaf_adc_enums.h:37
@ AGHAF_STATUS_OK
The operation succeeded.
Definition: aghaf_global.h:121
AGHAF_Status AGHAF_ADC_getLastConversion(AGHAF_ADC adc, int32_t *value, AGHAF_ADC_TriggerState *triggerState)
Return the current state from the ADC trigger.
Definition: aghaf_adc.cpp:119
void AGHAF_ADC_setOnConversionCallback(AGHAF_ADC adc, AGHAF_ADC_onConversion callback, void *userContext)
Set the callback called on a ADC event.
Definition: aghaf_adc.cpp:14
AGHAF_Status AGHAF_ADC_deactivate(AGHAF_ADC adc)
stop the communication with the ADC
Definition: aghaf_adc.cpp:67
AGHAF_ADC_TriggerState
Trigger state.
Definition: aghaf_adc_enums.h:36
void * AGHAF_ADC
handle on a ADC
Definition: aghaf_adc.h:22
uint8_t AGHAF_ADC_getCount(AGHAF_Device device)
return the number of Adcs available on a device
Definition: aghaf_adc.cpp:47
AGHAF_Status AGHAF_ADC_activate(AGHAF_ADC adc)
start the communication with the ADC
Definition: aghaf_adc.cpp:57
AGHAF_ADC AGHAF_ADC_get(AGHAF_Device device, uint8_t index)
return the KLine bus at the index specified
Definition: aghaf_adc.cpp:27
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