Added the ability to get the baudrate for networks
parent
b12e7dad97
commit
3488e36f2a
|
|
@ -338,7 +338,16 @@ bool icsneo_settingsApplyDefaultsTemporary(const neodevice_t* device) {
|
||||||
return device->device->settings->applyDefaults(true);
|
return device->device->settings->applyDefaults(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate) {
|
int64_t icsneo_getBaudrate(const neodevice_t* device, uint16_t netid) {
|
||||||
|
if(!icsneo_isValidNeoDevice(device)) {
|
||||||
|
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return device->device->settings->getBaudrateFor(netid);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, int64_t newBaudrate) {
|
||||||
if(!icsneo_isValidNeoDevice(device)) {
|
if(!icsneo_isValidNeoDevice(device)) {
|
||||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -347,7 +356,16 @@ bool icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newB
|
||||||
return device->device->settings->setBaudrateFor(netid, newBaudrate);
|
return device->device->settings->setBaudrateFor(netid, newBaudrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool icsneo_setFDBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate) {
|
int64_t icsneo_getFDBaudrate(const neodevice_t* device, uint16_t netid) {
|
||||||
|
if(!icsneo_isValidNeoDevice(device)) {
|
||||||
|
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return device->device->settings->getFDBaudrateFor(netid);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool icsneo_setFDBaudrate(const neodevice_t* device, uint16_t netid, int64_t newBaudrate) {
|
||||||
if(!icsneo_isValidNeoDevice(device)) {
|
if(!icsneo_isValidNeoDevice(device)) {
|
||||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,92 @@ uint16_t IDeviceSettings::CalculateGSChecksum(const std::vector<uint8_t>& settin
|
||||||
return gs_crc;
|
return gs_crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CANBaudrate IDeviceSettings::GetEnumValueForBaudrate(int64_t baudrate) {
|
||||||
|
switch(baudrate) {
|
||||||
|
case 20000:
|
||||||
|
return BPS20;
|
||||||
|
case 33000:
|
||||||
|
return BPS33;
|
||||||
|
case 50000:
|
||||||
|
return BPS50;
|
||||||
|
case 62000:
|
||||||
|
return BPS62;
|
||||||
|
case 83000:
|
||||||
|
return BPS83;
|
||||||
|
case 100000:
|
||||||
|
return BPS100;
|
||||||
|
case 125000:
|
||||||
|
return BPS125;
|
||||||
|
case 250000:
|
||||||
|
return BPS250;
|
||||||
|
case 500000:
|
||||||
|
return BPS500;
|
||||||
|
case 800000:
|
||||||
|
return BPS800;
|
||||||
|
case 1000000:
|
||||||
|
return BPS1000;
|
||||||
|
case 666000:
|
||||||
|
return BPS666;
|
||||||
|
case 2000000:
|
||||||
|
return BPS2000;
|
||||||
|
case 4000000:
|
||||||
|
return BPS4000;
|
||||||
|
case 5000000:
|
||||||
|
return CAN_BPS5000;
|
||||||
|
case 6667000:
|
||||||
|
return CAN_BPS6667;
|
||||||
|
case 8000000:
|
||||||
|
return CAN_BPS8000;
|
||||||
|
case 10000000:
|
||||||
|
return CAN_BPS10000;
|
||||||
|
default:
|
||||||
|
return (CANBaudrate)-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t IDeviceSettings::GetBaudrateValueForEnum(CANBaudrate enumValue) {
|
||||||
|
switch(enumValue) {
|
||||||
|
case BPS20:
|
||||||
|
return 20000;
|
||||||
|
case BPS33:
|
||||||
|
return 33000;
|
||||||
|
case BPS50:
|
||||||
|
return 50000;
|
||||||
|
case BPS62:
|
||||||
|
return 62000;
|
||||||
|
case BPS83:
|
||||||
|
return 83000;
|
||||||
|
case BPS100:
|
||||||
|
return 100000;
|
||||||
|
case BPS125:
|
||||||
|
return 125000;
|
||||||
|
case BPS250:
|
||||||
|
return 250000;
|
||||||
|
case BPS500:
|
||||||
|
return 500000;
|
||||||
|
case BPS800:
|
||||||
|
return 800000;
|
||||||
|
case BPS1000:
|
||||||
|
return 1000000;
|
||||||
|
case BPS666:
|
||||||
|
return 666000;
|
||||||
|
case BPS2000:
|
||||||
|
return 2000000;
|
||||||
|
case BPS4000:
|
||||||
|
return 4000000;
|
||||||
|
case CAN_BPS5000:
|
||||||
|
return 5000000;
|
||||||
|
case CAN_BPS6667:
|
||||||
|
return 6667000;
|
||||||
|
case CAN_BPS8000:
|
||||||
|
return 8000000;
|
||||||
|
case CAN_BPS10000:
|
||||||
|
return 10000000;
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
||||||
if(disabled) {
|
if(disabled) {
|
||||||
err(APIError::SettingsNotAvailable);
|
err(APIError::SettingsNotAvailable);
|
||||||
|
|
@ -186,7 +272,27 @@ bool IDeviceSettings::applyDefaults(bool temporary) {
|
||||||
return (msg && msg->data[0] == 1); // Device sends 0x01 for success
|
return (msg && msg->data[0] == 1); // Device sends 0x01 for success
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IDeviceSettings::setBaudrateFor(Network net, uint32_t baudrate) {
|
int64_t IDeviceSettings::getBaudrateFor(Network net) const {
|
||||||
|
if(disabled)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
switch(net.getType()) {
|
||||||
|
case Network::Type::CAN: {
|
||||||
|
const CAN_SETTINGS* cfg = getCANSettingsFor(net);
|
||||||
|
if(cfg == nullptr)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int64_t baudrate = GetBaudrateValueForEnum((CANBaudrate)cfg->Baudrate);
|
||||||
|
if(baudrate == -1)
|
||||||
|
return -1;
|
||||||
|
return baudrate;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setBaudrateFor(Network net, int64_t baudrate) {
|
||||||
if(disabled || readonly)
|
if(disabled || readonly)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -199,10 +305,10 @@ bool IDeviceSettings::setBaudrateFor(Network net, uint32_t baudrate) {
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t newBaud = getEnumValueForBaudrate(baudrate);
|
CANBaudrate newBaud = GetEnumValueForBaudrate(baudrate);
|
||||||
if(newBaud == 0xFF)
|
if(newBaud == (CANBaudrate)-1)
|
||||||
return false;
|
return false;
|
||||||
cfg->Baudrate = newBaud;
|
cfg->Baudrate = (uint8_t)newBaud;
|
||||||
cfg->auto_baud = false;
|
cfg->auto_baud = false;
|
||||||
cfg->SetBaudrate = AUTO; // Device will use the baudrate value to set the TQ values
|
cfg->SetBaudrate = AUTO; // Device will use the baudrate value to set the TQ values
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -212,7 +318,27 @@ bool IDeviceSettings::setBaudrateFor(Network net, uint32_t baudrate) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IDeviceSettings::setFDBaudrateFor(Network net, uint32_t baudrate) {
|
int64_t IDeviceSettings::getFDBaudrateFor(Network net) const {
|
||||||
|
if(disabled)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
switch(net.getType()) {
|
||||||
|
case Network::Type::CAN: {
|
||||||
|
const CANFD_SETTINGS* cfg = getCANFDSettingsFor(net);
|
||||||
|
if(cfg == nullptr)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int64_t baudrate = GetBaudrateValueForEnum((CANBaudrate)cfg->FDBaudrate);
|
||||||
|
if(baudrate == -1)
|
||||||
|
return -1;
|
||||||
|
return baudrate;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setFDBaudrateFor(Network net, int64_t baudrate) {
|
||||||
if(disabled || readonly)
|
if(disabled || readonly)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -222,10 +348,10 @@ bool IDeviceSettings::setFDBaudrateFor(Network net, uint32_t baudrate) {
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint8_t newBaud = getEnumValueForBaudrate(baudrate);
|
CANBaudrate newBaud = GetEnumValueForBaudrate(baudrate);
|
||||||
if(newBaud == 0xFF)
|
if(newBaud == (CANBaudrate)-1)
|
||||||
return false;
|
return false;
|
||||||
cfg->FDBaudrate = newBaud;
|
cfg->FDBaudrate = (uint8_t)newBaud;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
@ -246,46 +372,3 @@ template<typename T> bool IDeviceSettings::setStructure(const T& newStructure) {
|
||||||
memcpy(settings.data(), &newStructure, structSize);
|
memcpy(settings.data(), &newStructure, structSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t IDeviceSettings::getEnumValueForBaudrate(uint32_t baudrate) {
|
|
||||||
switch(baudrate) {
|
|
||||||
case 20000:
|
|
||||||
return BPS20;
|
|
||||||
case 33000:
|
|
||||||
return BPS33;
|
|
||||||
case 50000:
|
|
||||||
return BPS50;
|
|
||||||
case 62000:
|
|
||||||
return BPS62;
|
|
||||||
case 83000:
|
|
||||||
return BPS83;
|
|
||||||
case 100000:
|
|
||||||
return BPS100;
|
|
||||||
case 125000:
|
|
||||||
return BPS125;
|
|
||||||
case 250000:
|
|
||||||
return BPS250;
|
|
||||||
case 500000:
|
|
||||||
return BPS500;
|
|
||||||
case 800000:
|
|
||||||
return BPS800;
|
|
||||||
case 1000000:
|
|
||||||
return BPS1000;
|
|
||||||
case 666000:
|
|
||||||
return BPS666;
|
|
||||||
case 2000000:
|
|
||||||
return BPS2000;
|
|
||||||
case 4000000:
|
|
||||||
return BPS4000;
|
|
||||||
case 5000000:
|
|
||||||
return CAN_BPS5000;
|
|
||||||
case 6667000:
|
|
||||||
return CAN_BPS6667;
|
|
||||||
case 8000000:
|
|
||||||
return CAN_BPS8000;
|
|
||||||
case 10000000:
|
|
||||||
return CAN_BPS10000;
|
|
||||||
default:
|
|
||||||
return 0xFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -13,7 +13,7 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Baudrate in CAN_SETTINGS/CANFD_SETTINGS */
|
/* Baudrate in CAN_SETTINGS/CANFD_SETTINGS */
|
||||||
enum
|
enum CANBaudrate
|
||||||
{
|
{
|
||||||
BPS20,
|
BPS20,
|
||||||
BPS33,
|
BPS33,
|
||||||
|
|
@ -282,6 +282,8 @@ class IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
static constexpr uint16_t GS_VERSION = 5;
|
static constexpr uint16_t GS_VERSION = 5;
|
||||||
static uint16_t CalculateGSChecksum(const std::vector<uint8_t>& settings);
|
static uint16_t CalculateGSChecksum(const std::vector<uint8_t>& settings);
|
||||||
|
static CANBaudrate GetEnumValueForBaudrate(int64_t baudrate);
|
||||||
|
static int64_t GetBaudrateValueForEnum(CANBaudrate enumValue);
|
||||||
|
|
||||||
IDeviceSettings(std::shared_ptr<Communication> com, size_t size) : com(com), err(com->err), structSize(size) {}
|
IDeviceSettings(std::shared_ptr<Communication> com, size_t size) : com(com), err(com->err), structSize(size) {}
|
||||||
virtual ~IDeviceSettings() {}
|
virtual ~IDeviceSettings() {}
|
||||||
|
|
@ -293,19 +295,29 @@ public:
|
||||||
bool apply(bool temporary = false);
|
bool apply(bool temporary = false);
|
||||||
bool applyDefaults(bool temporary = false);
|
bool applyDefaults(bool temporary = false);
|
||||||
|
|
||||||
virtual bool setBaudrateFor(Network net, uint32_t baudrate);
|
virtual int64_t getBaudrateFor(Network net) const;
|
||||||
virtual bool setFDBaudrateFor(Network net, uint32_t baudrate);
|
virtual bool setBaudrateFor(Network net, int64_t baudrate);
|
||||||
|
|
||||||
virtual CAN_SETTINGS* getCANSettingsFor(Network net) { (void)net; return nullptr; }
|
virtual int64_t getFDBaudrateFor(Network net) const;
|
||||||
virtual CANFD_SETTINGS* getCANFDSettingsFor(Network net) { (void)net; return nullptr; }
|
virtual bool setFDBaudrateFor(Network net, int64_t baudrate);
|
||||||
|
|
||||||
|
virtual const CAN_SETTINGS* getCANSettingsFor(Network net) const { (void)net; return nullptr; }
|
||||||
|
CAN_SETTINGS* getCANSettingsFor(Network net) {
|
||||||
|
return const_cast<CAN_SETTINGS*>(static_cast<const IDeviceSettings*>(this)->getCANSettingsFor(net));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const { (void)net; return nullptr; }
|
||||||
|
CANFD_SETTINGS* getCANFDSettingsFor(Network net) {
|
||||||
|
return const_cast<CANFD_SETTINGS*>(static_cast<const IDeviceSettings*>(this)->getCANFDSettingsFor(net));
|
||||||
|
}
|
||||||
|
|
||||||
|
const void* getRawStructurePointer() const { return settings.data(); }
|
||||||
void* getRawStructurePointer() { return settings.data(); }
|
void* getRawStructurePointer() { return settings.data(); }
|
||||||
template<typename T> T* getStructurePointer() { return static_cast<T*>((void*)settings.data()); }
|
template<typename T> const T* getStructurePointer() const { return static_cast<const T*>(getRawStructurePointer()); }
|
||||||
template<typename T> T getStructureCopy() { return *getStructurePointer<T>(); }
|
template<typename T> T* getStructurePointer() { return static_cast<T*>(getRawStructurePointer()); }
|
||||||
|
template<typename T> T getStructureCopy() const { return *getStructurePointer<T>(); }
|
||||||
template<typename T> bool setStructure(const T& newStructure);
|
template<typename T> bool setStructure(const T& newStructure);
|
||||||
|
|
||||||
uint8_t getEnumValueForBaudrate(uint32_t baudrate);
|
|
||||||
|
|
||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
bool readonly = false;
|
bool readonly = false;
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ typedef struct {
|
||||||
class NeoVIFIRESettings : public IDeviceSettings {
|
class NeoVIFIRESettings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
NeoVIFIRESettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire_settings_t)) {}
|
NeoVIFIRESettings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire_settings_t)) {}
|
||||||
CAN_SETTINGS* getCANSettingsFor(Network net) override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<neovifire_settings_t>();
|
auto cfg = getStructurePointer<neovifire_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ typedef struct {
|
||||||
class NeoVIFIRE2Settings : public IDeviceSettings {
|
class NeoVIFIRE2Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
NeoVIFIRE2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire2_settings_t)) {}
|
NeoVIFIRE2Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(neovifire2_settings_t)) {}
|
||||||
CAN_SETTINGS* getCANSettingsFor(Network net) override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<neovifire2_settings_t>();
|
auto cfg = getStructurePointer<neovifire2_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
@ -137,7 +137,7 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CANFD_SETTINGS* getCANFDSettingsFor(Network net) override {
|
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<neovifire2_settings_t>();
|
auto cfg = getStructurePointer<neovifire2_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ typedef struct {
|
||||||
class ValueCAN3Settings : public IDeviceSettings {
|
class ValueCAN3Settings : public IDeviceSettings {
|
||||||
public:
|
public:
|
||||||
ValueCAN3Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(valuecan3_settings_t)) {}
|
ValueCAN3Settings(std::shared_ptr<Communication> com) : IDeviceSettings(com, sizeof(valuecan3_settings_t)) {}
|
||||||
CAN_SETTINGS* getCANSettingsFor(Network net) override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan3_settings_t>();
|
auto cfg = getStructurePointer<valuecan3_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace icsneo {
|
||||||
class ValueCAN4_1Settings : public ValueCAN4_1_2Settings {
|
class ValueCAN4_1Settings : public ValueCAN4_1_2Settings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_1Settings(std::shared_ptr<Communication> com) : ValueCAN4_1_2Settings(com) {}
|
ValueCAN4_1Settings(std::shared_ptr<Communication> com) : ValueCAN4_1_2Settings(com) {}
|
||||||
CAN_SETTINGS* getCANSettingsFor(Network net) override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace icsneo {
|
||||||
class ValueCAN4_2ELSettings : public ValueCAN4_4_2ELSettings {
|
class ValueCAN4_2ELSettings : public ValueCAN4_4_2ELSettings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_2ELSettings(std::shared_ptr<Communication> com) : ValueCAN4_4_2ELSettings(com) {}
|
ValueCAN4_2ELSettings(std::shared_ptr<Communication> com) : ValueCAN4_4_2ELSettings(com) {}
|
||||||
CAN_SETTINGS* getCANSettingsFor(Network net) override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
@ -22,7 +22,7 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CANFD_SETTINGS* getCANFDSettingsFor(Network net) override {
|
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace icsneo {
|
||||||
class ValueCAN4_2Settings : public ValueCAN4_1_2Settings {
|
class ValueCAN4_2Settings : public ValueCAN4_1_2Settings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_2Settings(std::shared_ptr<Communication> com) : ValueCAN4_1_2Settings(com) {}
|
ValueCAN4_2Settings(std::shared_ptr<Communication> com) : ValueCAN4_1_2Settings(com) {}
|
||||||
CAN_SETTINGS* getCANSettingsFor(Network net) override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
@ -21,7 +21,7 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CANFD_SETTINGS* getCANFDSettingsFor(Network net) override {
|
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace icsneo {
|
||||||
class ValueCAN4_4Settings : public ValueCAN4_4_2ELSettings {
|
class ValueCAN4_4Settings : public ValueCAN4_4_2ELSettings {
|
||||||
public:
|
public:
|
||||||
ValueCAN4_4Settings(std::shared_ptr<Communication> com) : ValueCAN4_4_2ELSettings(com) {}
|
ValueCAN4_4Settings(std::shared_ptr<Communication> com) : ValueCAN4_4_2ELSettings(com) {}
|
||||||
CAN_SETTINGS* getCANSettingsFor(Network net) override {
|
const CAN_SETTINGS* getCANSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CANFD_SETTINGS* getCANFDSettingsFor(Network net) override {
|
const CANFD_SETTINGS* getCANFDSettingsFor(Network net) const override {
|
||||||
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
||||||
switch(net.getNetID()) {
|
switch(net.getNetID()) {
|
||||||
case Network::NetID::HSCAN:
|
case Network::NetID::HSCAN:
|
||||||
|
|
|
||||||
|
|
@ -357,6 +357,17 @@ extern bool DLLExport icsneo_settingsApplyDefaults(const neodevice_t* device);
|
||||||
*/
|
*/
|
||||||
extern bool DLLExport icsneo_settingsApplyDefaultsTemporary(const neodevice_t* device);
|
extern bool DLLExport icsneo_settingsApplyDefaultsTemporary(const neodevice_t* device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the network baudrate for a specified device.
|
||||||
|
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
||||||
|
* \param[in] netid The network for which the baudrate should be retrieved.
|
||||||
|
* \returns The value in baud with no multipliers. (i.e. 500k becomes 500000) A negative value is returned if an error occurs.
|
||||||
|
*
|
||||||
|
* 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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the network baudrate for a specified device.
|
* \brief Set the network baudrate for a specified device.
|
||||||
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
||||||
|
|
@ -369,7 +380,17 @@ extern bool DLLExport icsneo_settingsApplyDefaultsTemporary(const neodevice_t* d
|
||||||
*
|
*
|
||||||
* Call icsneo_settingsApply() or similar to make the changes active on the device.
|
* 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, uint32_t newBaudrate);
|
extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, int64_t newBaudrate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the CAN FD baudrate for a specified device.
|
||||||
|
* \param[in] device A pointer to the neodevice_t structure specifying the device to operate on.
|
||||||
|
* \param[in] netid The network for which the baudrate should be retrieved.
|
||||||
|
* \returns The value in baud with no multipliers. (i.e. 500k becomes 500000) A negative value is returned if an error occurs.
|
||||||
|
*
|
||||||
|
* 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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Set the CAN FD baudrate for a specified device.
|
* \brief Set the CAN FD baudrate for a specified device.
|
||||||
|
|
@ -378,9 +399,11 @@ extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, uint16_t net
|
||||||
* \param[in] newBaudrate The requested baudrate, with no multipliers. (i.e. 2Mbaud CAN FD should be represented as 2000000)
|
* \param[in] newBaudrate The requested baudrate, with no multipliers. (i.e. 2Mbaud CAN FD should be represented as 2000000)
|
||||||
* \returns True if the baudrate could be set.
|
* \returns True if the baudrate could be set.
|
||||||
*
|
*
|
||||||
|
* See icsneo_setBaudrate() to set the baudrate for the non baudrate-switched portion of CAN FD, classical CAN 2.0, and other network types.
|
||||||
|
*
|
||||||
* Call icsneo_settingsApply() or similar to make the changes active on the device.
|
* 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, uint32_t newBaudrate);
|
extern bool DLLExport icsneo_setFDBaudrate(const neodevice_t* device, uint16_t netid, int64_t newBaudrate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Transmit a single message.
|
* \brief Transmit a single message.
|
||||||
|
|
@ -626,10 +649,16 @@ fn_icsneo_settingsApplyDefaults icsneo_settingsApplyDefaults;
|
||||||
typedef bool(*fn_icsneo_settingsApplyDefaultsTemporary)(const neodevice_t* device);
|
typedef bool(*fn_icsneo_settingsApplyDefaultsTemporary)(const neodevice_t* device);
|
||||||
fn_icsneo_settingsApplyDefaultsTemporary icsneo_settingsApplyDefaultsTemporary;
|
fn_icsneo_settingsApplyDefaultsTemporary icsneo_settingsApplyDefaultsTemporary;
|
||||||
|
|
||||||
typedef bool(*fn_icsneo_setBaudrate)(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate);
|
typedef int64_t(*fn_icsneo_getBaudrate)(const neodevice_t* device, uint16_t netid);
|
||||||
|
fn_icsneo_getBaudrate icsneo_getBaudrate;
|
||||||
|
|
||||||
|
typedef bool(*fn_icsneo_setBaudrate)(const neodevice_t* device, uint16_t netid, int64_t newBaudrate);
|
||||||
fn_icsneo_setBaudrate icsneo_setBaudrate;
|
fn_icsneo_setBaudrate icsneo_setBaudrate;
|
||||||
|
|
||||||
typedef bool(*fn_icsneo_setFDBaudrate)(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate);
|
typedef int64_t(*fn_icsneo_getFDBaudrate)(const neodevice_t* device, uint16_t netid);
|
||||||
|
fn_icsneo_getFDBaudrate icsneo_getFDBaudrate;
|
||||||
|
|
||||||
|
typedef bool(*fn_icsneo_setFDBaudrate)(const neodevice_t* device, uint16_t netid, int64_t newBaudrate);
|
||||||
fn_icsneo_setFDBaudrate icsneo_setFDBaudrate;
|
fn_icsneo_setFDBaudrate icsneo_setFDBaudrate;
|
||||||
|
|
||||||
typedef bool(*fn_icsneo_transmit)(const neodevice_t* device, const neomessage_t* message);
|
typedef bool(*fn_icsneo_transmit)(const neodevice_t* device, const neomessage_t* message);
|
||||||
|
|
@ -700,7 +729,9 @@ int icsneo_init() {
|
||||||
ICSNEO_IMPORTASSERT(icsneo_settingsApplyTemporary);
|
ICSNEO_IMPORTASSERT(icsneo_settingsApplyTemporary);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaults);
|
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaults);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaultsTemporary);
|
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaultsTemporary);
|
||||||
|
ICSNEO_IMPORTASSERT(icsneo_getBaudrate);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_setBaudrate);
|
ICSNEO_IMPORTASSERT(icsneo_setBaudrate);
|
||||||
|
ICSNEO_IMPORTASSERT(icsneo_getFDBaudrate);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_setFDBaudrate);
|
ICSNEO_IMPORTASSERT(icsneo_setFDBaudrate);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_transmit);
|
ICSNEO_IMPORTASSERT(icsneo_transmit);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_transmitMessages);
|
ICSNEO_IMPORTASSERT(icsneo_transmitMessages);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue