Legacy API can receive CAN now

This commit is contained in:
Paul Hollinsky
2018-10-08 21:43:32 -04:00
parent b3471890eb
commit ba9813021e
11 changed files with 142 additions and 42 deletions
+2 -1
View File
@@ -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;
}
+7 -5
View File
@@ -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;
}
}
+1 -1
View File
@@ -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);
+3 -3
View File
@@ -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;