Data: read and write

Read an object by name or expression, write a value or a table of writes.

since 0.3.0

Methods

EntrySignatureAvailable sinceAPI 3
readread(path, *, fields=None, start=0, count=None)0.3.0no calls in expressions
writewrite(path, value, *, verify=True) -> dict; write(rows) -> list0.3.0no calls in expressions

API 3 changes (0.5.0)

No await. The write right-hand side is evaluated once; expressions never call functions.

Recommended

Read structure fields in one call; several writes as a table in the required order.

ticks = t.read("app_state.ticks")
state = t.read("app_state", fields={"ticks": None, "led": None})
t.write("app_delay", 100)
t.write([("app_state.mode", "APP_MODE_BLINK"), ("app_delay", 100)])

Avoid

Peripheral registers through general methods: a compound read touches neighbours and RMW hides effects. Use mmio for registers.

t.write("ADC1->CR", t.read("ADC1->CR") | 4)   # register via data methods: use t.mmio
t.write("app_delay", "compute_delay()")        # hidden call: refused

The fragments show refused or discouraged patterns, not a working recipe.

Fragments for a scenario body; firmware symbols are illustrative.

← Live windowAll groupsExpressions and memory →