STD::cout Can't see variables

Hi ,
I’am using basic code for testing purposes. I can’t see my variables in teraterm when I’m using std::cout .Using mbed version 6.16.0.
This is the code snippet.

#include <iostream>
#include "LIB_TEST.h"

using namespace std;


int main()
{
    while(1){
    double a = 7.4;
    int b = 99;
    std::cout << "a + b = " <<
        LIB_TEST::Arithmetic::Add(a, b) << std::endl;
    std::cout << "a - b = " <<
        LIB_TEST::Arithmetic::Subtract(a, b) << std::endl;
    std::cout << "a * b = " <<
        LIB_TEST::Arithmetic::Multiply(a, b) << std::endl;
    std::cout << "a / b = " <<
        LIB_TEST::Arithmetic::Divide(a, b) << std::endl;
    }
    return 0;
}

and I have mbedd-app.json file

{
    "target_overrides": {
        "*": {
            "target.printf_lib": "std"
        }
    }
}

TERATERM snapshot
TERA

Hello,

#include <iostream>
...
    double a = 7.4;
    int b = 99;
    std::cout << "a + b = " << a + b << '\n';
...

Output in a Serial Terminal:

a + b = 106.4

My current mbed_app.json

{
 "requires": ["bare-metal"],
        "target_overrides": {
        "*": {
            "platform.stdio-baud-rate": 115200,
            "target.c_lib": "std",
            "target.printf_lib": "std"
        }
    }
}

BR, Jan

Hello Jan ,
I tried to your code and your mbed_app.json file.It doesn’t work again. I’m getting same results in TeraTerm.In this setup i’m working on a NUCLEOF429-ZI.

My setup :

  • Keil Studio Cloud
  • MbedOS 6.16 bare-metal (just for faster compilation)
  • Nucleo-F429ZI
  • Serial terminal apps - Termite, YAT, Puty - all same result
  • mbed_app.json from above
  • the code and output below
#include "mbed.h"
#include <iostream>

#define BLINKING_RATE     1s
DigitalOut led(LED1);

int main()
{
    std::cout << "Hello\n";
    double a = 7.4;
    int b = 1;
    
    while (true) {
        led = !led;
        b++;
        std::cout << "a + b = " <<a + b << '\n';
        std::cout << "a * b = " << a * b << '\n';
        std::cout << "a / b = " << a / b << '\n';
        ThisThread::sleep_for(BLINKING_RATE);
    }
}

BR, Jan

Hi Jan,
I tried that but I’m getting error; Could not parse mbed app configuration from /tmp/chroots/ch-7c748c19-ac80-4018-b6c9-fe2c9ffcdd51/src/mbed_app.json.

This is the code

#include "mbed.h"
#include <iostream>

#define BLINKING_RATE     1s
DigitalOut led(LED1);

int main()
{
    std::cout << "Hello\n";
    double a = 7.4;
    int b = 1;
    
    while (true) {
        led = !led;
        b++;
        std::cout << "a + b = " <<a + b << '\n';
        std::cout << "a * b = " << a * b << '\n';
        std::cout << "a / b = " << a / b << '\n';
        ThisThread::sleep_for(BLINKING_RATE);
    }
}

Mbed_app.json file;

I had typo there. Just cut out the last comma.

// from
"target.printf_lib": "std",
// to
"target.printf_lib": "std"

BR, Jan

Thanks a lot Jan. :slight_smile:
Sorry for taking up too much of your time.