Fix: cpplint errors
This commit is contained in:
parent
dc5eb96f50
commit
bcf4b70dc9
@ -85,13 +85,13 @@ bool ActivePowerControlCommand::handleResponse(const fragment_t fragment[], cons
|
||||
|
||||
float ActivePowerControlCommand::getLimit() const
|
||||
{
|
||||
const float l = (((uint16_t)_payload[12] << 8) | _payload[13]);
|
||||
const float l = (static_cast<uint16_t>(_payload[12]) << 8) | _payload[13];
|
||||
return l / 10;
|
||||
}
|
||||
|
||||
PowerLimitControlType ActivePowerControlCommand::getType()
|
||||
{
|
||||
return (PowerLimitControlType)(((uint16_t)_payload[14] << 8) | _payload[15]);
|
||||
return (PowerLimitControlType)((static_cast<uint16_t>(_payload[14]) << 8) | _payload[15]);
|
||||
}
|
||||
|
||||
void ActivePowerControlCommand::gotTimeout()
|
||||
|
||||
@ -35,8 +35,8 @@ DevControlCommand::DevControlCommand(InverterAbstract* inv, const uint64_t route
|
||||
void DevControlCommand::udpateCRC(const uint8_t len)
|
||||
{
|
||||
const uint16_t crc = crc16(&_payload[10], len);
|
||||
_payload[10 + len] = (uint8_t)(crc >> 8);
|
||||
_payload[10 + len + 1] = (uint8_t)(crc);
|
||||
_payload[10 + len] = static_cast<uint8_t>(crc >> 8);
|
||||
_payload[10 + len + 1] = static_cast<uint8_t>(crc);
|
||||
}
|
||||
|
||||
bool DevControlCommand::handleResponse(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||
|
||||
@ -63,10 +63,10 @@ uint8_t MultiDataCommand::getDataType() const
|
||||
|
||||
void MultiDataCommand::setTime(const time_t time)
|
||||
{
|
||||
_payload[12] = (uint8_t)(time >> 24);
|
||||
_payload[13] = (uint8_t)(time >> 16);
|
||||
_payload[14] = (uint8_t)(time >> 8);
|
||||
_payload[15] = (uint8_t)(time);
|
||||
_payload[12] = static_cast<uint8_t>(time >> 24);
|
||||
_payload[13] = static_cast<uint8_t>(time >> 16);
|
||||
_payload[14] = static_cast<uint8_t>(time >> 8);
|
||||
_payload[15] = static_cast<uint8_t>(time);
|
||||
udpateCRC();
|
||||
}
|
||||
|
||||
@ -112,8 +112,8 @@ bool MultiDataCommand::handleResponse(const fragment_t fragment[], const uint8_t
|
||||
void MultiDataCommand::udpateCRC()
|
||||
{
|
||||
const uint16_t crc = crc16(&_payload[10], 14); // From data_type till password
|
||||
_payload[24] = (uint8_t)(crc >> 8);
|
||||
_payload[25] = (uint8_t)(crc);
|
||||
_payload[24] = static_cast<uint8_t>(crc >> 8);
|
||||
_payload[25] = static_cast<uint8_t>(crc);
|
||||
}
|
||||
|
||||
uint8_t MultiDataCommand::getTotalFragmentSize(const fragment_t fragment[], const uint8_t max_fragment_id)
|
||||
|
||||
@ -36,10 +36,10 @@ bool HM_1CH::isValidSerial(const uint64_t serial)
|
||||
// serial >= 0x112100000000 && serial <= 0x1121ffffffff
|
||||
|
||||
uint8_t preId[2];
|
||||
preId[0] = (uint8_t)(serial >> 40);
|
||||
preId[1] = (uint8_t)(serial >> 32);
|
||||
preId[0] = static_cast<uint8_t>(serial >> 40);
|
||||
preId[1] = static_cast<uint8_t>(serial >> 32);
|
||||
|
||||
if ((uint8_t)(((((uint16_t)preId[0] << 8) | preId[1]) >> 4) & 0xff) == 0x12) {
|
||||
if (static_cast<uint8_t>((((static_cast<uint16_t>(preId[0]) << 8) | preId[1]) >> 4) & 0xff) == 0x12) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -44,10 +44,10 @@ bool HM_2CH::isValidSerial(const uint64_t serial)
|
||||
// serial >= 0x114100000000 && serial <= 0x1141ffffffff
|
||||
|
||||
uint8_t preId[2];
|
||||
preId[0] = (uint8_t)(serial >> 40);
|
||||
preId[1] = (uint8_t)(serial >> 32);
|
||||
preId[0] = static_cast<uint8_t>(serial >> 40);
|
||||
preId[1] = static_cast<uint8_t>(serial >> 32);
|
||||
|
||||
if ((uint8_t)(((((uint16_t)preId[0] << 8) | preId[1]) >> 4) & 0xff) == 0x14) {
|
||||
if (static_cast<uint8_t>((((static_cast<uint16_t>(preId[0]) << 8) | preId[1]) >> 4) & 0xff) == 0x14) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -57,10 +57,10 @@ bool HM_4CH::isValidSerial(const uint64_t serial)
|
||||
// serial >= 0x116100000000 && serial <= 0x1161ffffffff
|
||||
|
||||
uint8_t preId[2];
|
||||
preId[0] = (uint8_t)(serial >> 40);
|
||||
preId[1] = (uint8_t)(serial >> 32);
|
||||
preId[0] = static_cast<uint8_t>(serial >> 40);
|
||||
preId[1] = static_cast<uint8_t>(serial >> 32);
|
||||
|
||||
if ((uint8_t)(((((uint16_t)preId[0] << 8) | preId[1]) >> 4) & 0xff) == 0x16) {
|
||||
if (static_cast<uint8_t>((((static_cast<uint16_t>(preId[0]) << 8) | preId[1]) >> 4) & 0xff) == 0x16) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -50,13 +50,13 @@ bool HM_Abstract::sendAlarmLogRequest(const bool force)
|
||||
|
||||
if (!force) {
|
||||
if (Statistics()->hasChannelFieldValue(TYPE_INV, CH0, FLD_EVT_LOG)) {
|
||||
if ((uint8_t)Statistics()->getChannelFieldValue(TYPE_INV, CH0, FLD_EVT_LOG) == _lastAlarmLogCnt) {
|
||||
if (static_cast<uint8_t>(Statistics()->getChannelFieldValue(TYPE_INV, CH0, FLD_EVT_LOG) == _lastAlarmLogCnt)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_lastAlarmLogCnt = (uint8_t)Statistics()->getChannelFieldValue(TYPE_INV, CH0, FLD_EVT_LOG);
|
||||
_lastAlarmLogCnt = static_cast<uint8_t>(Statistics()->getChannelFieldValue(TYPE_INV, CH0, FLD_EVT_LOG));
|
||||
|
||||
time_t now;
|
||||
time(&now);
|
||||
|
||||
@ -14,8 +14,8 @@ InverterAbstract::InverterAbstract(HoymilesRadio* radio, const uint64_t serial)
|
||||
|
||||
char serial_buff[sizeof(uint64_t) * 8 + 1];
|
||||
snprintf(serial_buff, sizeof(serial_buff), "%0x%08x",
|
||||
((uint32_t)((serial >> 32) & 0xFFFFFFFF)),
|
||||
((uint32_t)(serial & 0xFFFFFFFF)));
|
||||
static_cast<uint32_t>((serial >> 32) & 0xFFFFFFFF),
|
||||
static_cast<uint32_t>(serial & 0xFFFFFFFF));
|
||||
_serialString = serial_buff;
|
||||
|
||||
_alarmLogParser.reset(new AlarmLogParser());
|
||||
|
||||
@ -243,7 +243,7 @@ void AlarmLogParser::getLogEntry(const uint8_t entryId, AlarmLogEntry_t& entry,
|
||||
|
||||
HOY_SEMAPHORE_TAKE();
|
||||
|
||||
const uint32_t wcode = (uint16_t)_payloadAlarmLog[entryStartOffset] << 8 | _payloadAlarmLog[entryStartOffset + 1];
|
||||
const uint32_t wcode = static_cast<uint16_t>(_payloadAlarmLog[entryStartOffset]) << 8 | _payloadAlarmLog[entryStartOffset + 1];
|
||||
uint32_t startTimeOffset = 0;
|
||||
if (((wcode >> 13) & 0x01) == 1) {
|
||||
startTimeOffset = 12 * 60 * 60;
|
||||
@ -255,8 +255,8 @@ void AlarmLogParser::getLogEntry(const uint8_t entryId, AlarmLogEntry_t& entry,
|
||||
}
|
||||
|
||||
entry.MessageId = _payloadAlarmLog[entryStartOffset + 1];
|
||||
entry.StartTime = (((uint16_t)_payloadAlarmLog[entryStartOffset + 4] << 8) | ((uint16_t)_payloadAlarmLog[entryStartOffset + 5])) + startTimeOffset + timezoneOffset;
|
||||
entry.EndTime = ((uint16_t)_payloadAlarmLog[entryStartOffset + 6] << 8) | ((uint16_t)_payloadAlarmLog[entryStartOffset + 7]);
|
||||
entry.StartTime = ((static_cast<uint16_t>(_payloadAlarmLog[entryStartOffset + 4]) << 8) | static_cast<uint16_t>(_payloadAlarmLog[entryStartOffset + 5])) + startTimeOffset + timezoneOffset;
|
||||
entry.EndTime = (static_cast<uint16_t>(_payloadAlarmLog[entryStartOffset + 6]) << 8) | static_cast<uint16_t>(_payloadAlarmLog[entryStartOffset + 7]);
|
||||
|
||||
HOY_SEMAPHORE_GIVE();
|
||||
|
||||
|
||||
@ -149,7 +149,7 @@ void DevInfoParser::setLastUpdateSimple(const uint32_t lastUpdate)
|
||||
uint16_t DevInfoParser::getFwBuildVersion() const
|
||||
{
|
||||
HOY_SEMAPHORE_TAKE();
|
||||
const uint16_t ret = (((uint16_t)_payloadDevInfoAll[0]) << 8) | _payloadDevInfoAll[1];
|
||||
const uint16_t ret = (static_cast<uint16_t>(_payloadDevInfoAll[0]) << 8) | _payloadDevInfoAll[1];
|
||||
HOY_SEMAPHORE_GIVE();
|
||||
return ret;
|
||||
}
|
||||
@ -158,13 +158,13 @@ time_t DevInfoParser::getFwBuildDateTime() const
|
||||
{
|
||||
struct tm timeinfo = {};
|
||||
HOY_SEMAPHORE_TAKE();
|
||||
timeinfo.tm_year = ((((uint16_t)_payloadDevInfoAll[2]) << 8) | _payloadDevInfoAll[3]) - 1900;
|
||||
timeinfo.tm_year = ((static_cast<uint16_t>(_payloadDevInfoAll[2]) << 8) | _payloadDevInfoAll[3]) - 1900;
|
||||
|
||||
timeinfo.tm_mon = ((((uint16_t)_payloadDevInfoAll[4]) << 8) | _payloadDevInfoAll[5]) / 100 - 1;
|
||||
timeinfo.tm_mday = ((((uint16_t)_payloadDevInfoAll[4]) << 8) | _payloadDevInfoAll[5]) % 100;
|
||||
timeinfo.tm_mon = ((static_cast<uint16_t>(_payloadDevInfoAll[4]) << 8) | _payloadDevInfoAll[5]) / 100 - 1;
|
||||
timeinfo.tm_mday = ((static_cast<uint16_t>(_payloadDevInfoAll[4]) << 8) | _payloadDevInfoAll[5]) % 100;
|
||||
|
||||
timeinfo.tm_hour = ((((uint16_t)_payloadDevInfoAll[6]) << 8) | _payloadDevInfoAll[7]) / 100;
|
||||
timeinfo.tm_min = ((((uint16_t)_payloadDevInfoAll[6]) << 8) | _payloadDevInfoAll[7]) % 100;
|
||||
timeinfo.tm_hour = ((static_cast<uint16_t>(_payloadDevInfoAll[6]) << 8) | _payloadDevInfoAll[7]) / 100;
|
||||
timeinfo.tm_min = ((static_cast<uint16_t>(_payloadDevInfoAll[6]) << 8) | _payloadDevInfoAll[7]) % 100;
|
||||
HOY_SEMAPHORE_GIVE();
|
||||
|
||||
return timegm(&timeinfo);
|
||||
@ -181,7 +181,7 @@ String DevInfoParser::getFwBuildDateTimeStr() const
|
||||
uint16_t DevInfoParser::getFwBootloaderVersion() const
|
||||
{
|
||||
HOY_SEMAPHORE_TAKE();
|
||||
const uint16_t ret = (((uint16_t)_payloadDevInfoAll[8]) << 8) | _payloadDevInfoAll[9];
|
||||
const uint16_t ret = (static_cast<uint16_t>(_payloadDevInfoAll[8]) << 8) | _payloadDevInfoAll[9];
|
||||
HOY_SEMAPHORE_GIVE();
|
||||
return ret;
|
||||
}
|
||||
@ -189,11 +189,11 @@ uint16_t DevInfoParser::getFwBootloaderVersion() const
|
||||
uint32_t DevInfoParser::getHwPartNumber() const
|
||||
{
|
||||
HOY_SEMAPHORE_TAKE();
|
||||
const uint16_t hwpn_h = (((uint16_t)_payloadDevInfoSimple[2]) << 8) | _payloadDevInfoSimple[3];
|
||||
const uint16_t hwpn_l = (((uint16_t)_payloadDevInfoSimple[4]) << 8) | _payloadDevInfoSimple[5];
|
||||
const uint16_t hwpn_h = (static_cast<uint16_t>(_payloadDevInfoSimple[2]) << 8) | _payloadDevInfoSimple[3];
|
||||
const uint16_t hwpn_l = (static_cast<uint16_t>(_payloadDevInfoSimple[4]) << 8) | _payloadDevInfoSimple[5];
|
||||
HOY_SEMAPHORE_GIVE();
|
||||
|
||||
return ((uint32_t)hwpn_h << 16) | ((uint32_t)hwpn_l);
|
||||
return (static_cast<uint32_t>(hwpn_h) << 16) | static_cast<uint32_t>(hwpn_l);
|
||||
}
|
||||
|
||||
String DevInfoParser::getHwVersion() const
|
||||
|
||||
@ -443,7 +443,7 @@ std::list<GridProfileSection_t> GridProfileParser::getProfile() const
|
||||
for (uint8_t val_id = 0; val_id < section_size; val_id++) {
|
||||
auto itemDefinition = itemDefinitions.at(_profileValues[section_start + val_id].ItemDefinition);
|
||||
|
||||
float value = (int16_t)((_payloadGridProfile[pos] << 8) | _payloadGridProfile[pos + 1]);
|
||||
float value = static_cast<int16_t>((_payloadGridProfile[pos] << 8) | _payloadGridProfile[pos + 1]);
|
||||
value /= itemDefinition.Divider;
|
||||
|
||||
GridProfileItem_t v;
|
||||
|
||||
@ -45,7 +45,7 @@ void SystemConfigParaParser::appendFragment(const uint8_t offset, const uint8_t*
|
||||
float SystemConfigParaParser::getLimitPercent() const
|
||||
{
|
||||
HOY_SEMAPHORE_TAKE();
|
||||
const float ret = ((((uint16_t)_payload[2]) << 8) | _payload[3]) / 10.0;
|
||||
const float ret = ((static_cast<uint16_t>(_payload[2]) << 8) | _payload[3]) / 10.0;
|
||||
HOY_SEMAPHORE_GIVE();
|
||||
return ret;
|
||||
}
|
||||
@ -53,8 +53,8 @@ float SystemConfigParaParser::getLimitPercent() const
|
||||
void SystemConfigParaParser::setLimitPercent(const float value)
|
||||
{
|
||||
HOY_SEMAPHORE_TAKE();
|
||||
_payload[2] = ((uint16_t)(value * 10)) >> 8;
|
||||
_payload[3] = ((uint16_t)(value * 10));
|
||||
_payload[2] = static_cast<uint16_t>(value * 10) >> 8;
|
||||
_payload[3] = static_cast<uint16_t>(value * 10);
|
||||
HOY_SEMAPHORE_GIVE();
|
||||
}
|
||||
|
||||
|
||||
@ -50,8 +50,8 @@ void WebApiDtuClass::onDtuAdminGet(AsyncWebServerRequest* request)
|
||||
// DTU Serial is read as HEX
|
||||
char buffer[sizeof(uint64_t) * 8 + 1];
|
||||
snprintf(buffer, sizeof(buffer), "%0" PRIx32 "%08" PRIx32,
|
||||
((uint32_t)((config.Dtu.Serial >> 32) & 0xFFFFFFFF)),
|
||||
((uint32_t)(config.Dtu.Serial & 0xFFFFFFFF)));
|
||||
static_cast<uint32_t>((config.Dtu.Serial >> 32) & 0xFFFFFFFF),
|
||||
static_cast<uint32_t>(config.Dtu.Serial & 0xFFFFFFFF));
|
||||
root["serial"] = buffer;
|
||||
root["pollinterval"] = config.Dtu.PollInterval;
|
||||
root["nrf_enabled"] = Hoymiles.getRadioNrf()->isInitialized();
|
||||
|
||||
@ -46,8 +46,8 @@ void WebApiInverterClass::onInverterList(AsyncWebServerRequest* request)
|
||||
// Inverter Serial is read as HEX
|
||||
char buffer[sizeof(uint64_t) * 8 + 1];
|
||||
snprintf(buffer, sizeof(buffer), "%0" PRIx32 "%08" PRIx32,
|
||||
((uint32_t)((config.Inverter[i].Serial >> 32) & 0xFFFFFFFF)),
|
||||
((uint32_t)(config.Inverter[i].Serial & 0xFFFFFFFF)));
|
||||
static_cast<uint32_t>((config.Inverter[i].Serial >> 32) & 0xFFFFFFFF),
|
||||
static_cast<uint32_t>(config.Inverter[i].Serial & 0xFFFFFFFF));
|
||||
obj["serial"] = buffer;
|
||||
obj["poll_enable"] = config.Inverter[i].Poll_Enable;
|
||||
obj["poll_enable_night"] = config.Inverter[i].Poll_Enable_Night;
|
||||
|
||||
@ -152,8 +152,8 @@ void setup()
|
||||
MessageOutput.print("generate serial based on ESP chip id: ");
|
||||
const uint64_t dtuId = Utils::generateDtuSerial();
|
||||
MessageOutput.printf("%0" PRIx32 "%08" PRIx32 "... ",
|
||||
((uint32_t)((dtuId >> 32) & 0xFFFFFFFF)),
|
||||
((uint32_t)(dtuId & 0xFFFFFFFF)));
|
||||
static_cast<uint32_t>((dtuId >> 32) & 0xFFFFFFFF),
|
||||
static_cast<uint32_t>(dtuId & 0xFFFFFFFF));
|
||||
config.Dtu.Serial = dtuId;
|
||||
Configuration.write();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user