Skip to content

Flush buffered standard steams #489

@ivankravets

Description

@ivankravets

Hi,

Firstly, a big THANK YOU for the amazing project! Glad to see that @platformio users found it useful.

See initial platformio/platformio-core#3965 posted by @adbancroft.

There is a problem with data buffering on the SimAVR/Windows side. Possible solutions:

Please note that it works great on Unix.

How to reproduce?

I've just created a simple Python script and tried to redirect standard streams to the PIPE. Subsequent reading of 1 byte hangs Python script. See code

simavr.py

import sys
import subprocess


if __name__ == "__main__":
    with subprocess.Popen(
        sys.argv[1:],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        bufsize=0,
    ) as proc:
        print("reading...")
        proc.stdout.read(1)
        print("reading is done.")

Call SimAVR using Python bridge/script:

python simavr.py bin/simavr -m atmega328p -f 16000000L firmware.elf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions