Beispiel #1
0
// do the com port and configuration stuff
static GOOD_OR_BAD DS2480_big_reset(struct connection_in * in)
{
    struct port_in * pin = in->pown ;

    switch (pin->type) {
    case ct_telnet:
        pin->timeout.tv_sec = Globals.timeout_network ;
        pin->timeout.tv_usec = 0 ;
        return DS2480_big_reset_serial(in) ;

    case ct_serial:
    default:
        pin->timeout.tv_sec = Globals.timeout_serial ;
        pin->timeout.tv_usec = 0 ;

        pin->flow = flow_none ;
        RETURN_GOOD_IF_GOOD( DS2480_big_reset_serial(in)) ;

        pin->flow = flow_none ;
        RETURN_GOOD_IF_GOOD( DS2480_big_reset_serial(in)) ;

        pin->flow = flow_hard ;
        RETURN_GOOD_IF_GOOD( DS2480_big_reset_serial(in)) ;

        return gbBAD ;
    }
}
Beispiel #2
0
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;
}
Beispiel #3
0
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;
}
Beispiel #4
0
// 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) ;
}
/** readin_data
  Send 0xFFs and return response block
 */
GOOD_OR_BAD BUS_readin_bits(BYTE * data, const size_t len, const struct parsedname *pn)
{
	memset(data, 0xFF, (size_t) len) ;
	RETURN_GOOD_IF_GOOD( BUS_sendback_bits( data, data, len, pn) ) ;

	STAT_ADD1(BUS_readin_data_errors);
	return gbBAD;
}
Beispiel #6
0
// Make several attempts to initialize -- based on Digitemp example
static GOOD_OR_BAD DS2480_initialize_repeatedly(struct connection_in * in)
{
    int init_cycles ;

    for ( init_cycles = 0 ; init_cycles < DS9097U_INIT_CYCLES ; ++init_cycles ) {
        LEVEL_DEBUG("Attempt %d of %d to initialize the DS9097U",init_cycles,DS9097U_INIT_CYCLES) ;
        RETURN_GOOD_IF_GOOD( DS2480_big_reset(in) ) ;
    }

    return gbBAD ;
}
Beispiel #7
0
// bus locking done at a higher level
GOOD_OR_BAD LINK_detect(struct port_in *pin)
{
	struct connection_in * in = pin->first ;

	if (pin->init_data == NULL) {
		// requires input string
		LEVEL_DEFAULT("LINK busmaster requires port name");
		return gbBAD;
	}

	COM_set_standard( in ) ; // standard COM port settings

	switch( pin->type ) {
		case ct_telnet:
			// LinkHub-E
			pin->baud = B115200 ;
			LEVEL_DEBUG("Attempt connection to networked LINK at 115200 baud");
			RETURN_GOOD_IF_GOOD(  LINK_detect_net( in )  );

			// Xport or ser2net
			pin->baud = B9600 ;
			LEVEL_DEBUG("Attempt connection to networked LINK at 9600 baud");
			RETURN_GOOD_IF_GOOD(  LINK_detect_net( in )  );

			break ;

			

		case ct_serial:
			pin->baud = B9600 ;

			pin->flow = flow_first ;
			RETURN_GOOD_IF_GOOD( LINK_detect_serial(in) ) ;

			LEVEL_DEBUG("Second attempt at serial LINK setup");
			pin->flow = flow_second ;
			RETURN_GOOD_IF_GOOD( LINK_detect_serial(in) ) ;

			LEVEL_DEBUG("Third attempt at serial LINK setup");
			pin->flow = flow_first ;
			RETURN_GOOD_IF_GOOD( LINK_detect_serial(in) ) ;

			LEVEL_DEBUG("Fourth attempt at serial LINK setup");
			pin->flow = flow_second ;
			RETURN_GOOD_IF_GOOD( LINK_detect_serial(in) ) ;
			break ;

		default:
			return gbBAD ;
	}
	return gbBAD ;
}
/** BUS_send_data
    Send a data and expect response match
 */
GOOD_OR_BAD BUS_send_bits(const BYTE * data, const size_t len, const struct parsedname *pn)
{
	BYTE resp[len];

	if (len == 0) {
		return gbGOOD;
	}

	if ( BAD( BUS_sendback_bits(data, resp, len, pn) ) ) {
		STAT_ADD1_BUS(e_bus_errors, pn->selected_connection);
		return gbBAD ;
	}

	RETURN_GOOD_IF_GOOD( BUS_compare_bits( data, resp, len ) ) ;

	LEVEL_DEBUG("Response doesn't match bits sent");
	STAT_ADD1_BUS(e_bus_errors, pn->selected_connection);
	return gbBAD ;
}
Beispiel #9
0
static GOOD_OR_BAD OW_Hinit(struct parsedname * pn)
{
	int init = 1;
	// clear, display on, mode
	BYTE start[] = { NIBBLE_ONE(LCD_COMMAND_ATTENTION), };
	BYTE next[] = {
		NIBBLE_ONE(LCD_COMMAND_ATTENTION),
		NIBBLE_ONE(LCD_COMMAND_ATTENTION),
		NIBBLE_ONE(LCD_COMMAND_4_BIT),
		NIBBLE_CTRL(LCD_COMMAND_4_BIT_2_LINES),
	};
	BYTE data[6];

	// already done?
	RETURN_GOOD_IF_GOOD( Cache_Get_SlaveSpecific(&init, sizeof(init), SlaveSpecificTag(INI), pn) );
	
	if ( BAD( OW_w_control(0x04, pn) )	// strobe
		|| BAD( OW_r_reg(data, pn) ) ) {
		LEVEL_DEBUG("Trouble sending strobe to Hobbyboard LCD") ;
		return gbBAD;
	}
	if ( data[5] != 0x84 )	{
		LEVEL_DEBUG("LCD is not powered"); // not powered
		return gbBAD ;
	}
	if ( BAD( OW_c_latch(pn) ) ) {
		LEVEL_DEBUG("Trouble clearing latches") ;
		return gbBAD ;
	}// clear PIOs
	if ( BAD( OW_w_pios(start, 1, pn) ) ) {
		LEVEL_DEBUG("Error sending initial attention");	
		return gbBAD;
	}
	UT_delay(5);
	if ( BAD( OW_w_pios(next, 5, pn) ) ) {
		LEVEL_DEBUG("Error sending setup commands");	
		return gbBAD;
	}
	Cache_Add_SlaveSpecific(&init, sizeof(init), SlaveSpecificTag(INI), pn);
	return gbGOOD ;
}