microsoft / pxt-adafruit

Microsoft MakeCode editor for Adafruit Circuit Playground Express
https://makecode.adafruit.com
Other
81 stars 77 forks source link

Must read data from serial before writing #1189

Open ajs256 opened 4 years ago

ajs256 commented 4 years ago

Describe the bug You must read data from serial before writing again. I am using a Parallax Serial LCD, which doesn't send data, if this is a device-specific problem.

To Reproduce Import this code.

serial.redirect(pins.TX, pins.RX, BaudRate.BaudRate2400)
let buf = pins.createBuffer(2)
buf.setNumber(NumberFormat.Int8LE, 0, 0x11) // Backlight on
buf.setNumber(NumberFormat.Int8LE, 1, 0x0c) // Form feed
serial.writeBuffer(buf)

loops.pause(5) // The display requires this after a form feed

serial.writeString("Test") 
// Display shows "Te"
// serial.readString() // Workaround (uncomment this line)
// serial.writeString("Test") // Workaround (uncomment this line)
// Display shows "Test", not "TestTest"

Expected behavior I expected the display to show "Test" and not have to run the last two lines.

Desktop (please complete the following information):

Note: I'm sorry if this belongs in microsoft/pxt - let me know and I'll make it there