AGHAF  4.5.1
Annecy electronique Generic Hardware Access Framework
DoCan_FD/main.cpp
#include <vector>
#include <iostream>
#define AGHAF_DYNAMIC_LIBRARY_INIT
#include <aghaf.h>
void doCanBus_1_callback(AGHAF_DoCAN_Event event, void *userContext)
{
(void) userContext;
AGHAF_Status status = AGHAF_Event_getInfo(event, &info);
if (status == AGHAF_STATUS_OK) {
switch (info.type) {
break;
switch (eventType) {
std::cout << __FUNCTION__ << "AGHAF_DOCAN_EVENT_MSGTX" << reinterpret_cast<std::size_t>(channel) << std::endl;
break;
std::cout << __FUNCTION__ << "AGHAF_DoCAN_EVENT_MSGTXERR" << reinterpret_cast<std::size_t>(channel) << std::endl;
uint8_t error = AGHAF_DoCAN_Event_getError(event);
std::cout << static_cast<int>(error) << std::endl;
}
break;
std::cout << __FUNCTION__ << "AGHAF_DoCAN_EVENT_MSGRX" << reinterpret_cast<std::size_t>(channel) << std::endl;
uint32_t size = AGHAF_DoCAN_Event_getDataSize(event);
auto *data = new uint8_t[size];
event,
data,
&size);
delete [] data;
}
break;
std::cout << __FUNCTION__ << "AGHAF_DoCAN_MSGRXFF" << std::endl;
break;
std::cout << __FUNCTION__ << "AGHAF_DoCAN_EVENT_MSGRXERR" << reinterpret_cast<std::size_t>(channel) << std::endl;
uint8_t error = AGHAF_DoCAN_Event_getError(event);
std::cout << static_cast<int>(error) << std::endl;
}
break;
}
}
break;
}
}
}
void doCanBus_2_callback(AGHAF_CAN_Event event, void *userContext)
{
(void) event;
(void) userContext;
}
int main()
{
#ifdef _WIN32
AGHAF_loadLibrary(AGHAF_DEFAULT_FILENAME);
#endif
uint32_t count = AGHAF_getDeviceCount();
std::cout << count << std::endl;
if (count > 0) {
AGHAF_DeviceInfo *devicesInfo = nullptr;
uint32_t deviceInfoNumber = 0;
AGHAF_getDeviceList(&devicesInfo, &deviceInfoNumber);
devicesInfo[0].productNo,
devicesInfo[0].serialNo);
AGHAF_freeDeviceList(devicesInfo);
AGHAF_CAN_Bus canBus = AGHAF_CAN_getBus(device, 0);
AGHAF_DoCAN_Bus doCanbus = AGHAF_DoCAN_getBus(device, 0);
// BUS CAN FD -------------------------------
1000000);
5000000);
120);
// --------------------------------------------
doCanbus,
&doCanBus_1_callback,
nullptr);
std::vector<uint8_t> data;
data.push_back(0x01);
channel, static_cast<uint32_t>(data.size()), data.data());
AGHAF_DoCAN_deregisterCallback(doCanbus, &doCanBus_1_callback);
}
#ifdef _WIN32
AGHAF_unloadLibrary();
#endif
return 0;
}
@ CAN_PARAM_TERMINATION
Definition: aghaf_can_enums.h:99
@ CAN_PARAM_LISTEN_ONLY
Definition: aghaf_can_enums.h:93
@ CAN_PARAM_MODE
Definition: aghaf_can_enums.h:55
@ CAN_PARAM_BAUDRATE_FD
Definition: aghaf_can_enums.h:65
@ CAN_PARAM_BAUDRATE
Definition: aghaf_can_enums.h:60
@ AGHAF_CAN_MODE_FD
Definition: aghaf_can_enums.h:37
@ AGHAF_DoCAN_ID_FMT_XTD
Extended identifier (29-bit CAN ID)
Definition: aghaf_docan_enums.h:68
@ AGHAF_DoCAN_TX_DL_CLASSIC_CAN
Classic CAN, TX_DL = 8.
Definition: aghaf_docan_enums.h:52
@ AGHAF_DoCAN_ADDR_MODE_PHYS
Physical.
Definition: aghaf_docan_enums.h:30
@ AGHAF_DoCAN_CHANNEL_DIR_2WAY
2-way channel
Definition: aghaf_docan_enums.h:38
@ AGHAF_DoCAN_CHANNEL_PARAM_TIMING_AR
Definition: aghaf_docan_enums.h:116
@ AGHAF_DoCAN_CHANNEL_PARAM_TIMING_BS
Definition: aghaf_docan_enums.h:121
@ AGHAF_DoCAN_CHANNEL_PARAM_TIMING_AS
Definition: aghaf_docan_enums.h:111
@ AGHAF_DoCAN_CHANNEL_PARAM_PAD_HANDLING
Definition: aghaf_docan_enums.h:94
@ AGHAF_DoCAN_CHANNEL_PARAM_TXDL
Definition: aghaf_docan_enums.h:89
@ AGHAF_DoCAN_CHANNEL_PARAM_REQ_ID_VALUE
Definition: aghaf_docan_enums.h:151
@ AGHAF_DoCAN_CHANNEL_PARAM_REQ_ID_FMT
Definition: aghaf_docan_enums.h:146
@ AGHAF_DoCAN_CHANNEL_PARAM_TIMING_STMIN
Definition: aghaf_docan_enums.h:141
@ AGHAF_DoCAN_CHANNEL_PARAM_ADDRMODE
Definition: aghaf_docan_enums.h:106
@ AGHAF_DoCAN_CHANNEL_PARAM_TIMING_BR
Definition: aghaf_docan_enums.h:125
@ AGHAF_DoCAN_CHANNEL_PARAM_BLOCKSIZE
Definition: aghaf_docan_enums.h:183
@ AGHAF_DoCAN_CHANNEL_PARAM_DIRECTION
Definition: aghaf_docan_enums.h:83
@ AGHAF_DoCAN_CHANNEL_PARAM_RESP_ID_VALUE
Definition: aghaf_docan_enums.h:166
@ AGHAF_DoCAN_CHANNEL_PARAM_RESP_ID_FMT
Definition: aghaf_docan_enums.h:161
@ AGHAF_DoCAN_CHANNEL_PARAM_TIMING_CR
Definition: aghaf_docan_enums.h:134
@ AGHAF_DoCAN_CHANNEL_PARAM_WAITFRAME
Definition: aghaf_docan_enums.h:176
@ AGHAF_DoCAN_CHANNEL_PARAM_PAD_VALUE
Definition: aghaf_docan_enums.h:100
@ AGHAF_DoCAN_CHANNEL_PARAM_MAXDATALEN
Definition: aghaf_docan_enums.h:188
@ AGHAF_DoCAN_CHANNEL_PARAM_TIMING_CS
Definition: aghaf_docan_enums.h:129
@ AGHAF_DoCAN_CHANNEL_PARAM_RESP_ID_AE
Definition: aghaf_docan_enums.h:171
@ AGHAF_DoCAN_CHANNEL_PARAM_REQ_ID_AE
Definition: aghaf_docan_enums.h:156
@ AGHAF_DoCAN_PAD_ENABLE
Enable padding handling.
Definition: aghaf_docan_enums.h:46
@ AGHAF_STATUS_OK
The operation succeeded.
Definition: aghaf_global.h:110
@ AGHAF_TypeCanEvent
Event from CAN.
Definition: aghaf_global.h:174
@ AGHAF_TypeEthernetEvent
Event from Ethernet.
Definition: aghaf_global.h:173
@ AGHAF_TypeDoCanEvent
Event from DOCAN.
Definition: aghaf_global.h:175
@ AGHAF_TypeNoEvent
No event. Event is invalid.
Definition: aghaf_global.h:171
@ AGHAF_TypeDeviceEvent
Event from Device.
Definition: aghaf_global.h:172
AGHAF_Status AGHAF_CAN_Bus_deactivate(AGHAF_CAN_Bus bus)
deactivate a CAN bus
Definition: aghaf_can.cpp:194
void * AGHAF_CAN_Bus
handle to a CAN bus
Definition: aghaf_can.h:82
AGHAF_CAN_Bus AGHAF_CAN_getBus(AGHAF_Device device, uint8_t index)
return the CAN bus at index in parameter
Definition: aghaf_can.cpp:16
void * AGHAF_CAN_Event
Handle to a CAN event.
Definition: aghaf_can.h:88
AGHAF_Status AGHAF_CAN_Bus_setParam(AGHAF_CAN_Bus bus, AGHAF_CAN_Param param, uint32_t value)
Set the value from a CAN parameter.
Definition: aghaf_can.cpp:123
AGHAF_Status AGHAF_CAN_Bus_activate(AGHAF_CAN_Bus bus)
activate a CAN bus
Definition: aghaf_can.cpp:183
void * AGHAF_DoCAN_Bus
Handle to a DoCAN bus.
Definition: aghaf_docan.h:31
AGHAF_Status AGHAF_DoCAN_Channel_setParam(AGHAF_DoCAN_Channel channel, AGHAF_DoCAN_ChannelParam param, uint32_t value)
Set the parameter from a channel.
Definition: aghaf_docan.cpp:133
AGHAF_DoCAN_EventType
enumerator to tell the type of the event
Definition: aghaf_docan.h:22
AGHAF_DoCAN_Bus AGHAF_DoCAN_getBus(AGHAF_Device device, uint8_t index)
return the DoCAN bus at index in parameter
Definition: aghaf_docan.cpp:15
AGHAF_Status AGHAF_DoCAN_releaseChannel(AGHAF_DoCAN_Channel channel)
Release the channel.
Definition: aghaf_docan.cpp:95
void * AGHAF_DoCAN_Channel
Handle to a DoCAN channel.
Definition: aghaf_docan.h:37
uint32_t AGHAF_DoCAN_Event_getDataSize(AGHAF_DoCAN_Event event)
return the size from the datas in the event
Definition: aghaf_docan.cpp:224
AGHAF_Status AGHAF_DoCAN_Channel_stop(AGHAF_DoCAN_Channel channel)
Stop a channel.
Definition: aghaf_docan.cpp:168
AGHAF_DoCAN_EventType AGHAF_DoCAN_Event_type(AGHAF_EventInfo event)
return the type from the event
Definition: aghaf_docan.cpp:203
void AGHAF_DoCAN_deregisterCallback(AGHAF_DoCAN_Bus bus, AGHAF_DoCAN_Callback callback)
deregister a callback
Definition: aghaf_docan.cpp:49
AGHAF_DoCAN_Channel AGHAF_DoCAN_Event_getChannel(AGHAF_DoCAN_Event event)
Return the channel on which occured the event.
Definition: aghaf_docan.cpp:270
AGHAF_Status AGHAF_DoCAN_Channel_send(AGHAF_DoCAN_Channel channel, uint32_t dataLen, uint8_t const *data)
Send on the DoCAN channel in parameter.
Definition: aghaf_docan.cpp:181
void * AGHAF_DoCAN_Event
Handle to a DoCAN event.
Definition: aghaf_docan.h:34
AGHAF_Status AGHAF_DoCAN_Event_getData(AGHAF_DoCAN_Event event, uint8_t *data, uint32_t *size)
Provide the datas received in the event.
Definition: aghaf_docan.cpp:237
AGHAF_DoCAN_Channel AGHAF_DoCAN_createChannel(AGHAF_DoCAN_Bus bus)
Create a channel.
Definition: aghaf_docan.cpp:84
uint8_t AGHAF_DoCAN_Event_getError(AGHAF_DoCAN_Event event)
Return the error value from the event.
Definition: aghaf_docan.cpp:259
AGHAF_Status AGHAF_DoCAN_Channel_start(AGHAF_DoCAN_Channel channel)
Start a channel.
Definition: aghaf_docan.cpp:157
void AGHAF_DoCAN_registerCallback(AGHAF_DoCAN_Bus bus, AGHAF_DoCAN_Callback callback, void *userContext)
Register a callback for the DoCAN events from a bus.
Definition: aghaf_docan.cpp:38
@ AGHAF_DoCAN_EVENT_MSGRXFF
First Frame has been received.
Definition: aghaf_docan.h:26
@ AGHAF_DoCAN_EVENT_MSGRXERR
Reception error.
Definition: aghaf_docan.h:27
@ AGHAF_DoCAN_EVENT_MSGTX
End of transmission.
Definition: aghaf_docan.h:23
@ AGHAF_DoCAN_EVENT_MSGTXERR
Transmission Error.
Definition: aghaf_docan.h:24
@ AGHAF_DoCAN_EVENT_MSGRX
Message has been received.
Definition: aghaf_docan.h:25
uint32_t AGHAF_getDeviceCount()
Return the number of devices onnected.
Definition: aghaf_global.cpp:111
AGHAF_Status
enumerator to define the error type in aghaf functions
Definition: aghaf_global.h:109
AGHAF_Status AGHAF_getDeviceList(AGHAF_DeviceInfo **devices, uint32_t *size)
Provide the list of devices connected.
Definition: aghaf_global.cpp:123
AGHAF_Device AGHAF_getDeviceBySN(const char *productNumber, const char *serialNumber)
Return the handle on the specified device.
Definition: aghaf_global.cpp:156
void AGHAF_freeDeviceList(AGHAF_DeviceInfo *devices)
Free the memory allocated with AGHAF_getDeviceList.
Definition: aghaf_global.cpp:135
void * AGHAF_Device
handle on an exxotest device
Definition: aghaf_global.h:145
AGHAF_Status AGHAF_Event_getInfo(AGHAF_Event event, AGHAF_EventInfo *info)
AGHAF_Event_getInfo.
Definition: aghaf_global.cpp:290
AGHAF_Status AGHAF_closeDevice(AGHAF_Device device)
close the device
Definition: aghaf_global.cpp:266
AGHAF_Status AGHAF_openDevice(AGHAF_Device device)
Open a device.
Definition: aghaf_global.cpp:255
@ AGHAF_FALSE
false
Definition: aghaf_global.h:103
structure containing the informtions about a device
Definition: aghaf_global.h:188
generic stucture to read an event in a callback
Definition: aghaf_global.h:201
AGHAF_TypeEvent type
Type information. Provide information about origin (device, can, ethernet...).
Definition: aghaf_global.h:202