CAN FD baudrate settings
parent
92d98f8bd5
commit
1a9c907fea
|
|
@ -323,6 +323,15 @@ 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) {
|
||||||
|
if(!icsneo_isValidNeoDevice(device)) {
|
||||||
|
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return device->device->settings->setFDBaudrateFor(netid, newBaudrate);
|
||||||
|
}
|
||||||
|
|
||||||
bool icsneo_transmit(const neodevice_t* device, const neomessage_t* message) {
|
bool icsneo_transmit(const neodevice_t* device, const neomessage_t* message) {
|
||||||
if(!icsneo_isValidNeoDevice(device)) {
|
if(!icsneo_isValidNeoDevice(device)) {
|
||||||
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
ErrorManager::GetInstance().add(APIError::InvalidNeoDevice);
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,9 @@ bool IDeviceSettings::setBaudrateFor(Network net, uint32_t baudrate) {
|
||||||
|
|
||||||
switch(net.getType()) {
|
switch(net.getType()) {
|
||||||
case Network::Type::CAN: {
|
case Network::Type::CAN: {
|
||||||
|
if(baudrate > 1000000) // This is an FD baudrate. Use setFDBaudrateFor instead.
|
||||||
|
return false;
|
||||||
|
|
||||||
CAN_SETTINGS* cfg = getCANSettingsFor(net);
|
CAN_SETTINGS* cfg = getCANSettingsFor(net);
|
||||||
if(cfg == nullptr)
|
if(cfg == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -209,6 +212,27 @@ bool IDeviceSettings::setBaudrateFor(Network net, uint32_t baudrate) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IDeviceSettings::setFDBaudrateFor(Network net, uint32_t baudrate) {
|
||||||
|
if(disabled || readonly)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch(net.getType()) {
|
||||||
|
case Network::Type::CAN: {
|
||||||
|
CANFD_SETTINGS* cfg = getCANFDSettingsFor(net);
|
||||||
|
if(cfg == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
uint8_t newBaud = getEnumValueForBaudrate(baudrate);
|
||||||
|
if(newBaud == 0xFF)
|
||||||
|
return false;
|
||||||
|
cfg->FDBaudrate = newBaud;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T> bool IDeviceSettings::setStructure(const T& newStructure) {
|
template<typename T> bool IDeviceSettings::setStructure(const T& newStructure) {
|
||||||
if(disabled || readonly)
|
if(disabled || readonly)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,7 @@ public:
|
||||||
bool applyDefaults(bool temporary = false);
|
bool applyDefaults(bool temporary = false);
|
||||||
|
|
||||||
virtual bool setBaudrateFor(Network net, uint32_t baudrate);
|
virtual bool setBaudrateFor(Network net, uint32_t baudrate);
|
||||||
|
virtual bool setFDBaudrateFor(Network net, uint32_t baudrate);
|
||||||
|
|
||||||
virtual CAN_SETTINGS* getCANSettingsFor(Network net) { (void)net; return nullptr; }
|
virtual CAN_SETTINGS* getCANSettingsFor(Network net) { (void)net; return nullptr; }
|
||||||
virtual CANFD_SETTINGS* getCANFDSettingsFor(Network net) { (void)net; return nullptr; }
|
virtual CANFD_SETTINGS* getCANFDSettingsFor(Network net) { (void)net; return nullptr; }
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,29 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
|
CANFD_SETTINGS* getCANFDSettingsFor(Network net) override {
|
||||||
|
auto cfg = getStructurePointer<neovifire2_settings_t>();
|
||||||
|
switch(net.getNetID()) {
|
||||||
|
case Network::NetID::HSCAN:
|
||||||
|
return &(cfg->canfd1);
|
||||||
|
case Network::NetID::MSCAN:
|
||||||
|
return &(cfg->canfd2);
|
||||||
|
case Network::NetID::HSCAN2:
|
||||||
|
return &(cfg->canfd3);
|
||||||
|
case Network::NetID::HSCAN3:
|
||||||
|
return &(cfg->canfd4);
|
||||||
|
case Network::NetID::HSCAN4:
|
||||||
|
return &(cfg->canfd5);
|
||||||
|
case Network::NetID::HSCAN5:
|
||||||
|
return &(cfg->canfd6);
|
||||||
|
case Network::NetID::HSCAN6:
|
||||||
|
return &(cfg->canfd7);
|
||||||
|
case Network::NetID::HSCAN7:
|
||||||
|
return &(cfg->canfd8);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,21 @@ public:
|
||||||
return &(cfg->can1);
|
return &(cfg->can1);
|
||||||
case Network::NetID::HSCAN2:
|
case Network::NetID::HSCAN2:
|
||||||
return &(cfg->can2);
|
return &(cfg->can2);
|
||||||
case Network::NetID::HSCAN3:
|
|
||||||
return &(cfg->can3);
|
|
||||||
case Network::NetID::HSCAN4:
|
|
||||||
return &(cfg->can4);
|
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
|
CANFD_SETTINGS* getCANFDSettingsFor(Network net) override {
|
||||||
|
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
||||||
|
switch(net.getNetID()) {
|
||||||
|
case Network::NetID::HSCAN:
|
||||||
|
return &(cfg->canfd1);
|
||||||
|
case Network::NetID::HSCAN2:
|
||||||
|
return &(cfg->canfd2);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,17 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
|
CANFD_SETTINGS* getCANFDSettingsFor(Network net) override {
|
||||||
|
auto cfg = getStructurePointer<valuecan4_1_2_settings_t>();
|
||||||
|
switch(net.getNetID()) {
|
||||||
|
case Network::NetID::HSCAN:
|
||||||
|
return &(cfg->canfd1);
|
||||||
|
case Network::NetID::HSCAN2:
|
||||||
|
return &(cfg->canfd2);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,21 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// CANFD_SETTINGS* getCANFDSettingsFor(Network net) override { return nullptr; }
|
CANFD_SETTINGS* getCANFDSettingsFor(Network net) override {
|
||||||
|
auto cfg = getStructurePointer<valuecan4_4_2el_settings_t>();
|
||||||
|
switch(net.getNetID()) {
|
||||||
|
case Network::NetID::HSCAN:
|
||||||
|
return &(cfg->canfd1);
|
||||||
|
case Network::NetID::HSCAN2:
|
||||||
|
return &(cfg->canfd2);
|
||||||
|
case Network::NetID::HSCAN3:
|
||||||
|
return &(cfg->canfd3);
|
||||||
|
case Network::NetID::HSCAN4:
|
||||||
|
return &(cfg->canfd4);
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ extern bool DLLExport icsneo_settingsApplyDefaultsTemporary(const neodevice_t* d
|
||||||
|
|
||||||
extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate);
|
extern bool DLLExport icsneo_setBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate);
|
||||||
|
|
||||||
|
extern bool DLLExport icsneo_setFDBaudrate(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate);
|
||||||
|
|
||||||
extern bool DLLExport icsneo_transmit(const neodevice_t* device, const neomessage_t* message);
|
extern bool DLLExport icsneo_transmit(const neodevice_t* device, const neomessage_t* message);
|
||||||
|
|
||||||
extern bool DLLExport icsneo_transmitMessages(const neodevice_t* device, const neomessage_t* messages, size_t count);
|
extern bool DLLExport icsneo_transmitMessages(const neodevice_t* device, const neomessage_t* messages, size_t count);
|
||||||
|
|
@ -138,6 +140,9 @@ fn_icsneo_settingsApplyDefaultsTemporary icsneo_settingsApplyDefaultsTemporary;
|
||||||
typedef bool(*fn_icsneo_setBaudrate)(const neodevice_t* device, uint16_t netid, uint32_t newBaudrate);
|
typedef bool(*fn_icsneo_setBaudrate)(const neodevice_t* device, uint16_t netid, uint32_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);
|
||||||
|
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);
|
||||||
fn_icsneo_transmit icsneo_transmit;
|
fn_icsneo_transmit icsneo_transmit;
|
||||||
|
|
||||||
|
|
@ -186,6 +191,7 @@ int icsneo_init() {
|
||||||
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaults);
|
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaults);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaultsTemporary);
|
ICSNEO_IMPORTASSERT(icsneo_settingsApplyDefaultsTemporary);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_setBaudrate);
|
ICSNEO_IMPORTASSERT(icsneo_setBaudrate);
|
||||||
|
ICSNEO_IMPORTASSERT(icsneo_setFDBaudrate);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_transmit);
|
ICSNEO_IMPORTASSERT(icsneo_transmit);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_transmitMessages);
|
ICSNEO_IMPORTASSERT(icsneo_transmitMessages);
|
||||||
ICSNEO_IMPORTASSERT(icsneo_describeDevice);
|
ICSNEO_IMPORTASSERT(icsneo_describeDevice);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue