pxsi: parameter update over serial interface ============================================ Markus Zolliker (markus.zolliker@psi.ch) helper library for micropython on RP2040 (e.g. Arduino Nano Connect or Paspberry Pico) Code example ------------ from pxsi import Pxsi # declare variables visibile over serial vars = Pxsi('MyBox', # idn will be: pxsi,MyBox t = 5, a = 2, ) # create action functions for some of the variables def change_t(value): # write here what to do when t changes # your real code print(t) # the given variables are now available in the main namesapce while True: # handle IO, wait at most 0.5 secs vars.handle_io(0.5) # read out sensors, do control logic here # important: do not sleep here! Serial protocol --------------- Commands: name # get value of variable name name=value # change value (value must be a valid JSON value) ["name1", ["name2", value]] # multiple commands: query name1, change name2. must be a valid JSON array {"name1": null, "name2": value} # alternative form - be aware that order is not guaranteed Special command for identification *IDN? returns: pxsi, For all other commands the reply is always a JSON object: {"name1": value1, "name2", value2} In case of an error, the result contains an item with the key "_error_" and a JSON array as value, listing the errors appeared. Hints for Arduino Nano Connect ------------------------------ For a soft reset send '\x03\x04' (Ctrl-C Ctrl-D). The reply will be quite some text, with the last line: pxsi: