mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
CAN and CAN FD transmit implemented
This commit is contained in:
+17
-1
@@ -180,7 +180,7 @@ bool icsneo_getMessages(const neodevice_t* device, neomessage_t* messages, size_
|
||||
|
||||
for(size_t i = 0; i < *items; i++) {
|
||||
// For each message, copy into neomessage_t buffer given
|
||||
messages[i] = CreateNeoMessage(*(storage[i]));
|
||||
messages[i] = CreateNeoMessage(storage[i]);
|
||||
}
|
||||
|
||||
// The user now has until the next call of icsneo_getMessages (for this device) to use the data, after which point it's freed
|
||||
@@ -270,4 +270,20 @@ bool icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newB
|
||||
return false;
|
||||
|
||||
return device->device->settings->setBaudrateFor(netid, newBaudrate);
|
||||
}
|
||||
|
||||
bool icsneo_transmit(const neodevice_t* device, const neomessage_t* message) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return false;
|
||||
|
||||
return device->device->transmit(CreateMessageFromNeoMessage(message));
|
||||
}
|
||||
|
||||
bool icsneo_transmitMessages(const neodevice_t* device, const neomessage_t* messages, size_t count) {
|
||||
// TODO This can be implemented faster
|
||||
for(size_t i = 0; i < count; i++) {
|
||||
if(!icsneo_transmit(device, messages + i))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -56,6 +56,10 @@ extern bool DLLExport icsneo_settingsApplyDefaultsTemporary(const neodevice_t* d
|
||||
|
||||
extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate);
|
||||
|
||||
extern bool DLLExport icsneo_transmit(const neodevice_t* device, const neomessage_t* message);
|
||||
|
||||
extern bool DLLExport icsneo_transmitMessages(const neodevice_t* device, const neomessage_t* messages, size_t count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
@@ -128,6 +132,12 @@ fn_icsneo_settingsApplyDefaultsTemporary icsneo_settingsApplyDefaultsTemporary;
|
||||
typedef bool(*fn_icsneo_setBaudrate)(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate);
|
||||
fn_icsneo_setBaudrate icsneo_setBaudrate;
|
||||
|
||||
typedef bool(*fn_icsneo_transmit)(const neodevice_t* device, const neomessage_t* message);
|
||||
fn_icsneo_transmit icsneo_transmit;
|
||||
|
||||
typedef bool(*fn_icsneo_transmitMessages)(const neodevice_t* device, const neomessage_t* messages, size_t count);
|
||||
fn_icsneo_transmitMessages icsneo_transmitMessages;
|
||||
|
||||
#define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func)
|
||||
#define ICSNEO_IMPORTASSERT(func) if((ICSNEO_IMPORT(func)) == NULL) return 3
|
||||
void* icsneo_libraryHandle = NULL;
|
||||
@@ -164,6 +174,8 @@ int icsneo_init() {
|
||||
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaults);
|
||||
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaultsTemporary);
|
||||
ICSNEO_IMPORTASSERT(icsneo_setBaudrate);
|
||||
ICSNEO_IMPORTASSERT(icsneo_transmit);
|
||||
ICSNEO_IMPORTASSERT(icsneo_transmitMessages);
|
||||
|
||||
icsneo_initialized = true;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user