Mercurial > ecos
changeset 1592:a9676dbe50b5
* src/chat.c: Script now returns success when it runs to completion
| author | nickg |
|---|---|
| date | Thu, 15 Apr 2004 15:51:54 +0000 |
| parents | 634e666b376d |
| children | 8cda65846a87 |
| files | packages/net/ppp/current/ChangeLog packages/net/ppp/current/doc/ppp.sgml packages/net/ppp/current/src/chat.c packages/net/ppp/current/tests/chat.c |
| diffstat | 4 files changed, 23 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/net/ppp/current/ChangeLog +++ b/packages/net/ppp/current/ChangeLog @@ -1,3 +1,7 @@ +2004-04-15 Oyvind Harboe <oyvind.harboe@zylin.com> + + * src/chat.c: Script now returns success when it runs to completion + 2004-03-31 John Dallaway <jld@ecoscentric.com> * cdl/ppp.cdl: Correct capitalisation in display strings.
--- a/packages/net/ppp/current/doc/ppp.sgml +++ b/packages/net/ppp/current/doc/ppp.sgml @@ -875,6 +875,12 @@ linkend="ppp-chat"> for full detail of t </para> <para> +The return value of this function will be zero if the chat script +fails for any reason, such as an ABORT or a timeout. If the end of the +script is reached, then the return value will be non-zero. +</para> + +<para> Under normal use this function is called from the PPP subsystem if the <structname>cyg_ppp_options_t</structname> <structfield>script</structfield> field is set to a
--- a/packages/net/ppp/current/src/chat.c +++ b/packages/net/ppp/current/src/chat.c @@ -114,9 +114,6 @@ static cyg_io_handle_t cyg_ppp_chat_hand static char cyg_ppp_chat_buffer[CHAT_STRING_LENGTH]; static char cyg_ppp_chat_expect_buffer[CHAT_STRING_LENGTH]; -// success indicator -static int cyg_ppp_chat_success; - //===================================================================== // Timeout alarm function // @@ -367,8 +364,8 @@ externC cyg_int32 cyg_ppp_chat( const ch { const char *s; Cyg_ErrNo err; + cyg_int32 result = 1; - cyg_ppp_chat_success = 0; cyg_ppp_chat_thread = cyg_thread_self(); cyg_ppp_chat_abort_count = 0; cyg_ppp_chat_timeout = 45; @@ -387,7 +384,7 @@ externC cyg_int32 cyg_ppp_chat( const ch // Now loop over script handling the elements in turn - while( (s = *script++) != NULL && cyg_ppp_chat_success == 0 ) + while( (s = *script++) != NULL ) { int what = cyg_ppp_chat_expect( s ); @@ -395,7 +392,7 @@ externC cyg_int32 cyg_ppp_chat( const ch if( what == CHAT_FAIL ) { - cyg_ppp_chat_success = 1; + result = 0; break; } @@ -429,6 +426,12 @@ externC cyg_int32 cyg_ppp_chat( const ch } } + if (s==NULL) + { + // the script ran to completion + result = 1; + } + // Finally, wait for the serial device to drain { cyg_uint32 zero = 0; @@ -440,7 +443,7 @@ externC cyg_int32 cyg_ppp_chat( const ch } - return cyg_ppp_chat_success; + return result; } //=====================================================================
--- a/packages/net/ppp/current/tests/chat.c +++ b/packages/net/ppp/current/tests/chat.c @@ -114,9 +114,9 @@ static struct test_info cyg_int32 result; } tests[] = { - { "CHAT_TEST_1" , script1 , 0 }, // Simple test to completion - { "CHAT_TEST_2" , script1 , 1 }, // Expects an ABORT - { "CHAT_TEST_3" , script1 , 1 }, // Expects a timeout + { "CHAT_TEST_1" , script1 , 1 }, // Simple test to completion + { "CHAT_TEST_2" , script1 , 0 }, // Expects an ABORT + { "CHAT_TEST_3" , script1 , 0 }, // Expects a timeout { NULL , NULL , 0 } };
