How to simulate serial port on debugger simulator?

The underlying simulator is simavr and externally developed. Check out its manual.

Also checkout related topics Atmel AVR dev/platform v2.1.0: new boards, AVR simulator, updated Arduino cores - #8 by Sambo007 and especially AVR simulator as aid tool for debugging code - #35 by msquirogac.

Note that you can also start simavr manually the firmware and any switches you like.

E.g., a firmware like

#include <Arduino.h>

void setup() {
  Serial.begin(115200);
}

uint16_t count = 0;

void loop() {
  Serial.println("The count is: " + String(count++));
  delay(200);
}

with a platformio.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino
debug_tool = simavr

after doing a pio debug to build the binary, we can start simavr in a new Powershell session

PS C:\Users\Maxi\.platformio\packages\tool-simavr\bin> .\simavr.exe -m atmega328p -f 16000000  "C:\Users\Maxi\Documents\PlatformIO\Projects\arduino-simavr-test\.pio\build\uno\firmware.elf"   | Out-Host

to get

1 Like