Hello,
I came across a very funny and random issue while working with platformio and mbed.
Board : Ublox C027 with LISA U200 module
IDE : VSCode
Framework : Mbed
These are the present contents of my platformio.ini file
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; Redirecting...[env:ubloxc027]
platform = nxplpc
board = ubloxc027
framework = mbed
lib_deps = ArduinoJson
lib_archive = false
build_flags = -std=gnu++11
And these are the contents of the main.cpp file.
#include <mbed.h>
#include “ArduinoJson.h”Serial PC(USBTX,USBRX);
Serial Windsonic(P4_28, P4_29);
char *p_DeviceID, *p_WindSpeedPolar,*p_WindDirectionPolar,*p_Units,*p_StatusCode,*p_Checksum;
char p_bufferString[256];
char p_Buffer[100];
char serialNumber[16];int main()
{Windsonic.baud(9600);
PC.printf(“Initialized PC comms\n”);
PC.printf(“Initialized Windsonic comms\n”);
PC.printf(“Entering Configuration Mode\n”);
Windsonic.puts(“*”);
while(Windsonic.readable())
{
PC.putc(Windsonic.getc());
}
PC.printf(“Checking Default Configuration\n”);
Windsonic.puts(“D3\r”);
while (Windsonic.readable())
{
PC.putc(Windsonic.getc());
}
PC.printf(“Setting output format to UV, Continuous\n”);
Windsonic.puts(“M2\r”);
while (Windsonic.readable())
{
PC.putc(Windsonic.getc());
}
Windsonic.puts(“Q\r”);while(1)
{
if(Windsonic.readable())
{
Windsonic.scanf(“%s”,p_Buffer);
PC.printf(“%s\n”,p_Buffer);
}PC.printf(“\n”);
PC.printf(“\n”);if(p_Buffer[2] == p_Buffer[3])
{
p_DeviceID = strtok(p_Buffer, “,”);
p_WindSpeedPolar = strtok(NULL, “,”);
p_Units = strtok(NULL, “,”);
p_StatusCode = strtok(NULL, “,”);
p_Checksum = strtok(NULL, “,”);
p_WindDirectionPolar = “0”;}
else{
p_DeviceID = strtok(p_Buffer, “,”);
p_WindDirectionPolar = strtok(NULL, “,”);
p_WindSpeedPolar = strtok(NULL, “,”);
p_Units = strtok(NULL, “,”);
p_StatusCode = strtok(NULL, “,”);
p_Checksum = strtok(NULL, “,”);
}#ifdef DEBUG
PC.printf(“\n”);
PC.printf(“Device ID: %s\n”,p_DeviceID);
PC.printf(“Wind Direction: %s\n”, p_WindDirectionPolar);
PC.printf(“Wind Speed: %s\n”, p_WindSpeedPolar);
PC.printf(“Units: %s\n”, p_Units);
PC.printf(“Status Code: %s\n”, p_StatusCode);
#endif
// wait(1);DynamicJsonBuffer postBuffer(128);
JsonObject &root = postBuffer.createObject();
root[“board_id”]=“12345”;
root[“id”]=“12345”;
root[“type”] = “report”;
JsonObject &data = root.createNestedObject(“data”);
data[“event”]=“periodic”;
data[“Direction”]=p_WindDirectionPolar;
data[“WindSpeed”]=p_WindSpeedPolar;
data[“Units”]=p_Units;root.prettyPrintTo(p_bufferString);
PC.printf(p_bufferString);}
return 0;
}
As you can see, I am only using the ArduinoJson library to construct a json object
However, building the project gives this error.
My piolibdeps contains the ArduinoJson library. and contrary to the name the library can be used for other platforms. It is only a header file. I read somewhere else on the web (maybe their own forums) that since it is a header only library I needed to add the lib_archive = false options to the platformio.ini file to ensure that the compiler does not try to search for a .cpp file for the header. but apparently that is not making any difference either.
Any suggestions on what I can do to fix it??
There are a couple of other issues with this, but I would like to address one issues at a time.
Thank you in advance!!