test_unified_consumer_metadata.py 1.2 KB

12345678910111213141516171819202122232425
  1. import json
  2. from tools.generate_6400_manual import generate, OUT
  3. def test_exported_uart_metadata_agrees_with_command_tables():
  4. data = json.loads(generate()[OUT / "manual-uart-contract.json"])
  5. uart = data["wire"]["uart"]
  6. responses = data["wire"]["responses"]
  7. commands = data["wire"]["commands"]
  8. assert uart["length_width_bits"] == 8
  9. assert uart["set_all_type"] == commands["SET_ALL"]["type"] == 0x01
  10. assert uart["get_all_type"] == commands["GET_ALL"]["type"] == 0x02
  11. assert uart["set_ack_type"] == responses["SET_ACK"]["type"] == 129
  12. assert uart["get_ack_type"] == responses["GET_ACK"]["type"] == 130
  13. assert uart["get_data_type"] == responses["GET_DATA"]["type"] == 66
  14. assert uart["nack_type"] == responses["NACK"]["type"] == 192
  15. assert uart["set_all_payload_bytes"] == 32 and uart["get_data_payload_bytes"] == 83
  16. assert responses["NACK"]["payload_length"] == 2
  17. assert responses["NACK"]["reason"] == {
  18. "UNSUPPORTED": 1, "BAD_LENGTH": 2, "BAD_VALUE": 3, "QUEUE_FULL": 4, "BUSY": 5,
  19. }
  20. assert data["watchdog"]["feed_on"] == ["successful_set_accept", "legal_get_accept"]
  21. assert data["snapshot"]["payload_length"] == 83
  22. assert data["wire"]["inter_byte_timeout_clks"] == 250000