Skip to content

Commit

Permalink
fixes from sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Strooom committed Oct 24, 2024
1 parent a80a7bb commit 3e5d757
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
13 changes: 5 additions & 8 deletions lib/logging/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
#include <cstdio>
#include <cstdarg>
#include <logging.hpp>
#ifndef generic
#include <Arduino.h>
#endif

uint32_t logging::activeSources{0};
uint32_t logging::activeDestinations{0};
char logging::buffer[bufferLength]{};

#ifndef generic
#include <Arduino.h>
#endif

void logging::initialize() {
#ifndef generic
Serial.begin(115200);
Expand All @@ -25,7 +24,7 @@ void logging::initialize() {

uint32_t logging::snprintf(const char *format, ...) {
uint32_t length{0};
if (activeDestinations != 00) {
if (activeDestinations != 0) {
va_list argList;
va_start(argList, format);
length = vsnprintf(buffer, bufferLength, format, argList);
Expand All @@ -37,15 +36,13 @@ uint32_t logging::snprintf(const char *format, ...) {

uint32_t logging::snprintf(source aSource, const char *format, ...) {
uint32_t length{0};
if (activeDestinations != 00) {
if (isActive(aSource)) {
if ((activeDestinations != 0) && (isActive(aSource))) {
va_list argList;
va_start(argList, format);
length = vsnprintf(buffer, bufferLength, format, argList);
va_end(argList);
write(length);
}
}
return length;
}

Expand Down
12 changes: 6 additions & 6 deletions lib/pn7160interface/pn7160interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ uint8_t PN7160Interface::IRQpin;
uint8_t PN7160Interface::VENpin;
uint8_t PN7160Interface::I2Caddress{0x28};

void PN7160Interface::initialize(uint8_t theIRQpin, uint8_t theVENpin, uint8_t I2Caddress) {
void PN7160Interface::initialize(uint8_t theIRQpin, uint8_t theVENpin, uint8_t theI2Caddress) {
IRQpin = theIRQpin;
VENpin = theVENpin;
I2Caddress = I2Caddress;
I2Caddress = theI2Caddress;
#ifndef generic
pinMode(IRQpin, INPUT);
pinMode(VENpin, OUTPUT);
Expand Down Expand Up @@ -80,15 +80,15 @@ uint32_t PN7160Interface::read(uint8_t rxBuffer[]) {
// using 'Split mode' I2C read. See UM10936 section 3.5
bytesReceived = Wire.requestFrom((int)I2Caddress, 3); // first reading the header, as this contains how long the payload will be

rxBuffer[0] = Wire.read();
rxBuffer[1] = Wire.read();
rxBuffer[2] = Wire.read();
rxBuffer[0] = static_cast<uint8_t>(Wire.read());
rxBuffer[1] = static_cast<uint8_t>(Wire.read());
rxBuffer[2] = static_cast<uint8_t>(Wire.read());
uint8_t payloadLength = rxBuffer[2];
if (payloadLength > 0) {
bytesReceived += Wire.requestFrom(I2Caddress, payloadLength); // then reading the payload, if any
uint32_t index = 3;
while (index < bytesReceived) {
rxBuffer[index] = Wire.read();
rxBuffer[index] = static_cast<uint8_t>(Wire.read());
index++;
}
}
Expand Down

0 comments on commit 3e5d757

Please sign in to comment.