few fixes from LGTM

old-commit-hash: 758794dec5
commatwo_master
Adeeb Shihadeh 4 years ago
parent b5efa28b59
commit 6a01983000
  1. 2
      selfdrive/camerad/cameras/camera_common.cc
  2. 3
      selfdrive/thermald/thermald.py
  3. 4
      tools/nui/FileReader.cpp
  4. 15
      tools/nui/FileReader.hpp

@ -232,7 +232,7 @@ void fill_frame_image(cereal::FrameData::Builder &framed, const CameraBuf *b) {
memcpy(&resized_dat[(r*new_width+c)*3], &dat[goff+r*b->rgb_stride*scale+c*3*scale], 3*sizeof(uint8_t)); memcpy(&resized_dat[(r*new_width+c)*3], &dat[goff+r*b->rgb_stride*scale+c*3*scale], 3*sizeof(uint8_t));
} }
} }
framed.setImage(kj::arrayPtr((const uint8_t*)resized_dat, new_width*new_height*3)); framed.setImage(kj::arrayPtr((const uint8_t*)resized_dat, (size_t)new_width*new_height*3));
delete[] resized_dat; delete[] resized_dat;
} }

@ -276,7 +276,6 @@ def thermald_thread():
# If device is offroad we want to cool down before going onroad # If device is offroad we want to cool down before going onroad
# since going onroad increases load and can make temps go over 107 # since going onroad increases load and can make temps go over 107
# We only do this if there is a relay that prevents the car from faulting # We only do this if there is a relay that prevents the car from faulting
thermal_status = ThermalStatus.green # default to good condition
is_offroad_for_5_min = (started_ts is None) and ((not started_seen) or (off_ts is None) or (sec_since_boot() - off_ts > 60 * 5)) is_offroad_for_5_min = (started_ts is None) and ((not started_seen) or (off_ts is None) or (sec_since_boot() - off_ts > 60 * 5))
if max_cpu_temp > 107. or bat_temp >= 63. or (is_offroad_for_5_min and max_cpu_temp > 70.0): if max_cpu_temp > 107. or bat_temp >= 63. or (is_offroad_for_5_min and max_cpu_temp > 70.0):
# onroad not allowed # onroad not allowed
@ -293,6 +292,8 @@ def thermald_thread():
elif max_cpu_temp > 75.0: elif max_cpu_temp > 75.0:
# hysteresis between uploader not allowed and all good # hysteresis between uploader not allowed and all good
thermal_status = clip(thermal_status, ThermalStatus.green, ThermalStatus.yellow) thermal_status = clip(thermal_status, ThermalStatus.green, ThermalStatus.yellow)
else:
thermal_status = ThermalStatus.green # default to good condition
# **** starting logic **** # **** starting logic ****

@ -74,6 +74,10 @@ LogReader::LogReader(const QString& file, Events *events_, QReadWriteLock* event
}); });
} }
LogReader::~LogReader() {
delete parser;
}
void LogReader::mergeEvents(int dled) { void LogReader::mergeEvents(int dled) {
auto amsg = kj::arrayPtr((const capnp::word*)(raw.data() + event_offset), (dled-event_offset)/sizeof(capnp::word)); auto amsg = kj::arrayPtr((const capnp::word*)(raw.data() + event_offset), (dled-event_offset)/sizeof(capnp::word));
Events events_local; Events events_local;

@ -1,5 +1,4 @@
#ifndef FILEREADER_HPP #pragma once
#define FILEREADER_HPP
#include <QString> #include <QString>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
@ -20,7 +19,8 @@
#include "channel.hpp" #include "channel.hpp"
class FileReader : public QObject { class FileReader : public QObject {
Q_OBJECT Q_OBJECT
public: public:
FileReader(const QString& file_); FileReader(const QString& file_);
void startRequest(const QUrl &url); void startRequest(const QUrl &url);
@ -28,10 +28,13 @@ public:
virtual void readyRead(); virtual void readyRead();
void httpFinished(); void httpFinished();
virtual void done() {}; virtual void done() {};
public slots: public slots:
void process(); void process();
protected: protected:
QNetworkReply *reply; QNetworkReply *reply;
private: private:
QNetworkAccessManager *qnam; QNetworkAccessManager *qnam;
QElapsedTimer timer; QElapsedTimer timer;
@ -44,9 +47,12 @@ class LogReader : public FileReader {
Q_OBJECT Q_OBJECT
public: public:
LogReader(const QString& file, Events *, QReadWriteLock* events_lock_, QMap<int, QPair<int, int> > *eidx_); LogReader(const QString& file, Events *, QReadWriteLock* events_lock_, QMap<int, QPair<int, int> > *eidx_);
~LogReader();
void readyRead(); void readyRead();
void done() { is_done = true; }; void done() { is_done = true; };
bool is_done = false; bool is_done = false;
private: private:
bz_stream bStream; bz_stream bStream;
@ -63,6 +69,3 @@ private:
QReadWriteLock* events_lock; QReadWriteLock* events_lock;
QMap<int, QPair<int, int> > *eidx; QMap<int, QPair<int, int> > *eidx;
}; };
#endif

Loading…
Cancel
Save