Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG ON UPDATE #1432

Closed
laercionit opened this issue Nov 9, 2020 · 2 comments
Closed

BUG ON UPDATE #1432

laercionit opened this issue Nov 9, 2020 · 2 comments
Labels
bug v6 ArduinoJson 6

Comments

@laercionit
Copy link

laercionit commented Nov 9, 2020

I am not able to identify the error, but it is having a problem in the compilation after the update. Can someone guide me please?

D:\SETUP\Programas\Desenvolvimento\ArduinoDesenv\portable\sketchbook\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantOperators.hpp: In instantiation of 'typename ArduinoJson6171_91::enable_if<(! ArduinoJson6171_91::IsVariant::value), T>::type ArduinoJson6171_91::operator|(const TVariant&, T) [with T = char*; TVariant = ArduinoJson6171_91::MemberProxy<ArduinoJson6171_91::ObjectRef, const __FlashStringHelper*>; typename ArduinoJson6171_91::enable_if<(! ArduinoJson6171_91::IsVariant::value), T>::type = char*]':
C:\Users\Laercio\AppData\Local\Temp\arduino_build_217137\sketch\Sensor.h:287:86: required from here
D:\SETUP\Programas\Desenvolvimento\ArduinoDesenv\portable\sketchbook\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantOperators.hpp:26:37: error: invalid conversion from 'ArduinoJson6171_91::VariantAs<char*>::type {aka const char*}' to 'ArduinoJson6171_91::enable_if<true, char*>::type {aka char*}' [-fpermissive]
return variant.template as();
^

bool SensorLoadSD(const char* Filename, const byte Total = SensorTotal) {
  if (FilesSDOpen(Filename)) {
    MyFileSD.find("[");
    byte ObjectID = 0;
    do {
      DynamicJsonDocument JSON(JsonSettingsBuffer);
      DeserializationError err = deserializeJson(JSON, MyFileSD);
      if (!err) {
        JsonObject Object = JSON.as<JsonObject>();
        Sensor[ObjectID].ID                   = Object[F("ID")]   | Sensor[ObjectID].ID;
        Sensor[ObjectID].Pin                  = Object[F("PIN")]  | Sensor[ObjectID].Pin;
        Sensor[ObjectID].Type                 = Object[F("TP")]   | Sensor[ObjectID].Type;
        Sensor[ObjectID].Model                = Object[F("MDL")]  | Sensor[ObjectID].Model;
        strlcpy(Sensor[ObjectID].Name         , Object[F("NM")]   | Sensor[ObjectID].Name,          sizeof(Sensor[ObjectID].Name)); // ERROR COM COMPILE
        Sensor[ObjectID].Rate                 = Object[F("RT")]   | Sensor[ObjectID].Rate;
        Sensor[ObjectID].LowAlert             = Object[F("LW")]   | Sensor[ObjectID].LowAlert;
        Sensor[ObjectID].HighAlert            = Object[F("HG")]   | Sensor[ObjectID].HighAlert;
        Sensor[ObjectID].Favorite             = Object[F("FAV")]  | Sensor[ObjectID].Favorite;
        ObjectID++;
      } else return 0;
    } while ((MyFileSD.findUntil(",", "]")) && (MyFileSD.available()) && (ObjectID < Total));
    String Formated = F("SensorLoadSD: %s"); snprintf_P(Buffer, sizeof(Buffer), Formated.c_str(), Filename); DebugSerial.println(Buffer);
    FilesSDClose();
    return 1;
  }
  return 0;
}



@bblanchon
Copy link
Owner

Hi @laercionit,

Thank you very much for reporting this bug.
It'll be fixed very soon; until then, you can revert back to 6.17.0 or cast Sensor[ObjectID].Name to a const char*:

strlcpy(Sensor[ObjectID].Name, Object[F("NM")] | (const char*)Sensor[ObjectID].Name, sizeof(Sensor[ObjectID].Name));

Best regards,
Benoit

@bblanchon
Copy link
Owner

The fix was published in version 6.17.2.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2021
@bblanchon bblanchon added the v6 ArduinoJson 6 label Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug v6 ArduinoJson 6
Projects
None yet
Development

No branches or pull requests

2 participants