From c09286901e2ddccddd6047b02f80fb354854b53e Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Mon, 1 Aug 2022 11:47:11 +0200 Subject: [PATCH] Make modbus library compatible with older versions of Toit. (#13) Fixes #12. --- examples/package.lock | 4 ++-- package.lock | 4 ++-- package.yaml | 2 +- src/bus.toit | 18 +++++++++++++++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/examples/package.lock b/examples/package.lock index 339300f..e5c5141 100644 --- a/examples/package.lock +++ b/examples/package.lock @@ -7,5 +7,5 @@ packages: rs485: toit-rs485 toit-rs485: url: github.com/toitware/toit-rs485 - version: 1.0.0 - hash: 2e8d0ae08c97a5dcba69b4e438408ef374c2c63f + version: 1.0.1 + hash: 854d96a9d27b6ce7325a9698001087b292f4b4b5 diff --git a/package.lock b/package.lock index 3771b8f..2461262 100644 --- a/package.lock +++ b/package.lock @@ -3,5 +3,5 @@ prefixes: packages: toit-rs485: url: github.com/toitware/toit-rs485 - version: 1.0.0 - hash: 2e8d0ae08c97a5dcba69b4e438408ef374c2c63f + version: 1.0.1 + hash: 854d96a9d27b6ce7325a9698001087b292f4b4b5 diff --git a/package.yaml b/package.yaml index 9de36f5..3407802 100644 --- a/package.yaml +++ b/package.yaml @@ -1,4 +1,4 @@ dependencies: rs485: url: github.com/toitware/toit-rs485 - version: ^1.0.0 + version: ^1.0.1 diff --git a/src/bus.toit b/src/bus.toit index fea4489..70abdd9 100644 --- a/src/bus.toit +++ b/src/bus.toit @@ -131,6 +131,22 @@ class Modbus: run: transactions_.run +/** +A signal synchronization primitive. + +This class is a partial copy of the 'Signal' class from the 'monitor' library. Older + versions of Toit don't have that class yet, and for backwards compatilibity we thus + copied it here. +*/ +monitor Signal_: + /** Waits until the $condition is satisfied. */ + wait [condition] -> none: + await: condition.call + + /** Raises the signal, making waiters evaluate their condition. */ + raise -> none: + + /** A transaction manager. @@ -145,7 +161,7 @@ class TransactionManager_: max_concurrent_transactions_/int? transactions_/Map ::= {:} - signal_/monitor.Signal ::= monitor.Signal + signal_/Signal_ ::= Signal_ run_task_ := null next_id_ := 0