// bus locking at a higher level GOOD_OR_BAD DS2480_detect(struct port_in *pin) { struct connection_in * in = pin->first ; if (pin->init_data == NULL) { LEVEL_DEFAULT("DS2480B-based bus master needs a port name"); return gbBAD; } /* Set up low-level routines */ DS2480_setroutines(in); in->overdrive = 0 ; in->flex = Globals.serial_flextime ; pin->busmode = bus_serial; // Now set desired baud and polarity // BUS_reset will do the actual changes in->master.serial.reverse_polarity = Globals.serial_reverse ; COM_set_standard( in ) ; // standard COM port settings // first pass with hardware flow control RETURN_GOOD_IF_GOOD( DS2480_detect_serial(in) ) ; pin->flow = flow_second; // flow control RETURN_BAD_IF_BAD(COM_change(in)) ; return DS2480_detect_serial(in) ; }
static void LINK_set_baud(struct connection_in * in) { struct port_in * pin = in->pown ; char * speed_code ; if ( pin->type == ct_telnet ) { // telnet pinned at 115200 return ; } COM_BaudRestrict( &(pin->baud), B9600, B19200, B38400, B57600, 0 ) ; LEVEL_DEBUG("to %d",COM_BaudRate(pin->baud)); // Find rate parameter switch ( pin->baud ) { case B9600: COM_break(in) ; LINK_flush(in); return ; case B19200: speed_code = "," ; break ; case B38400: speed_code = "`" ; break ; #ifdef B57600 /* MacOSX support max 38400 in termios.h ? */ case B57600: speed_code = "^" ; break ; #endif default: LEVEL_DEBUG("Unrecognized baud rate"); return ; } LEVEL_DEBUG("LINK change baud string <%s>",speed_code); LINK_flush(in); if ( BAD( LINK_write(LINK_string(speed_code), 1, in) ) ) { LEVEL_DEBUG("LINK change baud error -- will return to 9600"); pin->baud = B9600 ; ++in->changed_bus_settings ; return ; } // Send configuration change LINK_flush(in); // Change OS view of rate UT_delay(5); COM_change(in) ; UT_delay(5); LINK_slurp(in); return ; }
/* Puts in 9600 baud */ static GOOD_OR_BAD DS9097_pre_reset(struct connection_in *in ) { struct port_in * pin = in->pown ; RETURN_BAD_IF_BAD( COM_test(in) ) ; /* 8 data bits */ pin->bits = 8 ; pin->baud = B9600 ; if ( BAD( COM_change(in)) ) { ERROR_CONNECT("Cannot set attributes: %s", SAFESTRING(DEVICENAME(in))); DS9097_post_reset( in ) ; return gbBAD; } return gbGOOD; }
/* Restore terminal settings (serial port settings) */ static void DS9097_post_reset(struct connection_in *in ) { struct port_in * pin = in->pown ; if (Globals.eightbit_serial) { /* coninue with 8 data bits */ pin->bits = 8; } else { /* 6 data bits, Receiver enabled, Hangup, Dont change "owner" */ pin->bits = 6; } #ifndef B115200 /* MacOSX support max 38400 in termios.h ? */ pin->baud = B38400 ; #else pin->baud = B115200 ; #endif /* Flush the input and output buffers */ COM_flush(in); // Adds no appreciable time COM_change(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 ; }