From 9e4a37c95739a524db9f7b8f7f64fa3c25264879 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Tue, 5 Mar 2013 20:56:33 +0100 Subject: Fix doc typos for R16B01 --- system/doc/design_principles/fsm.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/doc/design_principles/fsm.xml b/system/doc/design_principles/fsm.xml index edb2e20605..bd19b88e2d 100644 --- a/system/doc/design_principles/fsm.xml +++ b/system/doc/design_principles/fsm.xml @@ -87,7 +87,7 @@ locked({button, Digit}, {SoFar, Code}) -> case [Digit|SoFar] of Code -> do_unlock(), - {next_state, open, {[], Code}, 3000}; + {next_state, open, {[], Code}, 30000}; Incomplete when length(Incomplete) {next_state, locked, {Incomplete, Code}}; _Wrong -> @@ -203,7 +203,7 @@ open(timeout, State) ->
Timeouts -

When a correct code has been givened, the door is unlocked and +

When a correct code has been given, the door is unlocked and the following tuple is returned from locked/2:

{next_state, open, {[], Code}, 30000}; -- cgit v1.2.3 From 0792d2102908a1008b08c37e1015ba5e6cb88882 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 7 Mar 2013 11:41:28 +0100 Subject: Fix gen_fsm example code --- system/doc/design_principles/fsm.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/system/doc/design_principles/fsm.xml b/system/doc/design_principles/fsm.xml index bd19b88e2d..7decbb48cd 100644 --- a/system/doc/design_principles/fsm.xml +++ b/system/doc/design_principles/fsm.xml @@ -75,7 +75,7 @@ StateName(Event, StateData) -> -export([init/1, locked/2, open/2]). start_link(Code) -> - gen_fsm:start_link({local, code_lock}, code_lock, Code, []). + gen_fsm:start_link({local, code_lock}, code_lock, lists:reverse(Code, []). button(Digit) -> gen_fsm:send_event(code_lock, {button, Digit}). @@ -106,7 +106,8 @@ open(timeout, State) -> calling code_lock:start_link(Code):

start_link(Code) -> - gen_fsm:start_link({local, code_lock}, code_lock, Code, []). + gen_fsm:start_link({local, code_lock}, code_lock, lists:reverse(Code), []). +

start_link calls the function gen_fsm:start_link/4. This function spawns and links to a new process, a gen_fsm.

@@ -130,8 +131,8 @@ start_link(Code) -> corresponding to one process contained in one module.

-

The third argument, Code, is a term which is passed - as-is to the callback function init. Here, init +

The third argument, Code, is a list of digits which is passed + reversed to the callback function init. Here, init gets the correct code for the lock as indata.

-- cgit v1.2.3