I am trying to connect to the serial port on a pybadge from MakeCode Arcade I have configured the application as follows but I am not receiving any data
pxt.json - Configured to import serial
{
"name": "SerialTest1",
"description": "",
"dependencies": {
"device": "*",
"serial": "*",
"arcade-text": "github:microsoft/arcade-text#v1.3.0"
},
"files": [
"main.blocks",
"main.ts",
"README.md",
"main.py"
],
"preferredEditor": "tsprj"
}
main.js - Displays error -1012 from serialDevice.Read()
let text : TextSprite = null
text = textsprite.create("Starting")
text.setOutline(1, 6)
scene.setBackgroundColor(0)
serial.redirect(pins.TX, pins.RX, BaudRate.BaudRate115200)
text.setText("Started12")
forever(function on_forever() {
pause(2000)
let byte = serial.device().serialDevice.read()
text.setText(byte.toString())
})
Pin Connections
Python Verification Code
I have verified that text can be sent and received with the following circutpython code
import board
import busio
uart = busio.UART(board.TX, board.RX, baudrate=115200)
while True:
data = uart.read(1) # read a byte
if data is not None:
data_string = ''.join([chr(b) for b in data])
print(data_string, end="")
uart.write(data)