Decode reset status messages
parent
d50e6040b3
commit
b3184eb1ed
|
|
@ -1,6 +1,7 @@
|
||||||
#include "communication/include/decoder.h"
|
#include "communication/include/decoder.h"
|
||||||
#include "communication/include/communication.h"
|
#include "communication/include/communication.h"
|
||||||
#include "communication/message/include/serialnumbermessage.h"
|
#include "communication/message/include/serialnumbermessage.h"
|
||||||
|
#include "communication/message/include/resetstatusmessage.h"
|
||||||
#include "communication/include/command.h"
|
#include "communication/include/command.h"
|
||||||
#include "device/include/device.h"
|
#include "device/include/device.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -33,6 +34,38 @@ std::shared_ptr<Message> Decoder::decodePacket(const std::shared_ptr<Packet>& pa
|
||||||
msg->data.push_back(data->data[i]);
|
msg->data.push_back(data->data[i]);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
case Network::Type::Internal: {
|
||||||
|
switch(packet->network.getNetID()) {
|
||||||
|
case Network::NetID::Reset_Status: {
|
||||||
|
if(packet->data.size() < sizeof(HardwareResetStatusPacket))
|
||||||
|
break;
|
||||||
|
|
||||||
|
HardwareResetStatusPacket* data = (HardwareResetStatusPacket*)packet->data.data();
|
||||||
|
auto msg = std::make_shared<ResetStatusMessage>();
|
||||||
|
msg->network = packet->network;
|
||||||
|
msg->mainLoopTime = data->main_loop_time_25ns * 25;
|
||||||
|
msg->maxMainLoopTime = data->max_main_loop_time_25ns * 25;
|
||||||
|
msg->busVoltage = data->busVoltage;
|
||||||
|
msg->deviceTemperature = data->deviceTemperature;
|
||||||
|
msg->justReset = data->status.just_reset;
|
||||||
|
msg->comEnabled = data->status.com_enabled;
|
||||||
|
msg->cmRunning = data->status.cm_is_running;
|
||||||
|
msg->cmChecksumFailed = data->status.cm_checksum_failed;
|
||||||
|
msg->cmLicenseFailed = data->status.cm_license_failed;
|
||||||
|
msg->cmVersionMismatch = data->status.cm_version_mismatch;
|
||||||
|
msg->cmBootOff = data->status.cm_boot_off;
|
||||||
|
msg->hardwareFailure = data->status.hardware_failure;
|
||||||
|
msg->usbComEnabled = data->status.usbComEnabled;
|
||||||
|
msg->linuxComEnabled = data->status.linuxComEnabled;
|
||||||
|
msg->cmTooBig = data->status.cm_too_big;
|
||||||
|
msg->hidUsbState = data->status.hidUsbState;
|
||||||
|
msg->fpgaUsbState = data->status.fpgaUsbState;
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
switch(packet->network.getNetID()) {
|
switch(packet->network.getNetID()) {
|
||||||
case Network::NetID::Main51: {
|
case Network::NetID::Main51: {
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,40 @@ private:
|
||||||
} timestamp;
|
} timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
union CoreMiniStatusBits_t {
|
||||||
|
struct {
|
||||||
|
unsigned just_reset : 1;
|
||||||
|
unsigned com_enabled : 1;
|
||||||
|
unsigned cm_is_running : 1;
|
||||||
|
unsigned cm_checksum_failed : 1;
|
||||||
|
unsigned cm_license_failed : 1;
|
||||||
|
unsigned cm_version_mismatch : 1;
|
||||||
|
unsigned cm_boot_off : 1;
|
||||||
|
unsigned hardware_failure : 1;//to check SRAM failure (for now)
|
||||||
|
unsigned isPassiveConnect : 1;///< Always zero. Set to one when neoVI connection is passive,i.e. no async traffic
|
||||||
|
unsigned usbComEnabled : 1;///< Set to one when USB Host PC has enabled communication.
|
||||||
|
unsigned linuxComEnabled : 1;///< Set to one when Android (Linux) has enabled communication.
|
||||||
|
unsigned cm_too_big : 1;
|
||||||
|
unsigned hidUsbState : 1;
|
||||||
|
unsigned fpgaUsbState : 1;
|
||||||
|
unsigned reserved : 2;
|
||||||
|
};
|
||||||
|
uint32_t dword;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HardwareResetStatusPacket {
|
||||||
|
uint16_t main_loop_time_25ns;
|
||||||
|
uint16_t max_main_loop_time_25ns;
|
||||||
|
CoreMiniStatusBits_t status;
|
||||||
|
uint8_t histo[6];//!< Can hold histogram performance data.
|
||||||
|
uint16_t spi1Kbps;//!< Spi1's kbps throughput.
|
||||||
|
uint16_t initBits;//!< Bitfield with init states of drivers, 1 is succes, 0 is fail.
|
||||||
|
uint16_t cpuMipsH;
|
||||||
|
uint16_t cpuMipsL;
|
||||||
|
uint16_t busVoltage;
|
||||||
|
uint16_t deviceTemperature;
|
||||||
|
} CoreMiniMsgResetStatus;
|
||||||
|
|
||||||
// struct CoreMiniMsg {
|
// struct CoreMiniMsg {
|
||||||
// CANMessage toCANMessage(Network netid);
|
// CANMessage toCANMessage(Network netid);
|
||||||
// union {
|
// union {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef __RESETSTATUSMESSAGE_H_
|
||||||
|
#define __RESETSTATUSMESSAGE_H_
|
||||||
|
|
||||||
|
#include "communication/message/include/main51message.h"
|
||||||
|
#include "communication/include/command.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace icsneo {
|
||||||
|
|
||||||
|
class ResetStatusMessage : public Message {
|
||||||
|
public:
|
||||||
|
ResetStatusMessage() : Message() {}
|
||||||
|
virtual ~ResetStatusMessage() = default;
|
||||||
|
uint16_t mainLoopTime;
|
||||||
|
uint16_t maxMainLoopTime;
|
||||||
|
bool justReset;
|
||||||
|
bool comEnabled;
|
||||||
|
bool cmRunning;
|
||||||
|
bool cmChecksumFailed;
|
||||||
|
bool cmLicenseFailed;
|
||||||
|
bool cmVersionMismatch;
|
||||||
|
bool cmBootOff;
|
||||||
|
bool hardwareFailure;
|
||||||
|
bool usbComEnabled;
|
||||||
|
bool linuxComEnabled;
|
||||||
|
bool cmTooBig;
|
||||||
|
bool hidUsbState;
|
||||||
|
bool fpgaUsbState;
|
||||||
|
uint16_t busVoltage;
|
||||||
|
uint16_t deviceTemperature;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -152,6 +152,10 @@ bool Device::open() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internalHandlerCallbackID = com->addMessageCallback(MessageCallback(MessageFilter(Network::Type::Internal), [this](std::shared_ptr<Message> message) {
|
||||||
|
handleInternalMessage(message);
|
||||||
|
}));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,7 +163,8 @@ bool Device::close() {
|
||||||
if(!com)
|
if(!com)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
settings = nullptr;
|
if(internalHandlerCallbackID)
|
||||||
|
com->removeMessageCallback(internalHandlerCallbackID);
|
||||||
|
|
||||||
return com->close();
|
return com->close();
|
||||||
}
|
}
|
||||||
|
|
@ -179,3 +184,13 @@ bool Device::goOffline() {
|
||||||
online = false;
|
online = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Device::handleInternalMessage(std::shared_ptr<Message> message) {
|
||||||
|
switch(message->network.getNetID()) {
|
||||||
|
case Network::NetID::Reset_Status:
|
||||||
|
latestResetStatus = std::dynamic_pointer_cast<ResetStatusMessage>(message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break; //std::cout << "HandleInternalMessage got a message from " << message->network << " and it was unhandled!" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include "communication/include/packetizer.h"
|
#include "communication/include/packetizer.h"
|
||||||
#include "communication/include/encoder.h"
|
#include "communication/include/encoder.h"
|
||||||
#include "communication/include/decoder.h"
|
#include "communication/include/decoder.h"
|
||||||
|
#include "communication/message/include/resetstatusmessage.h"
|
||||||
#include "third-party/concurrentqueue/concurrentqueue.h"
|
#include "third-party/concurrentqueue/concurrentqueue.h"
|
||||||
|
|
||||||
namespace icsneo {
|
namespace icsneo {
|
||||||
|
|
@ -54,18 +55,22 @@ public:
|
||||||
enforcePollingMessageLimit();
|
enforcePollingMessageLimit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleInternalMessage(std::shared_ptr<Message> message);
|
||||||
|
|
||||||
std::unique_ptr<IDeviceSettings> settings;
|
std::unique_ptr<IDeviceSettings> settings;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint16_t productId = 0;
|
uint16_t productId = 0;
|
||||||
bool online = false;
|
bool online = false;
|
||||||
int messagePollingCallbackID = 0;
|
int messagePollingCallbackID = 0;
|
||||||
|
int internalHandlerCallbackID = 0;
|
||||||
std::shared_ptr<Communication> com;
|
std::shared_ptr<Communication> com;
|
||||||
|
|
||||||
neodevice_t& getWritableNeoDevice() { return data; }
|
neodevice_t& getWritableNeoDevice() { return data; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
neodevice_t data;
|
neodevice_t data;
|
||||||
|
std::shared_ptr<ResetStatusMessage> latestResetStatus;
|
||||||
|
|
||||||
size_t pollingMessageLimit = 20000;
|
size_t pollingMessageLimit = 20000;
|
||||||
moodycamel::ConcurrentQueue<std::shared_ptr<Message>> pollingContainer;
|
moodycamel::ConcurrentQueue<std::shared_ptr<Message>> pollingContainer;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue