mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Legacy API can receive CAN now
This commit is contained in:
+2
-1
@@ -106,7 +106,8 @@ bool Device::getMessages(std::vector<std::shared_ptr<Message>>& container, size_
|
||||
|
||||
size_t actuallyRead = pollingContainer.try_dequeue_bulk(container.data(), limit);
|
||||
|
||||
container.resize(actuallyRead);
|
||||
if(container.size() > actuallyRead)
|
||||
container.resize(actuallyRead);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ uint16_t IDeviceSettings::CalculateGSChecksum(const std::vector<uint8_t>& settin
|
||||
return gs_crc;
|
||||
}
|
||||
|
||||
void IDeviceSettings::refresh(bool ignoreChecksum) {
|
||||
bool IDeviceSettings::refresh(bool ignoreChecksum) {
|
||||
std::vector<uint8_t> rxSettings;
|
||||
bool ret = com->getSettingsSync(rxSettings);
|
||||
if(ret) {
|
||||
if(rxSettings.size() < 6) // We need to at least have the header of GLOBAL_SETTINGS
|
||||
return;
|
||||
return false;
|
||||
|
||||
constexpr size_t gs_size = 3 * sizeof(uint16_t);
|
||||
size_t rxLen = rxSettings.size() - gs_size;
|
||||
@@ -59,17 +59,17 @@ void IDeviceSettings::refresh(bool ignoreChecksum) {
|
||||
|
||||
if(gs_version != 5) {
|
||||
std::cout << "gs_version was " << gs_version << " instead of 5.\nPlease update your firmware." << std::endl;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(rxLen != gs_len) {
|
||||
std::cout << "rxLen was " << rxLen << " and gs_len was " << gs_len << " while reading settings" << std::endl;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!ignoreChecksum && gs_chksum != CalculateGSChecksum(rxSettings)) {
|
||||
std::cout << "Checksum mismatch while reading settings" << std::endl;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
settings = std::move(rxSettings);
|
||||
@@ -79,6 +79,8 @@ void IDeviceSettings::refresh(bool ignoreChecksum) {
|
||||
std::cout << "Settings size was " << settings.size() << " bytes but it should be " << structSize << " bytes for this device" << std::endl;
|
||||
settingsLoaded = false;
|
||||
}
|
||||
|
||||
return settingsLoaded;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
virtual ~IDeviceSettings() {}
|
||||
bool ok() { return settingsLoaded; }
|
||||
|
||||
void refresh(bool ignoreChecksum = false); // Get from device
|
||||
bool refresh(bool ignoreChecksum = false); // Get from device
|
||||
|
||||
// Send to device, if temporary device keeps settings in volatile RAM until power cycle, otherwise saved to EEPROM
|
||||
bool apply(bool temporary = false);
|
||||
|
||||
@@ -21,9 +21,9 @@ typedef int32_t neodevice_handle_t;
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct {
|
||||
devicehandle_t device;
|
||||
neodevice_handle_t handle;
|
||||
devicetype_t type;
|
||||
devicehandle_t device; // Pointer back to the C++ device object
|
||||
neodevice_handle_t handle; // Handle for use by the underlying driver
|
||||
devicetype_t type;
|
||||
char serial[7];
|
||||
} neodevice_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user