001-field.py 646 B

1234567891011121314151617181920212223242526272829
  1. import pathlib
  2. test_file = pathlib.Path(__file__)
  3. test_dir = test_file.parent
  4. project_dir = test_dir.parent
  5. import sys
  6. sys.path.append(str(project_dir.absolute()))
  7. import source as communication
  8. def main():
  9. print("Starting test.")
  10. sample = communication.field("move_x", int)
  11. sample.set(255)
  12. print("Sample is: " + str(sample.get()))
  13. print("Sample as bytes: " + str(sample.encoder().code()))
  14. encoded = sample.encoder().code()
  15. sample_2 = communication.field("move_x", int)
  16. sample_2.decoder().load(encoded)
  17. print("Sample 2 (decoded sample): " + str(sample_2.get()))
  18. if __name__ == "__main__":
  19. main()