示例#1
0
文件: tcp_echo.c 项目: LucidOne/Rovio
void
net_test(cyg_addrword_t param)
{
    cyg_serial_baud_rate_t old;    
    cyg_ppp_options_t options;
    cyg_ppp_handle_t ppp_handle;

    CYG_TEST_INIT();
    
    diag_printf("Start TCP test - ECHO mode\n");
    init_all_network_interfaces();
    calibrate_load(DESIRED_BACKGROUND_LOAD);
#ifdef CYGPKG_SNMPAGENT
    {
        extern void cyg_net_snmp_init(void);
        cyg_net_snmp_init();
    }
#endif

    old = ppp_test_set_baud( CYGNUM_SERIAL_BAUD_115200 );

    ppp_test_announce( "TCP_ECHO" );
    
    cyg_ppp_options_init( &options );

//    options.debug = 1;
//    options.kdebugflag = 1;
//    options.flowctl = CYG_PPP_FLOWCTL_SOFTWARE;

    ppp_handle = cyg_ppp_up( CYGPKG_PPP_TEST_DEVICE, &options );

    CYG_TEST_INFO( "Waiting for PPP to come up");
    
    cyg_ppp_wait_up( ppp_handle );

    echo_test(param);

    CYG_TEST_INFO( "Bringing PPP down");

    cyg_ppp_down( ppp_handle );
    
    CYG_TEST_INFO( "Waiting for PPP to go down");

    cyg_ppp_wait_down( ppp_handle );

    cyg_thread_delay( 200 );
    
    ppp_test_set_baud( old );

    ppp_test_finish();
    
    CYG_TEST_PASS_FINISH("TCP ECHO test OK");
}
示例#2
0
int main(int argc, char **argv)
{
     // Bring up the TCP/IP network
     init_all_network_interfaces();
     
     for (;;)
     {
          cyg_ppp_options_t options;
          cyg_ppp_handle_t ppp_handle;
          
          // Initialize the options
          cyg_ppp_options_init( &options );
          
          options.script=windows_script;
          options.baud = CYGNUM_SERIAL_BAUD_38400;
          options.flowctl = CYG_PPP_FLOWCTL_NONE;
          options.idle_time_limit = 0; // never shut down.      
          
          // Start up PPP
          ppp_handle = cyg_ppp_up( "/dev/ser0", &options );
          
          // Wait for it to get running
          if( cyg_ppp_wait_up( ppp_handle ) == 0 )
          {
               // Make use of PPP
               for (;;)
               {
                    telnet();
               }
               
               // never reached, but  for illustration:
               
               // Bring PPP link down
               cyg_ppp_down( ppp_handle );
               
               // Wait for connection to go down.
               cyg_ppp_wait_down( ppp_handle );
          }
     }
}
示例#3
0
文件: ppp_up.c 项目: LucidOne/Rovio
static void do_test( cyg_serial_baud_rate_t baud )
{
    cyg_ppp_options_t options;
    cyg_ppp_handle_t ppp_handle;
    int i = 0;

    ppp_test_announce( "PPP_UP" );
    
    cyg_ppp_options_init( &options );

//    options.debug = 1;
//    options.kdebugflag = 1;

    options.baud = baud;
    
    show_network_tables( diag_printf );
    
    ppp_handle = cyg_ppp_up( CYGPKG_PPP_TEST_DEVICE, &options );

    CYG_TEST_INFO( "Waiting for PPP to come up");
    
    cyg_ppp_wait_up( ppp_handle );

    CYG_TEST_INFO( "Waiting until remote end goes down");

    while( cyg_ppp_wait_up( ppp_handle ) == 0 )
    {
        i++;

        if( (i % 60) == 0 )
            show_network_tables( diag_printf );

        cyg_thread_delay(100);
    }
    
    cyg_ppp_wait_down( ppp_handle );
}
示例#4
0
void
net_test(test_param_t param)
{
#ifdef __ECOS
    cyg_serial_baud_rate_t old;    
    cyg_ppp_options_t options;
    cyg_ppp_handle_t ppp_handle;

    CYG_TEST_INIT();
#endif

//    int i;
    if (param == 0) {
        test_printf("Start Network Characterization - SLAVE\n");
#ifdef __ECOS
        init_all_network_interfaces();
        calibrate_load(DESIRED_BACKGROUND_LOAD);
#if 0
// I can see what this is trying to do, but I get "bind: Address already in
// use" errors from the 2nd interface - and the parameter is not used
// anyway, so one thread does quite well enough (but only tests one i/f at
// once).

// Comment in the 'int i' above too.
        for (i = 1;  i < CYGHWR_NET_DRIVERS;  i++) {
            cyg_thread_resume(main_thread_handle[i]);   // Start other threads
        }
#endif
#endif
    }

#ifdef __ECOS

    old = ppp_test_set_baud( CYGNUM_SERIAL_BAUD_115200 );

    ppp_test_announce( "NC_TEST_SLAVE" );
    
    cyg_ppp_options_init( &options );

//    options.debug = 1;
//    options.kdebugflag = 1;

//    options.script = script;
//    options.flowctl = CYG_PPP_FLOWCTL_SOFTWARE;

    ppp_handle = cyg_ppp_up( CYGPKG_PPP_TEST_DEVICE, &options );

    CYG_TEST_INFO( "Waiting for PPP to come up");
    
    cyg_ppp_wait_up( ppp_handle );
#endif
    
    nc_slave(param);
#ifdef CYGDBG_NET_TIMING_STATS
    show_net_times();
#endif

#ifdef __ECOS
    CYG_TEST_INFO( "Bringing PPP down");

    cyg_ppp_down( ppp_handle );
    
    CYG_TEST_INFO( "Waiting for PPP to go down");

    cyg_ppp_wait_down( ppp_handle );

    cyg_thread_delay( 200 );

    ppp_test_set_baud( old );

    ppp_test_finish();

    CYG_TEST_PASS_FINISH( "Network Characterization - SLAVE" );
    
#endif
    
    cyg_test_exit();
}