Skip to content

[Bug] Issues with USB stdout via Pybricksdev #2312

@laurensvalk

Description

@laurensvalk

Some programs don't show any standard output in Pybricksdev.

There doesn't seem to be any association with sensors after all. The following program also does not work for me.

from pybricks.tools import wait

print("INITED")

a = {1, 2, 3, 4, 5}

print(a)


while True:
    print("dist", a)
    wait(100)

Variations of this programs do seem to work. SPIKE Prime has this too for some scripts, but not necessarily the same ones. So perhaps another timing issue or race condition?

Sometimes, there is partial output, with some characters missing:

123, }

or:

INITED
{5, 1, , 34

Initial post for reference:

This program works, but the info is commented out.

from pybricks.iodevices import PUPDevice
from pybricks.parameters import Port
from pybricks.tools import wait

dev = PUPDevice(Port.S4)

a = dev.info()
# print(a)

while True:
    print("dist", dev.read(0))
    wait(100)

But this program does not produce any output:

from pybricks.iodevices import PUPDevice
from pybricks.parameters import Port

dev = PUPDevice(Port.S4)

a = dev.info()
print(a)

And yet this program prints both the info dictionary and the sensor values just fine:

from pybricks.iodevices import PUPDevice
from pybricks.parameters import Port
from pybricks.tools import wait

dev = PUPDevice(Port.S4)

wait(100)

print("INITED")
wait(100)
a = dev.info()

print(a)


while True:
    print("dist", dev.read(0))
    wait(100)

It should be unrelated to the sensor code since the same programs run fine on Bluetooth. I will try to create an example that does not use sensors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    software: pybricksdevIssues related to the pybrickdev Python packagetopic: USBIssues related to USB

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions