Resolve compilation errors and warnings with MSVC
parent
f05f96822e
commit
0cf1e7fe7f
|
|
@ -17,11 +17,11 @@ APIError::APIError(ErrorType error, const Device* forDevice) : errorStruct({}) {
|
|||
}
|
||||
|
||||
void APIError::init(ErrorType error) {
|
||||
timepoint = std::chrono::high_resolution_clock::now();
|
||||
timepoint = ErrorClock::now();
|
||||
errorStruct.description = DescriptionForType(error);
|
||||
errorStruct.errorNumber = (uint32_t)error;
|
||||
errorStruct.severity = (uint8_t)SeverityForType(error);
|
||||
errorStruct.timestamp = std::chrono::high_resolution_clock::to_time_t(timepoint);
|
||||
errorStruct.timestamp = ErrorClock::to_time_t(timepoint);
|
||||
}
|
||||
|
||||
std::string APIError::describe() const noexcept {
|
||||
|
|
@ -35,10 +35,10 @@ std::string APIError::describe() const noexcept {
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
bool APIError::isForDevice(std::string serial) const noexcept {
|
||||
if(!device || serial.length() == 0)
|
||||
bool APIError::isForDevice(std::string filterSerial) const noexcept {
|
||||
if(!device || filterSerial.length() == 0)
|
||||
return false;
|
||||
return device->getSerial() == serial;
|
||||
return device->getSerial() == filterSerial;
|
||||
}
|
||||
|
||||
// API Errors
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ class Device;
|
|||
|
||||
class APIError {
|
||||
public:
|
||||
typedef std::chrono::system_clock ErrorClock;
|
||||
typedef std::chrono::time_point<ErrorClock> ErrorTimePoint;
|
||||
|
||||
enum ErrorType : uint32_t {
|
||||
Any = 0, // Used for filtering, should not appear in data
|
||||
|
||||
|
|
@ -73,7 +76,7 @@ public:
|
|||
Severity getSeverity() const noexcept { return Severity(errorStruct.severity); }
|
||||
std::string getDescription() const noexcept { return std::string(errorStruct.description); }
|
||||
const Device* getDevice() const noexcept { return device; } // Will return nullptr if this is an API-wide error
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> getTimestamp() const noexcept { return timepoint; }
|
||||
ErrorTimePoint getTimestamp() const noexcept { return timepoint; }
|
||||
|
||||
bool isForDevice(const Device* forDevice) const noexcept { return forDevice == device; }
|
||||
bool isForDevice(std::string serial) const noexcept;
|
||||
|
|
@ -91,7 +94,7 @@ public:
|
|||
private:
|
||||
neoerror_t errorStruct;
|
||||
std::string serial;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> timepoint;
|
||||
ErrorTimePoint timepoint;
|
||||
const Device* device;
|
||||
|
||||
void init(ErrorType error);
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ public:
|
|||
get(ret, filter, max);
|
||||
return ret;
|
||||
}
|
||||
void get(std::vector<APIError>& errors, ErrorFilter filter, size_t max = 0) { get(errors, max, filter); }
|
||||
void get(std::vector<APIError>& errors, size_t max = 0, ErrorFilter filter = ErrorFilter());
|
||||
bool getLastError(APIError& error, ErrorFilter filter = ErrorFilter());
|
||||
void get(std::vector<APIError>& outErrors, ErrorFilter filter, size_t max = 0) { get(outErrors, max, filter); }
|
||||
void get(std::vector<APIError>& outErrors, size_t max = 0, ErrorFilter filter = ErrorFilter());
|
||||
bool getLastError(APIError& outErrors, ErrorFilter filter = ErrorFilter());
|
||||
|
||||
void add(APIError error) {
|
||||
std::lock_guard<std::mutex> lk(mutex);
|
||||
|
|
|
|||
|
|
@ -103,29 +103,29 @@ protected:
|
|||
|
||||
template<typename Transport>
|
||||
std::unique_ptr<ICommunication> makeTransport() { return std::unique_ptr<ICommunication>(new Transport(err, getWritableNeoDevice())); }
|
||||
virtual void setupTransport(ICommunication* transport) {}
|
||||
virtual void setupTransport(ICommunication* stransport) { (void)stransport; }
|
||||
|
||||
virtual std::shared_ptr<Packetizer> makePacketizer() { return std::make_shared<Packetizer>(err); }
|
||||
virtual void setupPacketizer(Packetizer* packetizer) {}
|
||||
virtual void setupPacketizer(Packetizer* spacketizer) { (void)spacketizer; }
|
||||
|
||||
virtual std::unique_ptr<Encoder> makeEncoder(std::shared_ptr<Packetizer> p) { return std::unique_ptr<Encoder>(new Encoder(err, p)); }
|
||||
virtual void setupEncoder(Encoder* encoder) {}
|
||||
virtual void setupEncoder(Encoder* sencoder) { (void)sencoder; }
|
||||
|
||||
virtual std::unique_ptr<Decoder> makeDecoder() { return std::unique_ptr<Decoder>(new Decoder(err)); }
|
||||
virtual void setupDecoder(Decoder* decoder) {}
|
||||
virtual void setupDecoder(Decoder* sdecoder) { (void)sdecoder; }
|
||||
|
||||
virtual std::shared_ptr<Communication> makeCommunication(
|
||||
std::unique_ptr<ICommunication> t,
|
||||
std::shared_ptr<Packetizer> p,
|
||||
std::unique_ptr<Encoder> e,
|
||||
std::unique_ptr<Decoder> d) { return std::make_shared<Communication>(err, std::move(t), p, std::move(e), std::move(d)); }
|
||||
virtual void setupCommunication(Communication* com) {}
|
||||
virtual void setupCommunication(Communication* scom) { (void)scom; }
|
||||
|
||||
template<typename Settings>
|
||||
std::unique_ptr<IDeviceSettings> makeSettings(std::shared_ptr<Communication> com) {
|
||||
return std::unique_ptr<IDeviceSettings>(new Settings(com));
|
||||
}
|
||||
virtual void setupSettings(IDeviceSettings* settings) {}
|
||||
virtual void setupSettings(IDeviceSettings* ssettings) { (void)ssettings; }
|
||||
// END Initialization Functions
|
||||
|
||||
void handleInternalMessage(std::shared_ptr<Message> message);
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@ public:
|
|||
std::vector<std::shared_ptr<Device>> found;
|
||||
|
||||
for(auto& foundDev : PCAP::FindAll()) {
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::unique_ptr<Decoder>(new Decoder());
|
||||
for(auto& payload : foundDev.discoveryPackets)
|
||||
packetizer->input(payload);
|
||||
for(auto& packet : packetizer->output()) {
|
||||
auto fakedev = std::shared_ptr<NeoVIFIRE2ETH>(new NeoVIFIRE2ETH({}));
|
||||
for (auto& payload : foundDev.discoveryPackets)
|
||||
fakedev->com->packetizer->input(payload);
|
||||
for (auto& packet : fakedev->com->packetizer->output()) {
|
||||
std::shared_ptr<Message> msg;
|
||||
if(!decoder->decode(msg, packet))
|
||||
if (!fakedev->com->decoder->decode(msg, packet))
|
||||
continue; // We failed to decode this packet
|
||||
|
||||
if(!msg || msg->network.getNetID() != Network::NetID::Main51)
|
||||
|
|
@ -44,17 +43,16 @@ public:
|
|||
return found;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void setupSettings(IDeviceSettings* settings) {
|
||||
// TODO Check firmware version, old firmwares will reset Ethernet settings on settings send
|
||||
settings->readonly = true;
|
||||
}
|
||||
|
||||
private:
|
||||
NeoVIFIRE2ETH(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
initialize<PCAP, NeoVIFIRE2Settings>();
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void setupSettings(IDeviceSettings* ssettings) {
|
||||
// TODO Check firmware version, old firmwares will reset Ethernet settings on settings send
|
||||
ssettings->readonly = true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,18 +47,17 @@ public:
|
|||
return found;
|
||||
}
|
||||
|
||||
protected:
|
||||
void setupPacketizer(Packetizer* packetizer) override {
|
||||
packetizer->disableChecksum = true;
|
||||
packetizer->align16bit = false;
|
||||
}
|
||||
|
||||
private:
|
||||
RADGalaxy(neodevice_t neodevice) : Device(neodevice) {
|
||||
initialize<PCAP>();
|
||||
getWritableNeoDevice().type = DEVICE_TYPE;
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
||||
protected:
|
||||
void setupPacketizer(Packetizer* packetizer) override {
|
||||
packetizer->disableChecksum = true;
|
||||
packetizer->align16bit = false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ public:
|
|||
return found;
|
||||
}
|
||||
|
||||
private:
|
||||
RADStar2ETH(neodevice_t neodevice) : RADStar2(neodevice) {
|
||||
initialize<PCAP>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public:
|
|||
bool close();
|
||||
private:
|
||||
PCAPDLL pcap;
|
||||
device_errorhandler_t err;
|
||||
char errbuf[PCAP_ERRBUF_SIZE] = { 0 };
|
||||
neodevice_t& device;
|
||||
uint8_t deviceMAC[6];
|
||||
|
|
|
|||
|
|
@ -270,7 +270,6 @@ void VCP::readTask() {
|
|||
case WAIT: {
|
||||
auto ret = WaitForSingleObject(overlappedRead.hEvent, 100);
|
||||
if(ret == WAIT_OBJECT_0) {
|
||||
auto err = GetLastError();
|
||||
if(GetOverlappedResult(handle, &overlappedRead, &bytesRead, FALSE)) {
|
||||
readQueue.enqueue_bulk(readbuf, bytesRead);
|
||||
state = LAUNCH;
|
||||
|
|
@ -300,8 +299,8 @@ void VCP::writeTask() {
|
|||
if(WriteFile(handle, writeOp.bytes.data(), (DWORD)writeOp.bytes.size(), nullptr, &overlappedWrite))
|
||||
continue;
|
||||
|
||||
auto err = GetLastError();
|
||||
if(err == ERROR_IO_PENDING) {
|
||||
auto winerr = GetLastError();
|
||||
if(winerr == ERROR_IO_PENDING) {
|
||||
state = WAIT;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue