C API: Add typedefs for neonetid_t and neonettype_t
parent
e29d63b08c
commit
40be68e744
|
|
@ -412,28 +412,28 @@ bool icsneo_settingsApplyStructureTemporary(const neodevice_t* device, const voi
|
|||
return icsneo_settingsWriteStructure(device, structure, structureSize) && icsneo_settingsApplyTemporary(device);
|
||||
}
|
||||
|
||||
int64_t icsneo_getBaudrate(const neodevice_t* device, uint16_t netid) {
|
||||
int64_t icsneo_getBaudrate(const neodevice_t* device, neonetid_t netid) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return -1;
|
||||
|
||||
return device->device->settings->getBaudrateFor(netid);
|
||||
}
|
||||
|
||||
bool icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, int64_t newBaudrate) {
|
||||
bool icsneo_setBaudrate(const neodevice_t* device, neonetid_t netid, int64_t newBaudrate) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return false;
|
||||
|
||||
return device->device->settings->setBaudrateFor(netid, newBaudrate);
|
||||
}
|
||||
|
||||
int64_t icsneo_getFDBaudrate(const neodevice_t* device, uint16_t netid) {
|
||||
int64_t icsneo_getFDBaudrate(const neodevice_t* device, neonetid_t netid) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return -1;
|
||||
|
||||
return device->device->settings->getFDBaudrateFor(netid);
|
||||
}
|
||||
|
||||
bool icsneo_setFDBaudrate(const neodevice_t* device, uint16_t netid, int64_t newBaudrate) {
|
||||
bool icsneo_setFDBaudrate(const neodevice_t* device, neonetid_t netid, int64_t newBaudrate) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return false;
|
||||
|
||||
|
|
@ -645,28 +645,28 @@ bool icsneo_setDigitalIO(const neodevice_t* device, neoio_t type, uint32_t numbe
|
|||
return device->device->setDigitalIO(static_cast<icsneo::IO>(type), number, value);
|
||||
}
|
||||
|
||||
bool icsneo_isTerminationSupportedFor(const neodevice_t* device, uint16_t netid) {
|
||||
bool icsneo_isTerminationSupportedFor(const neodevice_t* device, neonetid_t netid) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return false;
|
||||
|
||||
return device->device->settings->isTerminationSupportedFor(Network(netid));
|
||||
}
|
||||
|
||||
bool icsneo_canTerminationBeEnabledFor(const neodevice_t* device, uint16_t netid) {
|
||||
bool icsneo_canTerminationBeEnabledFor(const neodevice_t* device, neonetid_t netid) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return false;
|
||||
|
||||
return device->device->settings->canTerminationBeEnabledFor(Network(netid));
|
||||
}
|
||||
|
||||
bool icsneo_isTerminationEnabledFor(const neodevice_t* device, uint16_t netid) {
|
||||
bool icsneo_isTerminationEnabledFor(const neodevice_t* device, neonetid_t netid) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return false;
|
||||
|
||||
return device->device->settings->isTerminationEnabledFor(Network(netid)).value_or(false);
|
||||
}
|
||||
|
||||
bool icsneo_setTerminationFor(const neodevice_t* device, uint16_t netid, bool enabled) {
|
||||
bool icsneo_setTerminationFor(const neodevice_t* device, neonetid_t netid, bool enabled) {
|
||||
if(!icsneo_isValidNeoDevice(device))
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "icsneo/communication/network.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
|
@ -106,8 +107,8 @@ typedef struct {
|
|||
const uint8_t* data;
|
||||
size_t length;
|
||||
uint8_t header[4];
|
||||
uint16_t netid;
|
||||
uint8_t type;
|
||||
neonetid_t netid;
|
||||
neonettype_t type;
|
||||
uint8_t reserved0;
|
||||
uint16_t description;
|
||||
uint8_t reserved1[14];
|
||||
|
|
@ -121,8 +122,8 @@ typedef struct {
|
|||
const uint8_t* data;
|
||||
size_t length;
|
||||
uint32_t arbid;
|
||||
uint16_t netid;
|
||||
uint8_t type;
|
||||
neonetid_t netid;
|
||||
neonettype_t type;
|
||||
uint8_t dlcOnWire;
|
||||
uint16_t description;
|
||||
uint8_t reserved[14];
|
||||
|
|
@ -136,8 +137,8 @@ typedef struct {
|
|||
size_t length;
|
||||
uint8_t preemptionFlags;
|
||||
uint8_t reservedHeader[3];
|
||||
uint16_t netid;
|
||||
uint8_t type;
|
||||
neonetid_t netid;
|
||||
neonettype_t type;
|
||||
uint8_t reserved0;
|
||||
uint16_t description;
|
||||
uint8_t reserved1[14];
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
#ifndef __NETWORKID_H_
|
||||
#define __NETWORKID_H_
|
||||
|
||||
#include <stdint.h>
|
||||
typedef uint16_t neonetid_t;
|
||||
typedef uint8_t neonettype_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <cstdint>
|
||||
#include <ostream>
|
||||
#include "icsneo/platform/optional.h"
|
||||
|
||||
|
|
@ -11,7 +14,7 @@ namespace icsneo {
|
|||
|
||||
class Network {
|
||||
public:
|
||||
enum class NetID : uint16_t {
|
||||
enum class NetID : neonetid_t {
|
||||
Device = 0,
|
||||
HSCAN = 1,
|
||||
MSCAN = 2,
|
||||
|
|
@ -126,7 +129,7 @@ public:
|
|||
Any = 0xfffe, // Never actually set as type, but used as flag for filtering
|
||||
Invalid = 0xffff
|
||||
};
|
||||
enum class Type : uint8_t {
|
||||
enum class Type : neonettype_t {
|
||||
Invalid = 0,
|
||||
Internal = 1, // Used for statuses that don't actually need to be transferred to the client application
|
||||
CAN = 2,
|
||||
|
|
@ -766,7 +769,7 @@ public:
|
|||
}
|
||||
|
||||
Network() { setValue(NetID::Invalid); }
|
||||
Network(uint16_t netid) { setValue((NetID)netid); }
|
||||
Network(neonetid_t netid) { setValue((NetID)netid); }
|
||||
Network(NetID netid) { setValue(netid); }
|
||||
Network(CoreMini cm) { setValue(GetNetIDFromCoreMiniNetwork(cm)); }
|
||||
NetID getNetID() const { return value; }
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ extern bool DLLExport icsneo_settingsApplyStructureTemporary(const neodevice_t*
|
|||
* In the case of CAN, this function gets the standard CAN baudrate.
|
||||
* See icsneo_getFDBaudrate() to get the baudrate for (the baudrate-switched portion of) CAN FD.
|
||||
*/
|
||||
extern int64_t DLLExport icsneo_getBaudrate(const neodevice_t* device, uint16_t netid);
|
||||
extern int64_t DLLExport icsneo_getBaudrate(const neodevice_t* device, neonetid_t netid);
|
||||
|
||||
/**
|
||||
* \brief Set the network baudrate for a specified device.
|
||||
|
|
@ -475,7 +475,7 @@ extern int64_t DLLExport icsneo_getBaudrate(const neodevice_t* device, uint16_t
|
|||
*
|
||||
* Call icsneo_settingsApply() or similar to make the changes active on the device.
|
||||
*/
|
||||
extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, int64_t newBaudrate);
|
||||
extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, neonetid_t netid, int64_t newBaudrate);
|
||||
|
||||
/**
|
||||
* \brief Get the CAN FD baudrate for a specified device.
|
||||
|
|
@ -485,7 +485,7 @@ extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, uint16_t net
|
|||
*
|
||||
* See icsneo_getBaudrate() to get the baudrate for the non baudrate-switched portion of CAN FD, classical CAN 2.0, and other network types.
|
||||
*/
|
||||
extern int64_t DLLExport icsneo_getFDBaudrate(const neodevice_t* device, uint16_t netid);
|
||||
extern int64_t DLLExport icsneo_getFDBaudrate(const neodevice_t* device, neonetid_t netid);
|
||||
|
||||
/**
|
||||
* \brief Set the CAN FD baudrate for a specified device.
|
||||
|
|
@ -498,7 +498,7 @@ extern int64_t DLLExport icsneo_getFDBaudrate(const neodevice_t* device, uint16_
|
|||
*
|
||||
* Call icsneo_settingsApply() or similar to make the changes active on the device.
|
||||
*/
|
||||
extern bool DLLExport icsneo_setFDBaudrate(const neodevice_t* device, uint16_t netid, int64_t newBaudrate);
|
||||
extern bool DLLExport icsneo_setFDBaudrate(const neodevice_t* device, neonetid_t netid, int64_t newBaudrate);
|
||||
|
||||
/**
|
||||
* \brief Transmit a single message.
|
||||
|
|
@ -751,7 +751,7 @@ extern bool DLLExport icsneo_setDigitalIO(const neodevice_t* device, neoio_t typ
|
|||
* group has termination enabled, check canTerminationBeEnabledFor
|
||||
* for that.
|
||||
*/
|
||||
extern bool DLLExport icsneo_isTerminationSupportedFor(const neodevice_t* device, uint16_t netid);
|
||||
extern bool DLLExport icsneo_isTerminationSupportedFor(const neodevice_t* device, neonetid_t netid);
|
||||
|
||||
/**
|
||||
* \brief Check whether software switchable termination can currently be enabled for a given network.
|
||||
|
|
@ -764,7 +764,7 @@ extern bool DLLExport icsneo_isTerminationSupportedFor(const neodevice_t* device
|
|||
* returned and an error will have been reported in
|
||||
* icsneo_getLastError().
|
||||
*/
|
||||
extern bool DLLExport icsneo_canTerminationBeEnabledFor(const neodevice_t* device, uint16_t netid);
|
||||
extern bool DLLExport icsneo_canTerminationBeEnabledFor(const neodevice_t* device, neonetid_t netid);
|
||||
|
||||
/**
|
||||
* \brief Check whether software switchable termination is currently
|
||||
|
|
@ -780,7 +780,7 @@ extern bool DLLExport icsneo_canTerminationBeEnabledFor(const neodevice_t* devic
|
|||
* False will be returned and an error will be set in
|
||||
* icsneo_getLastError if the setting is unreadable.
|
||||
*/
|
||||
extern bool DLLExport icsneo_isTerminationEnabledFor(const neodevice_t* device, uint16_t netid);
|
||||
extern bool DLLExport icsneo_isTerminationEnabledFor(const neodevice_t* device, neonetid_t netid);
|
||||
|
||||
/**
|
||||
* \brief Enable or disable software switchable termination for a given network.
|
||||
|
|
@ -793,7 +793,7 @@ extern bool DLLExport icsneo_isTerminationEnabledFor(const neodevice_t* device,
|
|||
* prior to the call, but the change does not need to be applied
|
||||
* to the device before enqueing the enable.
|
||||
*/
|
||||
extern bool DLLExport icsneo_setTerminationFor(const neodevice_t* device, uint16_t netid, bool enabled);
|
||||
extern bool DLLExport icsneo_setTerminationFor(const neodevice_t* device, neonetid_t netid, bool enabled);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
@ -885,16 +885,16 @@ fn_icsneo_settingsApplyStructure icsneo_settingsApplyStructure;
|
|||
typedef bool(*fn_icsneo_settingsApplyStructureTemporary)(const neodevice_t* device, const void* structure, size_t structureSize);
|
||||
fn_icsneo_settingsApplyStructureTemporary icsneo_settingsApplyStructureTemporary;
|
||||
|
||||
typedef int64_t(*fn_icsneo_getBaudrate)(const neodevice_t* device, uint16_t netid);
|
||||
typedef int64_t(*fn_icsneo_getBaudrate)(const neodevice_t* device, neonetid_t netid);
|
||||
fn_icsneo_getBaudrate icsneo_getBaudrate;
|
||||
|
||||
typedef bool(*fn_icsneo_setBaudrate)(const neodevice_t* device, uint16_t netid, int64_t newBaudrate);
|
||||
typedef bool(*fn_icsneo_setBaudrate)(const neodevice_t* device, neonetid_t netid, int64_t newBaudrate);
|
||||
fn_icsneo_setBaudrate icsneo_setBaudrate;
|
||||
|
||||
typedef int64_t(*fn_icsneo_getFDBaudrate)(const neodevice_t* device, uint16_t netid);
|
||||
typedef int64_t(*fn_icsneo_getFDBaudrate)(const neodevice_t* device, neonetid_t netid);
|
||||
fn_icsneo_getFDBaudrate icsneo_getFDBaudrate;
|
||||
|
||||
typedef bool(*fn_icsneo_setFDBaudrate)(const neodevice_t* device, uint16_t netid, int64_t newBaudrate);
|
||||
typedef bool(*fn_icsneo_setFDBaudrate)(const neodevice_t* device, neonetid_t netid, int64_t newBaudrate);
|
||||
fn_icsneo_setFDBaudrate icsneo_setFDBaudrate;
|
||||
|
||||
typedef bool(*fn_icsneo_transmit)(const neodevice_t* device, const neomessage_t* message);
|
||||
|
|
@ -951,16 +951,16 @@ fn_icsneo_getDigitalIO icsneo_getDigitalIO;
|
|||
typedef bool(*fn_icsneo_setDigitalIO)(const neodevice_t* device, neoio_t type, uint32_t number, bool value);
|
||||
fn_icsneo_setDigitalIO icsneo_setDigitalIO;
|
||||
|
||||
typedef bool(*fn_icsneo_isTerminationSupportedFor)(const neodevice_t* device, uint16_t netid);
|
||||
typedef bool(*fn_icsneo_isTerminationSupportedFor)(const neodevice_t* device, neonetid_t netid);
|
||||
fn_icsneo_isTerminationSupportedFor icsneo_isTerminationSupportedFor;
|
||||
|
||||
typedef bool(*fn_icsneo_canTerminationBeEnabledFor)(const neodevice_t* device, uint16_t netid);
|
||||
typedef bool(*fn_icsneo_canTerminationBeEnabledFor)(const neodevice_t* device, neonetid_t netid);
|
||||
fn_icsneo_canTerminationBeEnabledFor icsneo_canTerminationBeEnabledFor;
|
||||
|
||||
typedef bool(*fn_icsneo_isTerminationEnabledFor)(const neodevice_t* device, uint16_t netid);
|
||||
typedef bool(*fn_icsneo_isTerminationEnabledFor)(const neodevice_t* device, neonetid_t netid);
|
||||
fn_icsneo_isTerminationEnabledFor icsneo_isTerminationEnabledFor;
|
||||
|
||||
typedef bool(*fn_icsneo_setTerminationFor)(const neodevice_t* device, uint16_t netid, bool enabled);
|
||||
typedef bool(*fn_icsneo_setTerminationFor)(const neodevice_t* device, neonetid_t netid, bool enabled);
|
||||
fn_icsneo_setTerminationFor icsneo_setTerminationFor;
|
||||
|
||||
#define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func)
|
||||
|
|
|
|||
Loading…
Reference in New Issue