static GOOD_OR_BAD LINK_detect_net(struct connection_in * in) { struct port_in * pin = in->pown ; /* Set up low-level routines */ LINKE_setroutines(in); pin->timeout.tv_sec = 0 ; pin->timeout.tv_usec = 300000 ; /* Open the tcp port */ RETURN_BAD_IF_BAD( COM_open(in) ) ; LEVEL_DEBUG("Slurp in initial bytes"); // LINK_slurp( in ) ; UT_delay(1000) ; // based on http://morpheus.wcf.net/phpbb2/viewtopic.php?t=89&sid=3ab680415917a0ebb1ef020bdc6903ad LINK_slurp( in ) ; // LINK_flush(in); pin->dev.telnet.telnet_negotiated = needs_negotiation ; RETURN_GOOD_IF_GOOD( LINK_version(in) ) ; // second try -- send a break and line settings LEVEL_DEBUG("Second try -- send BREAK"); COM_flush(in) ; COM_break(in); telnet_change(in); // LINK_slurp( in ) ; RETURN_GOOD_IF_GOOD( LINK_version(in) ) ; LEVEL_DEFAULT("LINK detection error"); COM_close(in) ; return gbBAD; }
static GOOD_OR_BAD LINK_detect_serial(struct connection_in * in) { struct port_in * pin = in->pown ; /* Set up low-level routines */ LINK_setroutines(in); pin->timeout.tv_sec = Globals.timeout_serial ; pin->timeout.tv_usec = 0 ; /* Open the com port */ RETURN_BAD_IF_BAD(COM_open(in)) ; //COM_break( in ) ; LEVEL_DEBUG("Slurp in initial bytes"); LINK_slurp( in ) ; UT_delay(100) ; // based on http://morpheus.wcf.net/phpbb2/viewtopic.php?t=89&sid=3ab680415917a0ebb1ef020bdc6903ad LINK_slurp( in ) ; RETURN_GOOD_IF_GOOD( LINK_version(in) ) ; LEVEL_DEFAULT("LINK detection error"); serial_powercycle(in) ; LEVEL_DEBUG("Slurp in initial bytes"); LINK_slurp( in ) ; UT_delay(100) ; // based on http://morpheus.wcf.net/phpbb2/viewtopic.php?t=89&sid=3ab680415917a0ebb1ef020bdc6903ad LINK_slurp( in ) ; RETURN_GOOD_IF_GOOD( LINK_version(in) ) ; LEVEL_DEFAULT("LINK detection error"); COM_close(in) ; return gbBAD; }
// do the com port and configuration stuff static GOOD_OR_BAD DS2480_big_reset_serial(struct connection_in * in) { BYTE reset_byte = (BYTE) ( CMD_COMM | FUNCTSEL_RESET | SPEEDSEL_STD ); // Open the com port in 9600 Baud. RETURN_BAD_IF_BAD(COM_open(in)) ; // send a break to reset the DS2480 COM_break(in); // It's in command mode now in->master.serial.mode = ds2480b_command_mode ; // send the timing byte (A reset command at 9600 baud) DS2480_write( &reset_byte, 1, in ) ; // delay to let line settle UT_delay(4); // flush the buffers DS2480_flush(in); // ignore response DS2480_slurp( in ) ; // Now set desired baud and polarity // BUS_reset will do the actual changes in->changed_bus_settings = 1 ; // Force a mode change // Send a reset again LEVEL_DEBUG("Send the initial reset to the bus master."); DS2480_reset_in(in) ; // delay to let line settle UT_delay(400); // flush the buffers DS2480_flush(in); // ignore response DS2480_slurp( in ) ; // Now set desired baud and polarity return DS2480_big_configuration(in) ; }
// no bus locking here (higher up) GOOD_OR_BAD DS9097_detect(struct port_in *pin) { struct connection_in * in = pin->first ; /* Set up low-level routines */ DS9097_setroutines(in); in->Adapter = adapter_DS9097; // in->adapter_name already set, to support HA3 and HA4B pin->busmode = bus_passive; // in case initially tried DS9097U /* open the COM port in 9600 Baud */ COM_set_standard( in ) ; // standard COM port settings pin->vmin = 1; // minimum chars pin->vtime = 0; // decisec wait if (pin->init_data == NULL) { LEVEL_DEFAULT("DS9097 (passive) busmaster requires port name"); return gbBAD; } RETURN_BAD_IF_BAD(COM_open(in)) ; pin->flow = flow_first; // flow control switch( DS9097_reset_in(in) ) { case BUS_RESET_OK: case BUS_RESET_SHORT: return gbGOOD ; default: break ; } if ( GOOD(serial_powercycle(in)) ) { switch( DS9097_reset_in(in) ) { case BUS_RESET_OK: case BUS_RESET_SHORT: return gbGOOD ; default: break ; } } /* open the COM port in 9600 Baud */ /* Second pass */ pin->flow = flow_second ; RETURN_BAD_IF_BAD(COM_change(in)) ; switch( DS9097_reset_in(in) ) { case BUS_RESET_OK: case BUS_RESET_SHORT: return gbGOOD ; default: break ; } /* open the COM port in 9600 Baud */ /* Third pass, hardware flow control */ pin->flow = flow_first ; RETURN_BAD_IF_BAD(COM_change(in)) ; switch( DS9097_reset_in(in) ) { case BUS_RESET_OK: case BUS_RESET_SHORT: return gbGOOD ; default: break ; } return gbBAD ; }