main.py 483 B

12345678910111213141516171819202122
  1. from nbus_hal.serial_port import *
  2. # example config
  3. config = {
  4. "port_name": "COM4",
  5. "baud": 115200,
  6. "parity": "N",
  7. "timeout": 0.4,
  8. "request_attempts": 1,
  9. "enable_log": True
  10. }
  11. if __name__ == "__main__":
  12. try:
  13. port = NBusSerialPort(NBusSerialConfig(**config))
  14. port.set_logger(default_logger)
  15. response = port.request(5, 1, NBusCommand.CMD_ECHO, [1, 2, 3])
  16. print(response)
  17. except Exception as Ex:
  18. print(str(Ex))