# MicroPython on the XIAO RP2350: talk to the Zaber X-MCB2 over the R-only RS-232 link.
# TX/RX are inverted in the UART because the board has no level shifter (RS-232 idle = low level).
from machine import UART, Pin
import time

zb = UART(0, baudrate=115200, tx=Pin(0), rx=Pin(1),
          invert=UART.INV_TX | UART.INV_RX, timeout=200)

def cmd(s):
    zb.write((s + "\n").encode())
    time.sleep_ms(50)
    r = zb.read()
    print(s, "->", r)
    return r

cmd("/")                 # every device answers with its address
cmd("/1 get pos")
cmd("/1 home")
time.sleep(3)
cmd("/1 move abs 10000")
