Whats confusing me at the moment is that in duet.h there is this:
private:
void ProcessBuffer();
int bufferIdx;
byte* buffer;
DynamicJsonDocument doc;
#ifdef SOFTWARESERIAL
AltSoftSerial duetSerial; //Software serial on pins 8/9 on Arduino Uno.
#endif
};
Which is about the json called doc which should hold all the data from the duet.
At the bottom of this:
void DuetData::ProcessBuffer()
{
//Process the json data
Status = DUET_STATUS::UNKNOWN;
//Scan for invalid characters
for (int i = 0; i < bufferIdx - 1; i++)
{
if (buffer[i] < 32 || buffer[i] > 126)
{
#ifdef DEBUG
Serial.println("Throwing out buffer due to bad characters");
#endif
return;
}
}
DeserializationError error = deserializeJson(doc, buffer);
if (error.code() != error.Ok)
{
Status = DUET_STATUS::ERROR;
Serial.println("Error");
Serial.print(error.c_str());
Serial.println(error.f_str());
return; //There was an error deserializing the json
}
const char *status = doc["status"];
switch (status[0])
{
case 'I':
Status = DUET_STATUS::IDLE;
break;
case 'P':
Status = DUET_STATUS::PRINTING;
break;
case 'M':
Status = DUET_STATUS::SIMULATING;
break;
case 'B':
Status = DUET_STATUS::BUSY;
break;
default:
Status = DUET_STATUS::ERROR;
break;
}
Progress = doc["fraction_printed"];
//Hotend Temp1
hotendTemp = doc["heaters"][1];
fanSpeed = doc["fanPercent"][0];
The hotendTemp and fanspeed look like they are getting 'extracted' from doc and assigned to variables. But when i print those, they are still just zero, or whatever they were initially assigned.