# HG changeset patch # User nickg # Date 1082044314 0 # Node ID a9676dbe50b556d23f42db871bc934a5bd338834 # Parent 634e666b376dc51f928856312a09970d64324bb8 * src/chat.c: Script now returns success when it runs to completion diff --git a/packages/net/ppp/current/ChangeLog b/packages/net/ppp/current/ChangeLog --- a/packages/net/ppp/current/ChangeLog +++ b/packages/net/ppp/current/ChangeLog @@ -1,3 +1,7 @@ +2004-04-15 Oyvind Harboe + + * src/chat.c: Script now returns success when it runs to completion + 2004-03-31 John Dallaway * cdl/ppp.cdl: Correct capitalisation in display strings. diff --git a/packages/net/ppp/current/doc/ppp.sgml b/packages/net/ppp/current/doc/ppp.sgml --- 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 +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. + + + Under normal use this function is called from the PPP subsystem if the cyg_ppp_options_t script field is set to a diff --git a/packages/net/ppp/current/src/chat.c b/packages/net/ppp/current/src/chat.c --- 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; } //===================================================================== diff --git a/packages/net/ppp/current/tests/chat.c b/packages/net/ppp/current/tests/chat.c --- 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 } };