API: Added icsneoc2.

Signed-off-by: David Rebbe <drebbe@intrepidcs.com>
This commit is contained in:
David Rebbe
2025-02-04 13:48:43 -05:00
parent c5ba2d8d32
commit 6dd4456f9a
81 changed files with 6731 additions and 364 deletions
@@ -20,8 +20,10 @@ enum class PCMType : uint8_t {
using ChannelMap = std::unordered_map<uint8_t, uint8_t>;
class A2BMessage : public Frame {
class A2BMessage : public BusMessage {
public:
const BusMessage::Type getBusType() const final { return BusMessage::Type::A2B; }
static constexpr size_t maxAudioBufferSize = 2048;
enum class TDMMode : uint8_t {
@@ -64,9 +64,9 @@ enum class AppErrorType : uint16_t {
AppNoError = 255
};
class AppErrorMessage : public RawMessage {
class AppErrorMessage : public InternalMessage {
public:
AppErrorMessage() : RawMessage(Message::Type::AppError, Network::NetID::RED_App_Error) {}
AppErrorMessage() : InternalMessage(Message::Type::AppError, Network::NetID::RED_App_Error) {}
uint16_t errorType;
Network::NetID errorNetID;
uint32_t timestamp10us;
@@ -7,8 +7,10 @@
namespace icsneo {
class CANMessage : public Frame {
class CANMessage : public BusMessage {
public:
const BusMessage::Type getBusType() const final { return BusMessage::Type::CAN; }
uint32_t arbid;
uint8_t dlcOnWire;
bool isRemote = false; // Not allowed if CAN FD
@@ -7,9 +7,9 @@
namespace icsneo {
class DiskDataMessage : public RawMessage {
class DiskDataMessage : public InternalMessage {
public:
DiskDataMessage(std::vector<uint8_t>&& d) : RawMessage(Network::NetID::DiskData) {
DiskDataMessage(std::vector<uint8_t>&& d) : InternalMessage(Network::NetID::DiskData) {
data = std::move(d);
}
};
@@ -31,8 +31,10 @@ struct MACAddress {
}
};
class EthernetMessage : public Frame {
class EthernetMessage : public BusMessage {
public:
const BusMessage::Type getBusType() const final { return BusMessage::Type::Ethernet; }
bool preemptionEnabled = false;
uint8_t preemptionFlags = 0;
std::optional<uint32_t> fcs;
@@ -9,7 +9,7 @@
namespace icsneo {
class ExtendedDataMessage : public Frame {
class ExtendedDataMessage : public InternalMessage {
public:
#pragma pack(push, 2)
struct ExtendedDataHeader {
@@ -13,8 +13,8 @@ namespace icsneo {
class CANMessageFilter : public MessageFilter {
public:
CANMessageFilter() : MessageFilter(Network::Type::CAN), arbid(INVALID_ARBID) { messageType = Message::Type::Frame; }
CANMessageFilter(uint32_t arbid) : MessageFilter(Network::Type::CAN), arbid(arbid) { messageType = Message::Type::Frame; }
CANMessageFilter() : MessageFilter(Network::Type::CAN), arbid(INVALID_ARBID) { messageType = Message::Type::BusMessage; }
CANMessageFilter(uint32_t arbid) : MessageFilter(Network::Type::CAN), arbid(arbid) { messageType = Message::Type::BusMessage; }
bool match(const std::shared_ptr<Message>& message) const {
if(!MessageFilter::match(message))
@@ -27,9 +27,9 @@ public:
if(!matchMessageType(message->type))
return false;
if(message->type == Message::Type::Frame || message->type == Message::Type::Main51 ||
message->type == Message::Type::RawMessage || message->type == Message::Type::ReadSettings) {
const auto frame = std::static_pointer_cast<RawMessage>(message);
if(message->type == Message::Type::BusMessage || message->type == Message::Type::Main51 ||
message->type == Message::Type::InternalMessage || message->type == Message::Type::ReadSettings) {
const auto frame = std::static_pointer_cast<InternalMessage>(message);
if(!matchNetworkType(frame->network.getType()))
return false;
if(!matchNetID(frame->network.getNetID()))
@@ -7,9 +7,9 @@
namespace icsneo {
class FlashMemoryMessage : public RawMessage {
class FlashMemoryMessage : public InternalMessage {
public:
FlashMemoryMessage() : RawMessage(Message::Type::RawMessage, Network::NetID::RED_INT_MEMORYREAD) {}
FlashMemoryMessage() : InternalMessage(Message::Type::InternalMessage, Network::NetID::RED_INT_MEMORYREAD) {}
uint16_t startAddress = 0;
};
@@ -10,8 +10,10 @@
namespace icsneo {
class FlexRayMessage : public Frame {
class FlexRayMessage : public BusMessage {
public:
const BusMessage::Type getBusType() const final { return BusMessage::Type::FlexRay; }
uint16_t slotid = 0;
double tsslen = 0;
double framelen = 0;
@@ -8,8 +8,10 @@
namespace icsneo {
class I2CMessage : public Frame {
class I2CMessage : public BusMessage {
public:
const BusMessage::Type getBusType() const final { return BusMessage::Type::I2C; }
enum class DeviceMode : uint8_t {
Target = 0,
Controller = 1
@@ -8,8 +8,10 @@
namespace icsneo {
class ISO9141Message : public Frame {
class ISO9141Message : public BusMessage {
public:
const BusMessage::Type getBusType() const final { return BusMessage::Type::ISO9141; }
std::array<uint8_t, 3> header;
bool isInit = false;
bool isBreak = false;
@@ -34,8 +34,10 @@ struct LINStatusFlags {
bool BreakOnly = false;
};
class LINMessage : public Frame {
class LINMessage : public BusMessage {
public:
const BusMessage::Type getBusType() const final { return BusMessage::Type::LIN; }
enum class Type : uint8_t {
NOT_SET = 0,
LIN_COMMANDER_MSG,
@@ -8,9 +8,9 @@
#include "icsneo/communication/livedata.h"
namespace icsneo {
class LiveDataMessage : public RawMessage {
class LiveDataMessage : public InternalMessage {
public:
LiveDataMessage() : RawMessage(Message::Type::LiveData, Network::NetID::ExtendedCommand) {}
LiveDataMessage() : InternalMessage(Message::Type::LiveData, Network::NetID::ExtendedCommand) {}
LiveDataHandle handle;
LiveDataCommand cmd;
};
@@ -8,9 +8,9 @@
namespace icsneo {
class Main51Message : public RawMessage {
class Main51Message : public InternalMessage {
public:
Main51Message() : RawMessage(Message::Type::Main51, Network::NetID::Main51) {}
Main51Message() : InternalMessage(Message::Type::Main51, Network::NetID::Main51) {}
Command command = Command(0);
bool forceShortFormat = false; // Necessary for EnableNetworkCom and EnableNetworkComEx
};
@@ -7,8 +7,10 @@
namespace icsneo {
class MDIOMessage : public Frame {
class MDIOMessage : public BusMessage {
public:
const BusMessage::Type getBusType() const final { return BusMessage::Type::MDIO; }
enum class Clause : uint8_t {
Clause45 = 0,
Clause22 = 1
+111 -10
View File
@@ -7,14 +7,70 @@ typedef uint16_t neomessagetype_t;
#ifdef __cplusplus
#include "icsneo/communication/network.h"
#include "icsneo/icsneoc2types.h"
#include <vector>
#include <sstream>
#include <string>
namespace icsneo {
class Message {
/**
* @brief Type of message class
*
* @see AbstractMessage::getMsgType()
*/
typedef enum class MessageType : icsneoc2_msg_type_t {
Device = icsneoc2_msg_type_device,
Internal = icsneoc2_msg_type_internal,
Bus = icsneoc2_msg_type_bus,
MaxSize = icsneoc2_msg_type_maxsize,
} MessageType;
/**
* @brief Pure virtual abstract class for all messages. Inherit from Message over this class.
*
* @see Message
*
*/
class AbstractMessage {
public:
virtual const MessageType getMsgType() const = 0;
};
/**
* @brief Base Message class representing Device messages.
*/
class Message : public AbstractMessage {
public:
virtual const MessageType getMsgType() const { return MessageType::Device; }
/**
* @brief Get the string representation of the message type
*
* @return String representation of the message type
*
* @see AbstractMessage::getMsgType()
*/
static std::string getMsgTypeName(MessageType msgType) {
switch (msgType) {
case MessageType::Device:
return "Device";
case MessageType::Internal:
return "Internal";
case MessageType::Bus:
return "Bus";
// Don't default here so we can rely on the compiler to warn us about missing cases
};
std::stringstream ss;
ss << "Unknown (" << static_cast<int>(msgType) << ")";
return ss.str();
}
enum class Type : neomessagetype_t {
Frame = 0,
BusMessage = 0,
// Deprecated: Will be removed in the future.
Frame = BusMessage,
CANErrorCount = 0x100,
CANError = 0x100,
@@ -24,7 +80,9 @@ public:
// Past 0x8000 are all for internal use only
Invalid = 0x8000,
RawMessage = 0x8001,
InternalMessage = 0x8001,
// Deprecated: Will be removed in the future.
RawMessage = InternalMessage,
ReadSettings = 0x8002,
ResetStatus = 0x8003,
DeviceVersion = 0x8004,
@@ -52,26 +110,69 @@ public:
uint64_t timestamp = 0;
};
class RawMessage : public Message {
/**
* @brief Internal Message class representing Device messages that shouldn't be exposed to public APIs.
*/
class InternalMessage : public Message {
public:
RawMessage(Message::Type type = Message::Type::RawMessage) : Message(type) {}
RawMessage(Message::Type type, Network net) : Message(type), network(net) {}
RawMessage(Network net) : Message(Message::Type::RawMessage), network(net) {}
RawMessage(Network net, std::vector<uint8_t> d) : Message(Message::Type::RawMessage), network(net), data(d) {}
InternalMessage(Message::Type type = Message::Type::InternalMessage) : Message(type) {}
InternalMessage(Message::Type type, Network net) : Message(type), network(net) {}
InternalMessage(Network net) : Message(Message::Type::InternalMessage), network(net) {}
InternalMessage(Network net, std::vector<uint8_t> d) : Message(Message::Type::InternalMessage), network(net), data(d) {}
virtual const MessageType getMsgType() const { return MessageType::Internal; }
Network network;
std::vector<uint8_t> data;
};
class Frame : public RawMessage {
/**
* @brief Bus Message class representing Device messages representing Bus networks like CAN, LIN, Ethernet, etc.
*/
class BusMessage : public InternalMessage {
public:
Frame() : RawMessage(Message::Type::Frame) {}
BusMessage() : InternalMessage(Message::Type::BusMessage) {}
/** @brief
* Bus message types, useful for filtering out or identifying Bus Messages.
*/
typedef enum class Type : icsneoc2_msg_bus_type_t {
Invalid = icsneoc2_msg_bus_type_invalid,
Internal = icsneoc2_msg_bus_type_internal,
CAN = icsneoc2_msg_bus_type_can,
LIN = icsneoc2_msg_bus_type_lin,
FlexRay = icsneoc2_msg_bus_type_flexray,
MOST = icsneoc2_msg_bus_type_most,
Ethernet = icsneoc2_msg_bus_type_ethernet,
LSFTCAN = icsneoc2_msg_bus_type_lsftcan,
SWCAN = icsneoc2_msg_bus_type_swcan,
ISO9141 = icsneoc2_msg_bus_type_iso9141,
I2C = icsneoc2_msg_bus_type_i2c,
A2B = icsneoc2_msg_bus_type_a2b,
SPI = icsneoc2_msg_bus_type_spi,
MDIO = icsneoc2_msg_bus_type_mdio,
ANY = icsneoc2_msg_bus_type_any,
OTHER = icsneoc2_msg_bus_type_other
} Type;
const MessageType getMsgType() const final { return MessageType::Bus; }
virtual const BusMessage::Type getBusType() const = 0;
// Description ID of the message. This is used for filtering / tracking in firmware and driver.
// This is equivalent to icsSpyMessage::DescriptionID
uint16_t description = 0;
// weather the message was originally transmitted on the bus. This is equivalent to
// SPY_STATUS_TX_MSG bit field in icsSpyMessage::StatusBitField
bool transmitted = false;
bool error = false;
};
/** @brief Backwards compatibility, RawMessage was renamed to better reflect what it actually does. */
typedef InternalMessage RawMessage;
/** @brief Backwards compatibility, Frame was renamed to better reflect what it actually does. */
typedef BusMessage Frame;
}
#endif // __cplusplus
@@ -7,9 +7,9 @@
namespace icsneo {
class NeoReadMemorySDMessage : public RawMessage {
class NeoReadMemorySDMessage : public InternalMessage {
public:
NeoReadMemorySDMessage() : RawMessage(Message::Type::RawMessage, Network::NetID::NeoMemorySDRead) {}
NeoReadMemorySDMessage() : InternalMessage(Message::Type::InternalMessage, Network::NetID::NeoMemorySDRead) {}
uint32_t startAddress = 0;
};
@@ -8,9 +8,9 @@
namespace icsneo {
class ReadSettingsMessage : public RawMessage {
class ReadSettingsMessage : public InternalMessage {
public:
ReadSettingsMessage() : RawMessage(Message::Type::ReadSettings, Network::NetID::ReadSettings) {}
ReadSettingsMessage() : InternalMessage(Message::Type::ReadSettings, Network::NetID::ReadSettings) {}
enum class Response : uint8_t {
OK = 0,
+176 -174
View File
@@ -12,6 +12,8 @@ typedef uint8_t neonettype_t;
#include <optional>
#include <tuple>
#include <icsneo/icsneoc2types.h>
namespace icsneo {
class Network {
@@ -23,187 +25,187 @@ class Network {
static constexpr uint16_t OFFSET_PLASMA_SLAVE3_RANGE2 = 12800;
public:
enum class NetID : neonetid_t {
Device = 0,
HSCAN = 1,
MSCAN = 2,
SWCAN = 3,
LSFTCAN = 4,
FordSCP = 5,
J1708 = 6,
Aux = 7,
J1850VPW = 8,
ISO9141 = 9,
DiskData = 10,
Main51 = 11,
RED = 12,
SCI = 13,
ISO9141_2 = 14,
ISO14230 = 15,
LIN = 16,
OP_Ethernet1 = 17,
OP_Ethernet2 = 18,
OP_Ethernet3 = 19,
enum class NetID : icsneoc2_netid_t {
Device = icsneoc2_netid_device,
HSCAN = icsneoc2_netid_hscan,
MSCAN = icsneoc2_netid_mscan,
SWCAN = icsneoc2_netid_swcan,
LSFTCAN = icsneoc2_netid_lsftcan,
FordSCP = icsneoc2_netid_fordscp,
J1708 = icsneoc2_netid_j1708,
Aux = icsneoc2_netid_aux,
J1850VPW = icsneoc2_netid_j1850vpw,
ISO9141 = icsneoc2_netid_iso9141,
DiskData = icsneoc2_netid_disk_data,
Main51 = icsneoc2_netid_main51,
RED = icsneoc2_netid_red,
SCI = icsneoc2_netid_sci,
ISO9141_2 = icsneoc2_netid_iso9141_2,
ISO14230 = icsneoc2_netid_iso14230,
LIN = icsneoc2_netid_lin,
OP_Ethernet1 = icsneoc2_netid_op_ethernet1,
OP_Ethernet2 = icsneoc2_netid_op_ethernet2,
OP_Ethernet3 = icsneoc2_netid_op_ethernet3,
// START Device Command Returns
// When we send a command, the device returns on one of these, depending on command
RED_EXT_MEMORYREAD = 20,
RED_INT_MEMORYREAD = 21,
RED_DFLASH_READ = 22,
NeoMemorySDRead = 23, // Response from NeoMemory (MemoryTypeSD)
CAN_ERRBITS = 24,
NeoMemoryWriteDone = 25,
RED_WAVE_CAN1_LOGICAL = 26,
RED_WAVE_CAN2_LOGICAL = 27,
RED_WAVE_LIN1_LOGICAL = 28,
RED_WAVE_LIN2_LOGICAL = 29,
RED_WAVE_LIN1_ANALOG = 30,
RED_WAVE_LIN2_ANALOG = 31,
RED_WAVE_MISC_ANALOG = 32,
RED_WAVE_MISCDIO2_LOGICAL = 33,
RED_NETWORK_COM_ENABLE_EX = 34,
RED_NEOVI_NETWORK = 35,
RED_READ_BAUD_SETTINGS = 36,
RED_OLDFORMAT = 37,
RED_SCOPE_CAPTURE = 38,
RED_HARDWARE_EXCEP = 39,
RED_GET_RTC = 40,
RED_EXT_MEMORYREAD = icsneoc2_netid_red_ext_memoryread,
RED_INT_MEMORYREAD = icsneoc2_netid_red_int_memoryread,
RED_DFLASH_READ = icsneoc2_netid_red_dflash_read,
NeoMemorySDRead = icsneoc2_netid_neo_memory_sdread, // Response from NeoMemory (MemoryTypeSD)
CAN_ERRBITS = icsneoc2_netid_can_errbits,
NeoMemoryWriteDone = icsneoc2_netid_neo_memory_write_done,
RED_WAVE_CAN1_LOGICAL = icsneoc2_netid_red_wave_can1_logical,
RED_WAVE_CAN2_LOGICAL = icsneoc2_netid_red_wave_can2_logical,
RED_WAVE_LIN1_LOGICAL = icsneoc2_netid_red_wave_lin1_logical,
RED_WAVE_LIN2_LOGICAL = icsneoc2_netid_red_wave_lin2_logical,
RED_WAVE_LIN1_ANALOG = icsneoc2_netid_red_wave_lin1_analog,
RED_WAVE_LIN2_ANALOG = icsneoc2_netid_red_wave_lin2_analog,
RED_WAVE_MISC_ANALOG = icsneoc2_netid_red_wave_misc_analog,
RED_WAVE_MISCDIO2_LOGICAL = icsneoc2_netid_red_wave_miscdio2_logical,
RED_NETWORK_COM_ENABLE_EX = icsneoc2_netid_red_network_com_enable_ex,
RED_NEOVI_NETWORK = icsneoc2_netid_red_neovi_network,
RED_READ_BAUD_SETTINGS = icsneoc2_netid_red_read_baud_settings,
RED_OLDFORMAT = icsneoc2_netid_red_oldformat,
RED_SCOPE_CAPTURE = icsneoc2_netid_red_scope_capture,
RED_HARDWARE_EXCEP = icsneoc2_netid_red_hardware_excep,
RED_GET_RTC = icsneoc2_netid_red_get_rtc,
// END Device Command Returns
ISO9141_3 = 41,
HSCAN2 = 42,
HSCAN3 = 44,
OP_Ethernet4 = 45,
OP_Ethernet5 = 46,
ISO9141_4 = 47,
LIN2 = 48,
LIN3 = 49,
LIN4 = 50,
ISO9141_3 = icsneoc2_netid_iso9141_3,
HSCAN2 = icsneoc2_netid_hscan2,
HSCAN3 = icsneoc2_netid_hscan3,
OP_Ethernet4 = icsneoc2_netid_op_ethernet4,
OP_Ethernet5 = icsneoc2_netid_op_ethernet5,
ISO9141_4 = icsneoc2_netid_iso9141_4,
LIN2 = icsneoc2_netid_lin2,
LIN3 = icsneoc2_netid_lin3,
LIN4 = icsneoc2_netid_lin4,
// MOST = 51, Old and unused
RED_App_Error = 52,
CGI = 53,
Reset_Status = 54,
FB_Status = 55,
App_Signal_Status = 56,
Read_Datalink_Cm_Tx_Msg = 57,
Read_Datalink_Cm_Rx_Msg = 58,
Logging_Overflow = 59,
ReadSettings = 60,
HSCAN4 = 61,
HSCAN5 = 62,
RS232 = 63,
UART = 64,
UART2 = 65,
UART3 = 66,
UART4 = 67,
SWCAN2 = 68,
Ethernet_DAQ = 69,
Data_To_Host = 70,
TextAPI_To_Host = 71,
SPI1 = 72,
OP_Ethernet6 = 73,
Red_VBat = 74,
OP_Ethernet7 = 75,
OP_Ethernet8 = 76,
OP_Ethernet9 = 77,
OP_Ethernet10 = 78,
OP_Ethernet11 = 79,
FlexRay1a = 80,
FlexRay1b = 81,
FlexRay2a = 82,
FlexRay2b = 83,
LIN5 = 84,
FlexRay = 85,
FlexRay2 = 86,
OP_Ethernet12 = 87,
I2C = 88,
MOST25 = 90,
MOST50 = 91,
MOST150 = 92,
Ethernet = 93,
GMFSA = 94,
TCP = 95,
HSCAN6 = 96,
HSCAN7 = 97,
LIN6 = 98,
LSFTCAN2 = 99,
LogicalDiskInfo = 187,
WiVICommand = 221,
ScriptStatus = 224,
EthPHYControl = 239,
ExtendedCommand = 240,
ExtendedData = 242,
FlexRayControl = 243,
CoreMiniPreLoad = 244,
HW_COM_Latency_Test = 512,
DeviceStatus = 513,
UDP = 514,
ForwardedMessage = 516,
I2C2 = 517,
I2C3 = 518,
I2C4 = 519,
Ethernet2 = 520,
A2B1 = 522,
A2B2 = 523,
Ethernet3 = 524,
WBMS = 532,
DWCAN9 = 534,
DWCAN10 = 535,
DWCAN11 = 536,
DWCAN12 = 537,
DWCAN13 = 538,
DWCAN14 = 539,
DWCAN15 = 540,
DWCAN16 = 541,
LIN7 = 542,
LIN8 = 543,
SPI2 = 544,
MDIO1 = 545,
MDIO2 = 546,
MDIO3 = 547,
MDIO4 = 548,
MDIO5 = 549,
MDIO6 = 550,
MDIO7 = 551,
MDIO8 = 552,
OP_Ethernet13 = 553,
OP_Ethernet14 = 554,
OP_Ethernet15 = 555,
OP_Ethernet16 = 556,
SPI3 = 557,
SPI4 = 558,
SPI5 = 559,
SPI6 = 560,
SPI7 = 561,
SPI8 = 562,
LIN9 = 563,
LIN10 = 564,
LIN11 = 565,
LIN12 = 566,
LIN13 = 567,
LIN14 = 568,
LIN15 = 569,
LIN16 = 570,
Any = 0xfffe, // Never actually set as type, but used as flag for filtering
Invalid = 0xffff
RED_App_Error = icsneoc2_netid_red_app_error,
CGI = icsneoc2_netid_cgi,
Reset_Status = icsneoc2_netid_reset_status,
FB_Status = icsneoc2_netid_fb_status,
App_Signal_Status = icsneoc2_netid_app_signal_status,
Read_Datalink_Cm_Tx_Msg = icsneoc2_netid_read_datalink_cm_tx_msg,
Read_Datalink_Cm_Rx_Msg = icsneoc2_netid_read_datalink_cm_rx_msg,
Logging_Overflow = icsneoc2_netid_logging_overflow,
ReadSettings = icsneoc2_netid_read_settings,
HSCAN4 = icsneoc2_netid_hscan4,
HSCAN5 = icsneoc2_netid_hscan5,
RS232 = icsneoc2_netid_rs232,
UART = icsneoc2_netid_uart,
UART2 = icsneoc2_netid_uart2,
UART3 = icsneoc2_netid_uart3,
UART4 = icsneoc2_netid_uart4,
SWCAN2 = icsneoc2_netid_swcan2,
Ethernet_DAQ = icsneoc2_netid_ethernet_daq,
Data_To_Host = icsneoc2_netid_data_to_host,
TextAPI_To_Host = icsneoc2_netid_textapi_to_host,
SPI1 = icsneoc2_netid_spi1,
OP_Ethernet6 = icsneoc2_netid_op_ethernet6,
Red_VBat = icsneoc2_netid_red_vbat,
OP_Ethernet7 = icsneoc2_netid_op_ethernet7,
OP_Ethernet8 = icsneoc2_netid_op_ethernet8,
OP_Ethernet9 = icsneoc2_netid_op_ethernet9,
OP_Ethernet10 = icsneoc2_netid_op_ethernet10,
OP_Ethernet11 = icsneoc2_netid_op_ethernet11,
FlexRay1a = icsneoc2_netid_flexray1a,
FlexRay1b = icsneoc2_netid_flexray1b,
FlexRay2a = icsneoc2_netid_flexray2a,
FlexRay2b = icsneoc2_netid_flexray2b,
LIN5 = icsneoc2_netid_lin5,
FlexRay = icsneoc2_netid_flexray,
FlexRay2 = icsneoc2_netid_flexray2,
OP_Ethernet12 = icsneoc2_netid_op_ethernet12,
I2C = icsneoc2_netid_i2c,
MOST25 = icsneoc2_netid_most25,
MOST50 = icsneoc2_netid_most50,
MOST150 = icsneoc2_netid_most150,
Ethernet = icsneoc2_netid_ethernet,
GMFSA = icsneoc2_netid_gmfsa,
TCP = icsneoc2_netid_tcp,
HSCAN6 = icsneoc2_netid_hscan6,
HSCAN7 = icsneoc2_netid_hscan7,
LIN6 = icsneoc2_netid_lin6,
LSFTCAN2 = icsneoc2_netid_lsftcan2,
LogicalDiskInfo = icsneoc2_netid_logical_disk_info,
WiVICommand = icsneoc2_netid_wivi_command,
ScriptStatus = icsneoc2_netid_script_status,
EthPHYControl = icsneoc2_netid_eth_phy_control,
ExtendedCommand = icsneoc2_netid_extended_command,
ExtendedData = icsneoc2_netid_extended_data,
FlexRayControl = icsneoc2_netid_flexray_control,
CoreMiniPreLoad = icsneoc2_netid_coremini_preload,
HW_COM_Latency_Test = icsneoc2_netid_hw_com_latency_test,
DeviceStatus = icsneoc2_netid_device_status,
UDP = icsneoc2_netid_udp,
ForwardedMessage = icsneoc2_netid_forwarded_message,
I2C2 = icsneoc2_netid_i2c2,
I2C3 = icsneoc2_netid_i2c3,
I2C4 = icsneoc2_netid_i2c4,
Ethernet2 = icsneoc2_netid_ethernet2,
A2B1 = icsneoc2_netid_a2b1,
A2B2 = icsneoc2_netid_a2b2,
Ethernet3 = icsneoc2_netid_ethernet3,
WBMS = icsneoc2_netid_wbms,
DWCAN9 = icsneoc2_netid_dwcan9,
DWCAN10 = icsneoc2_netid_dwcan10,
DWCAN11 = icsneoc2_netid_dwcan11,
DWCAN12 = icsneoc2_netid_dwcan12,
DWCAN13 = icsneoc2_netid_dwcan13,
DWCAN14 = icsneoc2_netid_dwcan14,
DWCAN15 = icsneoc2_netid_dwcan15,
DWCAN16 = icsneoc2_netid_dwcan16,
LIN7 = icsneoc2_netid_lin7,
LIN8 = icsneoc2_netid_lin8,
SPI2 = icsneoc2_netid_spi2,
MDIO1 = icsneoc2_netid_mdio1,
MDIO2 = icsneoc2_netid_mdio2,
MDIO3 = icsneoc2_netid_mdio3,
MDIO4 = icsneoc2_netid_mdio4,
MDIO5 = icsneoc2_netid_mdio5,
MDIO6 = icsneoc2_netid_mdio6,
MDIO7 = icsneoc2_netid_mdio7,
MDIO8 = icsneoc2_netid_mdio8,
OP_Ethernet13 = icsneoc2_netid_op_ethernet13,
OP_Ethernet14 = icsneoc2_netid_op_ethernet14,
OP_Ethernet15 = icsneoc2_netid_op_ethernet15,
OP_Ethernet16 = icsneoc2_netid_op_ethernet16,
SPI3 = icsneoc2_netid_spi3,
SPI4 = icsneoc2_netid_spi4,
SPI5 = icsneoc2_netid_spi5,
SPI6 = icsneoc2_netid_spi6,
SPI7 = icsneoc2_netid_spi7,
SPI8 = icsneoc2_netid_spi8,
LIN9 = icsneoc2_netid_lin9,
LIN10 = icsneoc2_netid_lin10,
LIN11 = icsneoc2_netid_lin11,
LIN12 = icsneoc2_netid_lin12,
LIN13 = icsneoc2_netid_lin13,
LIN14 = icsneoc2_netid_lin14,
LIN15 = icsneoc2_netid_lin15,
LIN16 = icsneoc2_netid_lin16,
Any = icsneoc2_netid_any, // Never actually set as type, but used as flag for filtering
Invalid = icsneoc2_netid_invalid
};
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,
LIN = 3,
FlexRay = 4,
MOST = 5,
Ethernet = 6,
LSFTCAN = 7,
SWCAN = 8,
ISO9141 = 9,
I2C = 10,
A2B = 11,
SPI = 12,
MDIO = 13,
Any = 0xFE, // Never actually set as type, but used as flag for filtering
Other = 0xFF
enum class Type : icsneoc2_msg_bus_type_t {
Invalid = icsneoc2_msg_bus_type_invalid,
Internal = icsneoc2_msg_bus_type_internal, // Used for statuses that don't actually need to be transferred to the client application
CAN = icsneoc2_msg_bus_type_can,
LIN = icsneoc2_msg_bus_type_lin,
FlexRay = icsneoc2_msg_bus_type_flexray,
MOST = icsneoc2_msg_bus_type_most,
Ethernet = icsneoc2_msg_bus_type_ethernet,
LSFTCAN = icsneoc2_msg_bus_type_lsftcan,
SWCAN = icsneoc2_msg_bus_type_swcan,
ISO9141 = icsneoc2_msg_bus_type_iso9141,
I2C = icsneoc2_msg_bus_type_i2c,
A2B = icsneoc2_msg_bus_type_a2b,
SPI = icsneoc2_msg_bus_type_spi,
MDIO = icsneoc2_msg_bus_type_mdio,
Any = icsneoc2_msg_bus_type_any, // Never actually set as type, but used as flag for filtering
Other = icsneoc2_msg_bus_type_other
};
enum class CoreMini : uint8_t {
HSCAN = 0,
@@ -13,6 +13,9 @@ namespace icsneo {
typedef uint16_t icscm_bitfield;
std::optional<uint8_t> CAN_DLCToLength(uint8_t length, bool fd);
std::optional<uint8_t> CAN_LengthToDLC(size_t dataLength, bool fd);
#pragma pack(push,2)
struct HardwareCANPacket {
static std::shared_ptr<Message> DecodeToMessage(const std::vector<uint8_t>& bytestream);
@@ -78,4 +81,4 @@ struct HardwareCANErrorPacket {
#endif // __cplusplus
#endif
#endif
+3 -3
View File
@@ -213,8 +213,8 @@ public:
int addMessageCallback(const std::shared_ptr<MessageCallback>& cb) { return com->addMessageCallback(cb); }
bool removeMessageCallback(int id) { return com->removeMessageCallback(id); }
bool transmit(std::shared_ptr<Frame> frame);
bool transmit(std::vector<std::shared_ptr<Frame>> frames);
bool transmit(std::shared_ptr<BusMessage> frame);
bool transmit(std::vector<std::shared_ptr<BusMessage>> frames);
void setWriteBlocks(bool blocks);
@@ -839,7 +839,7 @@ protected:
void handleInternalMessage(std::shared_ptr<Message> message);
virtual void handleDeviceStatus(const std::shared_ptr<RawMessage>&) {}
virtual void handleDeviceStatus(const std::shared_ptr<InternalMessage>&) {}
neodevice_t& getWritableNeoDevice() { return data; }
+68 -70
View File
@@ -14,7 +14,9 @@ typedef uint32_t devicetype_t;
#include <ostream>
#include <cstdint>
typedef uint32_t devicetype_t;
#include <icsneo/icsneoc2types.h>
typedef icsneoc2_devicetype_t devicetype_t;
namespace icsneo {
@@ -22,65 +24,65 @@ class DeviceType {
public:
// This enum used to be a bitfield, but has since become an enum as we have more than 32 devices
// Adding something? Make sure you update the type string and C-compatible defines below!
enum Enum : devicetype_t {
Unknown = (0x00000000),
BLUE = (0x00000001),
ECU_AVB = (0x00000002),
RADSupermoon = (0x00000003),
DW_VCAN = (0x00000004),
RADMoon2 = (0x00000005),
RADMars = (0x00000006),
VCAN4_1 = (0x00000007),
FIRE = (0x00000008),
RADPluto = (0x00000009),
VCAN4_2EL = (0x0000000a),
RADIO_CANHUB = (0x0000000b),
NEOECU12 = (0x0000000c),
OBD2_LCBADGE = (0x0000000d),
RADMoonDuo = (0x0000000e),
FIRE3 = (0x0000000f),
VCAN3 = (0x00000010),
RADJupiter = (0x00000011),
VCAN4_IND = (0x00000012),
RADGigastar = (0x00000013),
RED2 = (0x00000014),
EtherBADGE = (0x00000016),
RAD_A2B = (0x00000017),
RADEpsilon = (0x00000018),
RADGalaxy2 = (0x00000021),
RADMoon3 = (0x00000023),
RADComet = (0x00000024),
FIRE3_FlexRay = (0x00000025),
Connect = (0x00000026),
RADComet3 = (0x00000027),
RADMoonT1S = (0x00000028),
RADGigastar2 = (0x00000029),
RED = (0x00000040),
ECU = (0x00000080),
IEVB = (0x00000100),
Pendant = (0x00000200),
OBD2_PRO = (0x00000400),
ECUChip_UART = (0x00000800),
PLASMA = (0x00001000),
DONT_REUSE0 = (0x00002000), // Previously FIRE_VNET
NEOAnalog = (0x00004000),
CT_OBD = (0x00008000),
DONT_REUSE1 = (0x00010000), // Previously PLASMA_1_12
DONT_REUSE2 = (0x00020000), // Previously PLASMA_1_13
ION = (0x00040000),
RADStar = (0x00080000),
DONT_REUSE3 = (0x00100000), // Previously ION3
VCAN4_4 = (0x00200000),
VCAN4_2 = (0x00400000),
CMProbe = (0x00800000),
EEVB = (0x01000000),
VCANrf = (0x02000000),
FIRE2 = (0x04000000),
Flex = (0x08000000),
RADGalaxy = (0x10000000),
RADStar2 = (0x20000000),
VividCAN = (0x40000000),
OBD2_SIM = (0x80000000)
enum Enum : icsneoc2_devicetype_t {
Unknown = icsneoc2_devicetype_unknown,
BLUE = icsneoc2_devicetype_blue,
ECU_AVB = icsneoc2_devicetype_ecu_avb,
RADSupermoon = icsneoc2_devicetype_rad_supermoon,
DW_VCAN = icsneoc2_devicetype_dw_vcan,
RADMoon2 = icsneoc2_devicetype_rad_moon2,
RADMars = icsneoc2_devicetype_rad_mars,
VCAN4_1 = icsneoc2_devicetype_vcan41,
FIRE = icsneoc2_devicetype_fire,
RADPluto = icsneoc2_devicetype_rad_pluto,
VCAN4_2EL = icsneoc2_devicetype_vcan42_el,
RADIO_CANHUB = icsneoc2_devicetype_radio_canhub,
NEOECU12 = icsneoc2_devicetype_neo_ecu12,
OBD2_LCBADGE = icsneoc2_devicetype_obd2_lc_badge,
RADMoonDuo = icsneoc2_devicetype_rad_moon_duo,
FIRE3 = icsneoc2_devicetype_fire3,
VCAN3 = icsneoc2_devicetype_vcan3,
RADJupiter = icsneoc2_devicetype_rad_jupiter,
VCAN4_IND = icsneoc2_devicetype_vcan4_industrial,
RADGigastar = icsneoc2_devicetype_rad_gigastar,
RED2 = icsneoc2_devicetype_red2,
EtherBADGE = icsneoc2_devicetype_etherbadge,
RAD_A2B = icsneoc2_devicetype_rad_a2b,
RADEpsilon = icsneoc2_devicetype_rad_epsilon,
RADGalaxy2 = icsneoc2_devicetype_rad_galaxy2,
RADMoon3 = icsneoc2_devicetype_rad_moon3,
RADComet = icsneoc2_devicetype_rad_comet,
FIRE3_FlexRay = icsneoc2_devicetype_fire3_flexray,
Connect = icsneoc2_devicetype_connect,
RADComet3 = icsneoc2_devicetype_rad_comet3,
RADMoonT1S = icsneoc2_devicetype_rad_moon_t1s,
RADGigastar2 = icsneoc2_devicetype_rad_gigastar2,
RED = icsneoc2_devicetype_red,
ECU = icsneoc2_devicetype_ecu,
IEVB = icsneoc2_devicetype_ievb,
Pendant = icsneoc2_devicetype_pendant,
OBD2_PRO = icsneoc2_devicetype_obd2_pro,
ECUChip_UART = icsneoc2_devicetype_ecuchip_uart,
PLASMA = icsneoc2_devicetype_plasma,
//DONT_REUSE0 = , // Previously FIRE_VNET
NEOAnalog = icsneoc2_devicetype_neo_analog,
CT_OBD = icsneoc2_devicetype_ct_obd,
//DONT_REUSE1 = (0x00010000), // Previously PLASMA_1_12
//DONT_REUSE2 = (0x00020000), // Previously PLASMA_1_13
ION = icsneoc2_devicetype_ion,
RADStar = icsneoc2_devicetype_rad_star,
//DONT_REUSE3 = (0x00100000), // Previously ION3
VCAN4_4 = icsneoc2_devicetype_vcan44,
VCAN4_2 = icsneoc2_devicetype_vcan42,
CMProbe = icsneoc2_devicetype_cm_probe,
EEVB = icsneoc2_devicetype_eevb,
VCANrf = icsneoc2_devicetype_vcan_rf,
FIRE2 = icsneoc2_devicetype_fire2,
Flex = icsneoc2_devicetype_flex,
RADGalaxy = icsneoc2_devicetype_rad_galaxy,
RADStar2 = icsneoc2_devicetype_rad_star2,
VividCAN = icsneoc2_devicetype_vividcan,
OBD2_SIM = icsneoc2_devicetype_obd2_sim
};
/**
@@ -90,9 +92,10 @@ public:
* as the product name may change based on device-specific factors, such as serial
* number.
*/
static const char* GetGenericProductName(DeviceType::Enum type) {
template<typename T>
static std::string GetGenericProductName(T deviceType) {
// Adding something? Make sure you update DEVICE_TYPE_LONGEST_NAME at the top!
switch(type) {
switch(static_cast<icsneoc2_devicetype_t>(deviceType)) {
case Unknown:
return "Unknown";
case BLUE:
@@ -201,12 +204,7 @@ public:
return "neoVI Connect";
case RADGigastar2:
return "RAD-Gigastar 2";
case DONT_REUSE0:
case DONT_REUSE1:
case DONT_REUSE2:
case DONT_REUSE3:
// Intentionally don't use default so that the compiler throws a warning when something is added
return "Unknown neoVI";
// Intentionally don't use default so that the compiler throws a warning when something is added
}
return "Unknown neoVI";
}
@@ -214,8 +212,8 @@ public:
DeviceType() { value = DeviceType::Enum::Unknown; }
DeviceType(devicetype_t netid) { value = (DeviceType::Enum)netid; }
DeviceType(DeviceType::Enum netid) { value = netid; }
DeviceType::Enum getDeviceType() const { return value; }
std::string getGenericProductName() const { return GetGenericProductName(getDeviceType()); }
icsneoc2_devicetype_t getDeviceType() const { return value; }
std::string getGenericProductName() const { return DeviceType::GetGenericProductName(getDeviceType()); }
operator devicetype_t() const { return getDeviceType(); }
private:
@@ -33,7 +33,7 @@ public:
virtual void handleMessage(const std::shared_ptr<Message>&) {}
// Return true to continue transmitting, success should be written to if false is returned
virtual bool transmitHook(const std::shared_ptr<Frame>& frame, bool& success) { (void)frame; (void)success; return true; }
virtual bool transmitHook(const std::shared_ptr<BusMessage>& frame, bool& success) { (void)frame; (void)success; return true; }
protected:
Device& device;
@@ -25,7 +25,7 @@ public:
void onGoOffline() override;
void handleMessage(const std::shared_ptr<Message>& message) override;
bool transmitHook(const std::shared_ptr<Frame>& frame, bool& success) override;
bool transmitHook(const std::shared_ptr<BusMessage>& frame, bool& success) override;
std::shared_ptr<Controller> getController(uint8_t index) const {
if(index >= controllers.size())
@@ -121,7 +121,7 @@ protected:
// The supported TX networks are the same as the supported RX networks for this device
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
if(message->data.size() < sizeof(neovifire2_status_t))
return;
std::lock_guard<std::mutex> lk(ioMutex);
+1 -1
View File
@@ -81,7 +81,7 @@ protected:
return ret;
}
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
if(message->data.size() < sizeof(fire2vnet_status_t))
return;
std::lock_guard<std::mutex> lk(ioMutex);
@@ -92,7 +92,7 @@ protected:
// The supported TX networks are the same as the supported RX networks for this device
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
if(message->data.size() < sizeof(radgalaxy_status_t))
return;
std::lock_guard<std::mutex> lk(ioMutex);
@@ -97,7 +97,7 @@ protected:
// The supported TX networks are the same as the supported RX networks for this device
void setupSupportedTXNetworks(std::vector<Network>& txNetworks) override { setupSupportedRXNetworks(txNetworks); }
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
if(message->data.size() < sizeof(radgalaxy2_status_t))
return;
std::lock_guard<std::mutex> lk(ioMutex);
@@ -105,7 +105,7 @@ protected:
txNetworks.insert(txNetworks.end(), supportedTxNetworks.begin(), supportedTxNetworks.end());
}
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
if(message->data.size() < sizeof(radgigastar_status_t))
return;
std::lock_guard<std::mutex> lk(ioMutex);
@@ -113,7 +113,7 @@ namespace icsneo
// The supported TX networks are the same as the supported RX networks for this device
void setupSupportedTXNetworks(std::vector<Network> &txNetworks) override { setupSupportedRXNetworks(txNetworks); }
void handleDeviceStatus(const std::shared_ptr<RawMessage> &message) override
void handleDeviceStatus(const std::shared_ptr<InternalMessage> &message) override
{
if (message->data.size() < sizeof(radgigastar2_status_t))
return;
+1 -1
View File
@@ -97,7 +97,7 @@ protected:
txNetworks.insert(txNetworks.end(), supportedTxNetworks.begin(), supportedTxNetworks.end());
}
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
if(message->data.size() < sizeof(radmars_status_t))
return;
std::lock_guard<std::mutex> lk(ioMutex);
@@ -75,7 +75,7 @@ protected:
size_t getEthernetActivationLineCount() const override { return 1; }
void handleDeviceStatus(const std::shared_ptr<RawMessage>& message) override {
void handleDeviceStatus(const std::shared_ptr<InternalMessage>& message) override {
if(message->data.size() < sizeof(valuecan4_2el_status_t))
return;
std::lock_guard<std::mutex> lk(ioMutex);
+740
View File
@@ -0,0 +1,740 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <icsneo/icsneoc2types.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32) || defined(_WIN64)
// Microsoft
#define EXPORT __declspec(dllexport)
#define IMPORT __declspec(dllimport)
#elif defined(__GNUC__)
// GCC
#define EXPORT __attribute__((visibility("default")))
#define IMPORT
#else
// do nothing and hope for the best?
#define EXPORT
#define IMPORT
#pragma warning Unknown dynamic link import/export semantics.
#endif
#ifdef ICSNEOC2_BUILD_STATIC
#define ICSNEOC2_API
#else
#ifdef ICSNEOC2_BUILD_DYNAMIC
#define ICSNEOC2_API EXPORT
#else
#define ICSNEOC2_API IMPORT
#endif // ICSNEOC2_BUILD_DYNAMIC
#endif // ICSNEOC2_BUILD_STATIC
/** @brief icsneoc2_device_t opaque struct definition
*
* This object represents a single device found on the system.
*
* @see icsneo_find_devices
*/
typedef struct icsneoc2_device_t icsneoc2_device_t;
/** @brief icsneoc2_message_t opaque struct definition
*
* This object represents a single event from the device.
*
* @see icsneoc2_device_events_get
*/
typedef struct icsneoc2_message_t icsneoc2_message_t;
/** @brief icsneoc2_event_t opaque struct definition
*
* This object represents a single event from the device.
*
* @see icsneoc2_device_events_get
*/
typedef struct icsneoc2_event_t icsneoc2_event_t;
/** @brief Error codes for icsneo functions.
*
* This enum is guaranteed to be ABI stable, any new values will be appended to the end.
*/
typedef enum _icsneoc2_error_t {
// Function was successful
icsneoc2_error_success,
// Invalid parameters, typically because of a NULL reference.
icsneoc2_error_invalid_parameters,
// Error opening the device.
icsneoc2_error_open_failed,
// Error going online.
icsneoc2_error_go_online_failed,
// Error enabling message polling.
icsneoc2_error_enable_message_polling_failed,
// Error syncing RTC.
icsneoc2_error_sync_rtc_failed,
// Error getting messages.
icsneoc2_error_get_messages_failed,
// Generic invalid type error
icsneoc2_error_invalid_type,
// Generic RTC error code
icsneoc2_error_rtc_failure,
// Error setting settings
icsneoc2_error_set_settings_failure,
// Failed to transmit messages
icsneoc2_error_transmit_messages_failed,
// Failed to copy string to buffer
icsneoc2_error_string_copy_failed,
// Invalid device parameter
icsneoc2_error_invalid_device,
// Invalid message parameter
icsneoc2_error_invalid_message,
// NOTE: Any new values added here should be updated in icsneoc2_error_code_get
} _icsneoc2_error_t;
/** @brief Integer representation of _icsneoc2_error_t enum.
*
* This is used for easier ABI compatibility, especially between other languages.
*/
typedef uint32_t icsneoc2_error_t;
/** @brief Get the error string for an error code.
*
* @param[in] icsneoc2_error_t error_code The error code to get the description of.
* @param[out] const char* value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] uint32_t* value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_error_code_get(icsneoc2_error_t error_code, const char* value, uint32_t* value_length);
/** @brief Get the device type string for a icsneoc2_devicetype_t.
*
* @param[in] icsneoc2_devicetype_t device_type The device type to get the description of.
* @param[out] const char* value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] uint32_t* value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_type_name_get(icsneoc2_devicetype_t device_type, const char* value, uint32_t* value_length);
/** @brief Find all hardware attached to the system.
*
* @param[out] icsneoc2_device_t array of devices to be filled with found devices.
* Undefined behaviour if index is out of range of devices_count.
* @param[in,out] uint32_t* devices_count Size of the devices array. Modified with the number of devices found.
* @param[in] void* reserved Reserved for future use. Currently unused and must be set to NULL.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_find_all(icsneoc2_device_t** devices, uint32_t* devices_count, void* reserved);
/** @brief Check to make sure a device is valid.
*
* @param[in] icsneoc2_device_t device The device to check.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_is_valid(icsneoc2_device_t* device);
/** @brief Check to make sure a device is open.
*
* @param[in] icsneoc2_device_t device The device to check.
* @param[out] bool is_open true if the device is open, false otherwise
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_is_open(icsneoc2_device_t* device, bool* is_open);
/** @brief Check see if a device is disconnected.
*
* @param[in] icsneoc2_device_t device The device to check.
* @param[out] bool is_disconnected true if the device is open, false otherwise
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_is_disconnected(icsneoc2_device_t* device, bool* is_disconnected);
/** @brief Get the open options for a device
*
* @param[in] icsneoc2_device_t device The device to set options for.
* @param[in] icsneoc2_open_options_t options Options to set for the device.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_open_options_get(icsneoc2_device_t* device, icsneoc2_open_options_t* options);
/** @brief Set the open options for a device
*
* @param[in] icsneoc2_device_t device The device to set options for.
* @param[in] icsneoc2_open_options_t options Options to set for the device.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_open_options_set(icsneoc2_device_t* device, icsneoc2_open_options_t options);
/** @brief Open a connection to a device.
*
* After a successful call to this function, icsneoc2_device_close() must be called to close the device.
*
* @param[in] icsneoc2_device_t device The device to open.
* @param[out] icsneo_handle_t* handle Pointer to a handle to the opened device. Will be NULL on failure.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_failure otherwise.
*
* @see icsneoc2_device_close
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_open(icsneoc2_device_t* device);
/** @brief Close a connection to a previously opened device.
*
* After a successful call to icsneoc2_device_open(), this function must be called to close the device.
* An already closed device will still succeed. All messages and events related to the device will be freed.
*
* @param[in] icsneoc2_device_t device The device to close.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_failure otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_close(icsneoc2_device_t* device);
/** @brief Get the description of a device
*
* @param[in] icsneoc2_device_t device The device to get the description of.
* @param[out] const char* value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] uint32_t* value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_description_get(icsneoc2_device_t* device, const char* value, uint32_t* value_length);
/** @brief Get the type of a device
*
* @param[in] icsneoc2_device_t device The device to get the type of.
* @param[out] icsneoc2_devicetype_t* value Pointer to an icsneoc2_devicetype_t to copy the type into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_type_get(icsneoc2_device_t* device, icsneoc2_devicetype_t* value);
/** @brief Get the serial of a device
*
* @param[in] icsneoc2_device_t device The device to get the serial of.
* @param[out] const char* value Pointer to a buffer to copy the serial into. Null terminated.
* @param[in,out] uint32_t* value_length Size of the value buffer. Modified with the length of the serial.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_serial_get(icsneoc2_device_t* device, const char* value, uint32_t* value_length);
/** @brief Set the online state of a device.
*
* @param[in] icsneoc2_device_t device The device to set the online state of.
* @param[in] bool go_online true to go online, false to go offline.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_go_online(icsneoc2_device_t* device, bool go_online);
/** @brief Get the online state of a device.
*
* @param[in] icsneoc2_device_t device The device to get the online state of.
* @param[out] bool true if online, false if offline.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_is_online(icsneoc2_device_t* device, bool* is_online);
/** @brief Get the online supported state of a device.
*
* @param[in] icsneoc2_device_t device The device to get the online supported state of.
* @param[out] bool true if online, false if offline.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_is_online_supported(icsneoc2_device_t* device, bool* is_online_supported);
/** @brief Set the message polling state of a device.
*
* @param[in] icsneoc2_device_t device The device to set the message polling state of.
* @param[in] bool enable true to enable message polling, false to disable message polling..
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_message_polling_set(icsneoc2_device_t* device, bool enable);
/** @brief Get the message polling state of a device.
*
* @param[in] icsneoc2_device_t device The device to set the message polling state of.
* @param[out] bool is_enabled true if message polling is enabled, false if message polling is disabled.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_message_polling_get(icsneoc2_device_t* device, bool* is_enabled);
/** @brief Set the message polling limit of a device.
*
* This will truncate the message queue to the specified limit.
*
* @param[in] icsneoc2_device_t device The device to enforce the message polling limit.
* @param[in] uint32_t limit The limit to enforce.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_message_polling_set_limit(icsneoc2_device_t* device, uint32_t limit);
/** @brief Get the message polling limit of a device.
*
* @see icsneoc2_device_message_polling_set_limit
*
* @param[in] icsneoc2_device_t device The device to enforce the message polling limit.
* @param[out] uint32_t limit The limit to get.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_message_polling_limit_get(icsneoc2_device_t* device, uint32_t* limit);
/** @brief Get the message count of a device
*
* @param[in] icsneoc2_device_t device The device to get the message count of.
* @param[out] uint32_t* count Pointer to a uint32_t to copy the message count into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_message_count_get(icsneoc2_device_t* device, uint32_t* count);
/** @brief Get the timestamp resolution (nanoseconds) of a device
*
* @param[in] icsneoc2_device_t device The device to get the timestamp resolution of.
* @param[out] uint32_t* resolution Pointer to a uint32_t to copy the timestamp resolution in nanoseconds into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_timestamp_resolution_get(icsneoc2_device_t* device, uint32_t* resolution);
/** @brief Get the messages of a device
*
* When calling this function, the previous messages retrieved by this function will be invalid.
*
* @param[in] icsneoc2_device_t device The device to get the messages of.
* @param[out] icsneoc2_message_t** messages Pointer to an array of icsneoc2_message_t to copy the messages into.
* Undefined behaviour if index is out of range of messages_count.
* @param[in,out] uint32_t* messages_count Size of the messages array. Modified with the number of messages found.
* @param[in] uint32_t timeout_ms The timeout in milliseconds to wait for messages. A value of 0 indicates a non-blocking call.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_messages_get(icsneoc2_device_t* device, icsneoc2_message_t** messages, uint32_t* messages_count, uint32_t timeout_ms);
/** @brief Transmit messages from a device
*
* @param[in] icsneoc2_device_t device The device to get the messages of.
* @param[out] icsneoc2_message_t** messages Pointer to an array of icsneoc2_message_t to copy the messages into.
* Undefined behaviour if index is out of range of messages_count.
* @param[in,out] uint32_t* messages_count Size of the messages array. Modified with the number of messages actually transmitted.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_transmission_failed otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_messages_transmit(icsneoc2_device_t* device, icsneoc2_message_t** messages, uint32_t* messages_count);
/** @brief Check if a message is valid
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] bool* is_valid Pointer to a bool to copy the validity of the message into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_is_valid(icsneoc2_device_t* device, icsneoc2_message_t* message, bool* is_valid);
/** @brief Get the type of a message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] icsneoc2_msg_type_t* msg_type Pointer to a icsneoc2_msg_type_t to copy the type of the value into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*
* @see icsneoc2_msg_type_t
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_type_get(icsneoc2_device_t* device, icsneoc2_message_t* message, icsneoc2_msg_type_t* msg_type);
/** @brief Get the message type string for a icsneoc2_msg_bus_type_t.
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] const char* value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] uint32_t* value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_type_name_get(icsneoc2_msg_type_t msg_type, const char* value, uint32_t* value_length);
/** @brief Get the type of a bus message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] icsneoc2_msg_type_t* msg_type Pointer to a icsneoc2_msg_type_t to copy the type of the value into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_invalid_type otherwise.
*
* @see icsneoc2_msg_bus_type_t, icsneoc2_bus_type_name_get
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_bus_type_get(icsneoc2_device_t* device, icsneoc2_message_t* message, icsneoc2_msg_bus_type_t* bus_type);
/** @brief Get the bus type string for a icsneoc2_msg_bus_type_t.
*
* @param[in] icsneoc2_msg_bus_type_t bus_type The bus type to get the description of.
* @param[out] const char* value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] uint32_t* value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_bus_type_name_get(icsneoc2_msg_bus_type_t bus_type, const char* value, uint32_t* value_length);
/** @brief Get the transmission status of a message.
*
* When a message is transmitted from the device, It will be returned in the receive buffer.
* @see icsneoc2_device_messages_transmit
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to modify.
* @param[out] bool value Pointer to a bool to copy the tranmission status into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_is_transmit(icsneoc2_device_t* device, icsneoc2_message_t* message, bool* value);
/** @brief Get the Network ID (netid) of a bus message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] icsneoc2_netid_t* netid Pointer to a icsneoc2_netid_t to copy the type of the value into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters or icsneoc2_error_invalid_type otherwise.
*
* @see icsneoc2_netid_t, icsneoc2_netid_name_get
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_netid_get(icsneoc2_device_t* device, icsneoc2_message_t* message, icsneoc2_netid_t* netid);
/** @brief Get the netid string for a icsneoc2_netid_t.
*
* @param[in] icsneoc2_netid_t netid The network id to get the description of.
* @param[out] const char* value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] uint32_t* value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_netid_name_get(icsneoc2_netid_t netid, const char* value, uint32_t* value_length);
/** @brief Set the Network ID (netid) of a bus message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[in] icsneoc2_netid_t netid The netid to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_netid_set(icsneoc2_device_t* device, icsneoc2_message_t* message, icsneoc2_netid_t netid);
/** @brief Set the data bytes of a message
*
* @note This function will not set the DLC of the message. @see icsneoc2_message_set_dlc
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to copy the data into.
* @param[out] uint8_t* data Pointer to a uint8_t array to copy from.
* @param[in] uint32_t data_length length of the data.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_data_set(icsneoc2_device_t* device, icsneoc2_message_t* message, uint8_t* data, uint32_t data_length);
/** @brief Get the data bytes of a message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] uint8_t* data Pointer to a uint8_t to copy the data bytes into.
* @param[in,out] uint32_t* data_length Pointer to a uint32_t to copy the length of the data into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_data_get(icsneoc2_device_t* device, icsneoc2_message_t* message, uint8_t* data, uint32_t* data_length);
/** @brief Get the Arbitration ID of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] uint32_t* value Pointer to a uint32_t to copy the Arbitration ID into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_arbid_get(icsneoc2_device_t* device, icsneoc2_message_t* message, uint32_t* value);
/** @brief Set the Arbitration ID of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] uint32_t value Arbitration ID to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_arbid_set(icsneoc2_device_t* device, icsneoc2_message_t* message, uint32_t value);
/** @brief Get the DLC on wire of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] uint32_t* value Pointer to a uint32_t to copy the DLC on wire into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_dlc_get(icsneoc2_device_t* device, icsneoc2_message_t* message, int32_t* value);
/** @brief Set the DLC on wire of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] int32_t value DLC to set. Set to a negative value to auto calculate. Auto setting assumes data and
* canfd parameters are correct. Set to 0 on failure. @see icsneoc2_message_can_set_data and icsneoc2_message_can_canfd_set
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_dlc_set(icsneoc2_device_t* device, icsneoc2_message_t* message, int32_t value);
/** @brief Get the Remote Transmission Request (RTR) status of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[in] int32_t value DLC to get.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_is_remote(icsneoc2_device_t* device, icsneoc2_message_t* message, bool* value);
/** @brief Set the Remote Transmission Request (RTR) of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to modify.
* @param[out] bool value Remote status to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_set_remote(icsneoc2_device_t* device, icsneoc2_message_t* message, bool* value);
/** @brief Get the extended status of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] bool* value Pointer to a uint32_t to copy the extended status into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_is_extended(icsneoc2_device_t* device, icsneoc2_message_t* message, bool* value);
/** @brief Set the extended status of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to modify.
* @param[out] bool value Extended status to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_extended_set(icsneoc2_device_t* device, icsneoc2_message_t* message, bool value);
/** @brief Get the CANFD status of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] bool* value Pointer to a uint32_t to copy the CANFD status into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_is_canfd(icsneoc2_device_t* device, icsneoc2_message_t* message, bool* value);
/** @brief Set the CANFD status of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to modify.
* @param[out] bool value CANFD status to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_canfd_set(icsneoc2_device_t* device, icsneoc2_message_t* message, bool value);
/** @brief Get the baudrate switch status (BRS) of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] bool* value Pointer to a uint32_t to copy the baudrate switch (BRS) status into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_baudrate_switch_get(icsneoc2_device_t* device, icsneoc2_message_t* message, bool* value);
/** @brief Set the baudrate switch status (BRS) of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to modify.
* @param[out] bool value baudrate switch status (BRS) to set.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_baudrate_switch_set(icsneoc2_device_t* device, icsneoc2_message_t* message, bool value);
/** @brief Get the error state indicator status of a CAN message
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[in] icsneoc2_message_t* message The message to check.
* @param[out] bool* value Pointer to a uint32_t to copy the error state indicator status into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_error_state_indicator_get(icsneoc2_device_t* device, icsneoc2_message_t* message, bool* value);
/** @brief Create CAN messages for a device
*
* @param[in] icsneoc2_device_t device The device to get the messages of.
* @param[out] icsneoc2_message_t** messages Pointer to an array of icsneoc2_message_t to copy the messages into.
* Undefined behaviour if index is out of range of messages_count.
* @param[in] uint32_t* messages_count Size of the messages array.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_create(icsneoc2_device_t* device, icsneoc2_message_t** messages, uint32_t messages_count);
/** @brief Free CAN messages for a device
*
* @param[in] icsneoc2_device_t device The device to free the messages of.
* @param[in] icsneoc2_message_t* message The message to free.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*
* @warning This function should only be called on messages created by icsneoc2_message_can_create.
*
* @see icsneoc2_message_can_create
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_message_can_free(icsneoc2_device_t* device, icsneoc2_message_t* message);
/** @brief Get the global events not specifically related to a device.
*
* @param[out] icsneoc2_event_t** events Pointer to an array of icsneoc2_event_t to copy the events into.
* Undefined behaviour if index is out of range of events_count.
* @param[in,out] uint32_t* events_count Size of the events array. Modified with the number of events found.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_events_get(icsneoc2_event_t** events, uint32_t* events_count);
/** @brief Get the events of a device.
*
* @param[in] icsneoc2_device_t device The device to get the events of.
* @param[out] icsneoc2_event_t** events Pointer to an array of icsneoc2_event_t to copy the events into.
* Undefined behaviour if index is out of range of events_count.
* @param[in,out] uint32_t* events_count Size of the events array. Modified with the number of events found.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_events_get(icsneoc2_device_t* device, icsneoc2_event_t** events, uint32_t* events_count);
/** @brief Get the error string for an error code.
*
* @param[in] icsneoc2_event_t* event The event to get the description of.
* @param[out] const char* value Pointer to a buffer to copy the description into. Null terminated.
* @param[in,out] uint32_t* value_length Size of the value buffer. Modified with the length of the description.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_event_description_get(icsneoc2_event_t* event, const char* value, uint32_t* value_length);
/** @brief Get the RTC (Real time clock) of a device.
*
* @param[in] icsneoc2_device_t device The device to get the RTC of.
* @param[out] int64_t* unix_epoch Pointer to an int64_t to copy the RTC into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_rtc_get(icsneoc2_device_t* device, int64_t* unix_epoch);
/** @brief Set the RTC (Real time clock) of a device.
*
* @param[in] icsneoc2_device_t device The device to get the RTC of.
* @param[in] int64_t unix_epoch int64_t to copy the RTC into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_rtc_set(icsneoc2_device_t* device, int64_t unix_epoch);
/** @brief Load the default settings for a device
*
* @param[in] icsneoc2_device_t device The device to load the settings for.
* @param[in] bool save True to make the settings permanent, false will be reverted on power cycle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_load_default_settings(icsneoc2_device_t* device, bool save);
/** @brief Get the baudrate for a network
*
* @note @see icsneoc2_device_canfd_baudrate_get for CANFD.
*
* @param[in] icsneoc2_device_t* device The device to get the baudrate value.
* @param[in] icsneoc2_netid_t netid The network to get the baudrate value.
* @param[in] uint64_t* baudrate The baudrate to get the network value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_baudrate_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint64_t* baudrate);
/** @brief Set the baudrate for a network
*
* @note @see icsneoc2_device_canfd_baudrate_set for CANFD.
*
* @param[in] icsneoc2_device_t* device The device to set the baudrate for.
* @param[in] icsneoc2_netid_t netid The network to set the baudrate for.
* @param[in] uint64_t baudrate The baudrate to set the network to.
* @param[in] bool save True to make the settings permanent, false will be reverted on power cycle.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_baudrate_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint64_t baudrate, bool save);
/** @brief Get the baudrate for a CAN FD network
*
* @param[in] icsneoc2_device_t* device The device to get the baudrate value.
* @param[in] icsneoc2_netid_t netid The network to get the baudrate value.
* @param[in] uint64_t* baudrate The baudrate to get the network value.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_canfd_baudrate_get(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint64_t* baudrate);
/** @brief Set the baudrate for a CANFD network
*
* @param[in] icsneoc2_device_t* device The device to set the baudrate for.
* @param[in] icsneoc2_netid_t netid The network to set the baudrate for.
* @param[in] uint64_t baudrate The baudrate to set the network to.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_canfd_baudrate_set(icsneoc2_device_t* device, icsneoc2_netid_t netid, uint64_t baudrate, bool save);
/** @brief Check if the device supports TC10.
*
* @param[in] icsneoc2_device_t* device The device to check against.
* @param[out] bool* supported Pointer to a uint32_t to copy the value into.
*
* @return icsneoc2_error_t icsneoc2_error_success if successful, icsneoc2_error_invalid_parameters otherwise.
*/
ICSNEOC2_API icsneoc2_error_t icsneoc2_device_supports_tc10(icsneoc2_device_t* device, bool* supported);
#ifdef __cplusplus
}
#endif
+382
View File
@@ -0,0 +1,382 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/** @brief
* Options for opening a device. See icsneoc2_device_open() for more info.
*/
typedef enum _icsneoc2_open_options_t {
// No options
icsneoc2_open_options_none = 0x0,
// After opening, go online
icsneoc2_open_options_go_online = 0x1,
// After opening, enable message polling
icsneoc2_open_options_enable_message_polling = 0x2,
// After opening, sync RTC
icsneoc2_open_options_sync_rtc = 0x4,
// After opening, enable auto update
icsneoc2_open_options_enable_auto_update = 0x8,
// After opening, force update
icsneoc2_open_options_force_update = 0x10,
} _icsneoc2_open_options_t;
/** @brief Integer representation of _icsneoc2_open_options_t enum.
*
* This is used for easier ABI compatibility, especially between other languages.
*/
typedef uint32_t icsneoc2_open_options_t;
/** @brief
* Intrepid hardware device types, useful for filtering out or identifying devices.
*/
typedef enum _icsneoc2_devicetype_t {
// Unknown device type
icsneoc2_devicetype_unknown,
// neoVI Blue - Obsolete
icsneoc2_devicetype_blue,
// neoECU AVB/TSN
icsneoc2_devicetype_ecu_avb,
// RAD-SuperMoon
icsneoc2_devicetype_rad_supermoon,
// DualWire ValueCAN - Obsolete
icsneoc2_devicetype_dw_vcan,
// RAD-Moon 2
icsneoc2_devicetype_rad_moon2,
// RAD-Mars
icsneoc2_devicetype_rad_mars,
// ValueCAN 4-1
icsneoc2_devicetype_vcan41,
// neoVI FIRE
icsneoc2_devicetype_fire,
// RAD-Pluto
icsneoc2_devicetype_rad_pluto,
// ValueCAN 4-2EL
icsneoc2_devicetype_vcan42_el,
// RAD-IO CAN-HUB
icsneoc2_devicetype_radio_canhub,
// neoECU12
icsneoc2_devicetype_neo_ecu12,
// neoOBD2-LC Badge
icsneoc2_devicetype_obd2_lc_badge,
// RAD-Moon Duo
icsneoc2_devicetype_rad_moon_duo,
// neoVI FIRE3
icsneoc2_devicetype_fire3,
// ValueCAN3
icsneoc2_devicetype_vcan3,
// RAD-Jupiter
icsneoc2_devicetype_rad_jupiter,
// ValueCAN4 Industrial
icsneoc2_devicetype_vcan4_industrial,
// RAD-Gigastar
icsneoc2_devicetype_rad_gigastar,
// neoVI RED2
icsneoc2_devicetype_red2,
// EtherBADGE
icsneoc2_devicetype_etherbadge,
// RAD-A2B
icsneoc2_devicetype_rad_a2b,
// RAD-Epsilon
icsneoc2_devicetype_rad_epsilon,
// RAD-Moon 3
icsneoc2_devicetype_rad_moon3,
// RAD-Comet
icsneoc2_devicetype_rad_comet,
// neoVI FIRE3 FlexRay
icsneoc2_devicetype_fire3_flexray,
// neoVI CONNECT
icsneoc2_devicetype_connect,
// RAD-Comet 3
icsneoc2_devicetype_rad_comet3,
// RAD-Moon T1S
icsneoc2_devicetype_rad_moon_t1s,
// RAD-Gigastar 2
icsneoc2_devicetype_rad_gigastar2,
// neoVI RED
icsneoc2_devicetype_red,
// neoECU - Obsolete
icsneoc2_devicetype_ecu,
// IEVB - Obsolete
icsneoc2_devicetype_ievb,
// Pendant - Obsolete
icsneoc2_devicetype_pendant,
// neoOBD2 Pro - Obsolete
icsneoc2_devicetype_obd2_pro,
// neoECU Chip - Obsolete
icsneoc2_devicetype_ecuchip_uart,
// neoVI PLASMA
icsneoc2_devicetype_plasma,
// neoAnalog - Obsolete
icsneoc2_devicetype_neo_analog,
// Obsolete
icsneoc2_devicetype_ct_obd,
// neoVI ION
icsneoc2_devicetype_ion,
// RAD-Star - Obsolete
icsneoc2_devicetype_rad_star,
// ValueCAN4-4
icsneoc2_devicetype_vcan44,
// ValueCAN4-2
icsneoc2_devicetype_vcan42,
// CMProbe - Obsolete
icsneoc2_devicetype_cm_probe,
// Ethernet EVB - Obsolete
icsneoc2_devicetype_eevb,
// ValueCAN.rf - Obsolete
icsneoc2_devicetype_vcan_rf,
// neoVI FIRE2
icsneoc2_devicetype_fire2,
// neoVI FLEX - Obsolete
icsneoc2_devicetype_flex,
// RAD-Galaxy
icsneoc2_devicetype_rad_galaxy,
// RAD-Star 2
icsneoc2_devicetype_rad_star2,
// VividCAN
icsneoc2_devicetype_vividcan,
// neoOBD2 SIM
icsneoc2_devicetype_obd2_sim,
// RAD-Galaxy 2
icsneoc2_devicetype_rad_galaxy2,
// Must be last entry
icsneoc2_devicetype_maxsize,
} _icsneoc2_devicetype_t;
/** @brief Integer representation of _icsneoc2_devicetype_t enum.
*
* This is used for easier ABI compatibility, especially between other languages.
*/
typedef uint32_t icsneoc2_devicetype_t;
typedef enum _icsneoc2_msg_type_t {
icsneoc2_msg_type_device,
icsneoc2_msg_type_internal,
icsneoc2_msg_type_bus,
icsneoc2_msg_type_maxsize,
} _icsneoc2_msg_type_t;
/** @brief Integer representation of _icsneoc2_msg_type_t enum.
*
* This is used for easier ABI compatibility, especially between other languages.
*/
typedef uint32_t icsneoc2_msg_type_t;
/** @brief
* Bus message types, useful for filtering out or identifying Bus Messages.
*/
typedef enum _icsneoc2_msg_bus_type_t {
icsneoc2_msg_bus_type_invalid = 0,
icsneoc2_msg_bus_type_internal = 1, // Used for statuses that don't actually need to be transferred to the client application
icsneoc2_msg_bus_type_can = 2,
icsneoc2_msg_bus_type_lin = 3,
icsneoc2_msg_bus_type_flexray = 4,
icsneoc2_msg_bus_type_most = 5,
icsneoc2_msg_bus_type_ethernet = 6,
icsneoc2_msg_bus_type_lsftcan = 7,
icsneoc2_msg_bus_type_swcan = 8,
icsneoc2_msg_bus_type_iso9141 = 9,
icsneoc2_msg_bus_type_i2c = 10,
icsneoc2_msg_bus_type_a2b = 11,
icsneoc2_msg_bus_type_spi = 12,
icsneoc2_msg_bus_type_mdio = 13,
// Must be last entry
icsneoc2_msg_bus_type_maxsize,
icsneoc2_msg_bus_type_any = 0xFE, // Never actually set as type, but used as flag for filtering
icsneoc2_msg_bus_type_other = 0xFF
} _icsneoc2_msg_bus_type_t;
/** @brief Integer representation of _icsneoc2_msg_bus_type_t enum.
*
* This is used for easier ABI compatibility, especially between other languages.
*/
typedef uint8_t icsneoc2_msg_bus_type_t;
typedef enum _icsneoc2_netid_t {
icsneoc2_netid_device = 0,
icsneoc2_netid_hscan = 1,
icsneoc2_netid_mscan = 2,
icsneoc2_netid_swcan = 3,
icsneoc2_netid_lsftcan = 4,
icsneoc2_netid_fordscp = 5,
icsneoc2_netid_j1708 = 6,
icsneoc2_netid_aux = 7,
icsneoc2_netid_j1850vpw = 8,
icsneoc2_netid_iso9141 = 9,
icsneoc2_netid_disk_data = 10,
icsneoc2_netid_main51 = 11,
icsneoc2_netid_red = 12,
icsneoc2_netid_sci = 13,
icsneoc2_netid_iso9141_2 = 14,
icsneoc2_netid_iso14230 = 15,
icsneoc2_netid_lin = 16,
icsneoc2_netid_op_ethernet1 = 17,
icsneoc2_netid_op_ethernet2 = 18,
icsneoc2_netid_op_ethernet3 = 19,
// START Device Command Returns
// When we send a command, the device returns on one of these, depending on command
icsneoc2_netid_red_ext_memoryread = 20,
icsneoc2_netid_red_int_memoryread = 21,
icsneoc2_netid_red_dflash_read = 22,
icsneoc2_netid_neo_memory_sdread = 23, // Response from NeoMemory (MemoryTypeSD)
icsneoc2_netid_can_errbits = 24,
icsneoc2_netid_neo_memory_write_done = 25,
icsneoc2_netid_red_wave_can1_logical = 26,
icsneoc2_netid_red_wave_can2_logical = 27,
icsneoc2_netid_red_wave_lin1_logical = 28,
icsneoc2_netid_red_wave_lin2_logical = 29,
icsneoc2_netid_red_wave_lin1_analog = 30,
icsneoc2_netid_red_wave_lin2_analog = 31,
icsneoc2_netid_red_wave_misc_analog = 32,
icsneoc2_netid_red_wave_miscdio2_logical = 33,
icsneoc2_netid_red_network_com_enable_ex = 34,
icsneoc2_netid_red_neovi_network = 35,
icsneoc2_netid_red_read_baud_settings = 36,
icsneoc2_netid_red_oldformat = 37,
icsneoc2_netid_red_scope_capture = 38,
icsneoc2_netid_red_hardware_excep = 39,
icsneoc2_netid_red_get_rtc = 40,
// END Device Command Returns
icsneoc2_netid_iso9141_3 = 41,
icsneoc2_netid_hscan2 = 42,
icsneoc2_netid_hscan3 = 44,
icsneoc2_netid_op_ethernet4 = 45,
icsneoc2_netid_op_ethernet5 = 46,
icsneoc2_netid_iso9141_4 = 47,
icsneoc2_netid_lin2 = 48,
icsneoc2_netid_lin3 = 49,
icsneoc2_netid_lin4 = 50,
icsneoc2_netid_most_unused = 51, // MOST = 51, Old and unused
icsneoc2_netid_red_app_error = 52,
icsneoc2_netid_cgi = 53,
icsneoc2_netid_reset_status = 54,
icsneoc2_netid_fb_status = 55,
icsneoc2_netid_app_signal_status = 56,
icsneoc2_netid_read_datalink_cm_tx_msg = 57,
icsneoc2_netid_read_datalink_cm_rx_msg = 58,
icsneoc2_netid_logging_overflow = 59,
icsneoc2_netid_read_settings = 60,
icsneoc2_netid_hscan4 = 61,
icsneoc2_netid_hscan5 = 62,
icsneoc2_netid_rs232 = 63,
icsneoc2_netid_uart = 64,
icsneoc2_netid_uart2 = 65,
icsneoc2_netid_uart3 = 66,
icsneoc2_netid_uart4 = 67,
icsneoc2_netid_swcan2 = 68,
icsneoc2_netid_ethernet_daq = 69,
icsneoc2_netid_data_to_host = 70,
icsneoc2_netid_textapi_to_host = 71,
icsneoc2_netid_spi1 = 72,
icsneoc2_netid_op_ethernet6 = 73,
icsneoc2_netid_red_vbat = 74,
icsneoc2_netid_op_ethernet7 = 75,
icsneoc2_netid_op_ethernet8 = 76,
icsneoc2_netid_op_ethernet9 = 77,
icsneoc2_netid_op_ethernet10 = 78,
icsneoc2_netid_op_ethernet11 = 79,
icsneoc2_netid_flexray1a = 80,
icsneoc2_netid_flexray1b = 81,
icsneoc2_netid_flexray2a = 82,
icsneoc2_netid_flexray2b = 83,
icsneoc2_netid_lin5 = 84,
icsneoc2_netid_flexray = 85,
icsneoc2_netid_flexray2 = 86,
icsneoc2_netid_op_ethernet12 = 87,
icsneoc2_netid_i2c = 88,
icsneoc2_netid_most25 = 90,
icsneoc2_netid_most50 = 91,
icsneoc2_netid_most150 = 92,
icsneoc2_netid_ethernet = 93,
icsneoc2_netid_gmfsa = 94,
icsneoc2_netid_tcp = 95,
icsneoc2_netid_hscan6 = 96,
icsneoc2_netid_hscan7 = 97,
icsneoc2_netid_lin6 = 98,
icsneoc2_netid_lsftcan2 = 99,
icsneoc2_netid_logical_disk_info = 187,
icsneoc2_netid_wivi_command = 221,
icsneoc2_netid_script_status = 224,
icsneoc2_netid_eth_phy_control = 239,
icsneoc2_netid_extended_command = 240,
icsneoc2_netid_extended_data = 242,
icsneoc2_netid_flexray_control = 243,
icsneoc2_netid_coremini_preload = 244,
icsneoc2_netid_hw_com_latency_test = 512,
icsneoc2_netid_device_status = 513,
icsneoc2_netid_udp = 514,
icsneoc2_netid_forwarded_message = 516,
icsneoc2_netid_i2c2 = 517,
icsneoc2_netid_i2c3 = 518,
icsneoc2_netid_i2c4 = 519,
icsneoc2_netid_ethernet2 = 520,
icsneoc2_netid_a2b1 = 522,
icsneoc2_netid_a2b2 = 523,
icsneoc2_netid_ethernet3 = 524,
icsneoc2_netid_wbms = 532,
icsneoc2_netid_dwcan9 = 534,
icsneoc2_netid_dwcan10 = 535,
icsneoc2_netid_dwcan11 = 536,
icsneoc2_netid_dwcan12 = 537,
icsneoc2_netid_dwcan13 = 538,
icsneoc2_netid_dwcan14 = 539,
icsneoc2_netid_dwcan15 = 540,
icsneoc2_netid_dwcan16 = 541,
icsneoc2_netid_lin7 = 542,
icsneoc2_netid_lin8 = 543,
icsneoc2_netid_spi2 = 544,
icsneoc2_netid_mdio1 = 545,
icsneoc2_netid_mdio2 = 546,
icsneoc2_netid_mdio3 = 547,
icsneoc2_netid_mdio4 = 548,
icsneoc2_netid_mdio5 = 549,
icsneoc2_netid_mdio6 = 550,
icsneoc2_netid_mdio7 = 551,
icsneoc2_netid_mdio8 = 552,
icsneoc2_netid_op_ethernet13 = 553,
icsneoc2_netid_op_ethernet14 = 554,
icsneoc2_netid_op_ethernet15 = 555,
icsneoc2_netid_op_ethernet16 = 556,
icsneoc2_netid_spi3 = 557,
icsneoc2_netid_spi4 = 558,
icsneoc2_netid_spi5 = 559,
icsneoc2_netid_spi6 = 560,
icsneoc2_netid_spi7 = 561,
icsneoc2_netid_spi8 = 562,
icsneoc2_netid_lin9 = 563,
icsneoc2_netid_lin10 = 564,
icsneoc2_netid_lin11 = 565,
icsneoc2_netid_lin12 = 566,
icsneoc2_netid_lin13 = 567,
icsneoc2_netid_lin14 = 568,
icsneoc2_netid_lin15 = 569,
icsneoc2_netid_lin16 = 570,
// Must be the last entry
icsneoc2_netid_maxsize,
icsneoc2_netid_any = 0xfffe, // Never actually set as type, but used as flag for filtering
icsneoc2_netid_invalid = 0xffff
} _icsneoc2_netid_t;
/** @brief Integer representation of _icsneoc2_netid_t enum.
*
* This is used for easier ABI compatibility, especially between other languages.
*/
typedef uint16_t icsneoc2_netid_t;
#ifdef __cplusplus
}
#endif