コード例 #1
0
ファイル: ow_w1_monitor.c プロジェクト: M-o-a-T/owfs
GOOD_OR_BAD W1_monitor_detect(struct port_in *pin)
{
	(void) pin ;
	LEVEL_DEFAULT("W1 (the linux kernel 1-wire system) is not supported");
	return gbBAD ;
}
コード例 #2
0
ファイル: ow_parse_external.c プロジェクト: M-o-a-T/owfs
/*
 * property
 * family
 * structure
 * read
 * write
 * data
 * other
 * */
void AddProperty( char * input_string, enum external_type et )
{
	char * s_family = NULL ;
	char * s_property = NULL ;
	char * s_dummy ;
	ssize_t s_array ;
	enum ag_combined s_combined ;
	enum ag_index s_index_type ;
	enum ft_format s_format ;
	ssize_t s_length ;
	enum fc_change s_change ;
	char * s_read = NULL ;
	char * s_write = NULL ;
	char * s_data = NULL ;
	char * s_other = NULL;
	char * start_pointer = input_string ;
	
	if ( input_string == NULL ) {
		return ;
	}
	
	if ( ! Globals.allow_external ) {
		LEVEL_DEBUG("External prgroams not supported by %s",Globals.argv[0]) ;
		return ;
	}

	// property
	GetQuotedString( property ) ;
	
	// family
	GetQuotedString( family ) ;

	// type
	GetQuotedString( dummy ) ;
	switch ( s_dummy[0] ) {
		case 'D':
			s_length = PROPERTY_LENGTH_DIRECTORY ;
			s_format = ft_directory ;
			break ;
		case 'i':
			s_length = PROPERTY_LENGTH_INTEGER ;
			s_format = ft_integer ;
			break ;
		case 'u':
			s_length = PROPERTY_LENGTH_UNSIGNED ;
			s_format = ft_unsigned ;
			break ;
		case 'f':
			s_length = PROPERTY_LENGTH_FLOAT ;
			s_format = ft_float ;
			break ;
		case 'a':
			s_length = 1 ;
			s_format = ft_ascii ;
			break ;
		case 'b':
			s_length = 1 ;
			s_format = ft_binary ;
			break ;
		case 'y':
			s_length = PROPERTY_LENGTH_YESNO ;
			s_format = ft_yesno ;
			break ;
		case 'd':
			s_length = PROPERTY_LENGTH_DATE ;
			s_format = ft_date ;
			break ;
		case 't':
			s_length = PROPERTY_LENGTH_TEMP ;
			s_format = ft_temperature ;
			break ;
		case 'g':
			s_length = PROPERTY_LENGTH_TEMPGAP ;
			s_format = ft_tempgap ;
			break ;
		case 'p':
			s_length = PROPERTY_LENGTH_PRESSURE ;
			s_format = ft_pressure ;
			break ;
		default:
			LEVEL_DEFAULT("Unrecognized variable type <%s> for property <%s> family <%s>",s_dummy,s_property,s_family);
			s_format = ft_unknown ;
			return ;
	}
	if ( s_dummy[1] ) { 
		int temp_length ;
		temp_length = strtol( &s_dummy[1], NULL, 0 ) ;
		if ( temp_length < 1 ) {
			LEVEL_DEFAULT("Unrecognized variable length <%s> for property <%s> family <%s>",s_dummy,s_property,s_family);
			return ;
		}
		s_length = temp_length ;
	}

	// array
	GetQuotedString( dummy ) ;
	switch ( s_dummy[0] ) {
		case '1':
		case '0':
		case '\0':
			s_combined = ag_separate ;
			s_index_type = ag_numbers ;
			s_array = 1 ;
			break ;
		case '-':
			s_array = 1 ;
			switch ( s_dummy[1] ) {
				case '1':
					s_combined = ag_sparse ;
					s_index_type = ag_numbers ;
					break ;
				default:
					s_combined = ag_sparse ;
					s_index_type = ag_letters ;
					break ;
			}
			break ;
		case '+':
			if ( isalpha( (int) s_dummy[1] ) ) {
				s_array = toupper( (int) s_dummy[1] ) - 'A' ;
				s_combined = ag_aggregate ;
				s_index_type = ag_letters ;
			} else {
				s_array = strtol( s_dummy, NULL, 0 ) ;
				s_combined = ag_aggregate ;
				s_index_type = ag_numbers ;
			}
			break ;
		default:
			if ( isalpha( (int) s_dummy[0] ) ) {
				s_array = toupper( (int) s_dummy[0] ) - 'A' ;
				s_combined = ag_separate ;
				s_index_type = ag_letters ;
			} else {
				s_array = strtol( s_dummy, NULL, 0 ) ;
				s_combined = ag_separate ;
				s_index_type = ag_numbers ;
			}
			break ;
	}
	if ( s_array < 1 ) {
		LEVEL_DEFAULT("Unrecognized array type <%s> for property <%s> family <%s>",s_dummy,s_property,s_family);
		return ;
	}

	// persistance
	GetQuotedString( dummy ) ;
	switch ( s_dummy[0] ) {
		case 'f':
			s_change = fc_static ;
			break ;
		case 's':
			s_change = fc_stable ;
			break ;
		case 'v':
			s_change = fc_volatile ;
			break ;
		case 't':
			s_change = fc_second ;
			break ;
		case 'u':
			s_change = fc_uncached ;
			break ;
		default:
			LEVEL_DEFAULT("Unrecognized persistance <%s> for property <%s> family <%s>",s_dummy,s_property,s_family);
			return ;
	}

	// read
	GetQuotedString( read ) ;

	// write
	GetQuotedString( write ) ;

	// data
	GetQuotedString( data ) ;

	// other
	GetQuotedString( other ) ;

	// test minimums
	if ( strlen( s_family ) > 0 && strlen( s_property ) > 0 ) {
		// Actually add
		AddFamilyToTree( s_family ) ;
		AddPropertyToTree( s_property, s_family, s_format, s_array, s_combined, s_index_type, s_length, s_change, s_read, s_write, s_data, s_other, et ) ;
		create_subdirs( s_property, s_family ) ;
	}

	// Clean up
	owfree( s_property ) ;
	owfree( s_family ) ;
	owfree( s_read ) ;
	owfree( s_write ) ;
	owfree( s_data ) ;
	owfree( s_other ) ;
}
コード例 #3
0
ファイル: ow_link.c プロジェクト: GrandHsu/iicontrollibs
static GOOD_OR_BAD LINK_version(struct connection_in * in)
{
	char version_string[MAX_LINK_VERSION_LENGTH+1] ;
	enum { lvs_string, lvs_0d, } lvs = lvs_string ; // read state machine
	int version_index ;

	in->master.link.tmode = e_link_t_unknown ;
	in->master.link.qmode = e_link_t_unknown ;

	// clear out the buffer
	memset(version_string, 0, MAX_LINK_VERSION_LENGTH+1);

	if ( BAD( LINK_write(LINK_string(" "), 1, in) ) ) {
		LEVEL_DEFAULT("LINK version string cannot be requested");
		return gbBAD ;
	}
		
	/* read the version string */
	LEVEL_DEBUG("Checking LINK version");

	// need to read 1 char at a time to get a short string
	for ( version_index=0 ; version_index<MAX_LINK_VERSION_LENGTH ; ++version_index ) {
		if ( BAD( LINK_read_true_length( (BYTE *) &(version_string[version_index]), 1, in)) ) {
			LEVEL_DEBUG("Cannot read a full CRLF version string");
			switch ( lvs ) {
				case lvs_string:
					LEVEL_DEBUG("Found string <%s> but no 0x0D 0x0A",version_string) ;
					return gbBAD ;
				case lvs_0d:
					LEVEL_DEBUG("Found string <%s> but no 0x0A",version_string) ;
					return gbBAD ;
				default:
					return gbBAD ;
			}
		}
		
		switch( version_string[version_index] ) {
			case 0x0D:
				switch ( lvs ) {
					case lvs_string:
						lvs = lvs_0d ;
						// end of text
						version_string[version_index] = '\0' ;
						break ;
					case lvs_0d:
						LEVEL_DEBUG("Extra CR char in <%s>",version_string);
						return gbBAD ;
				}
				break ;
			case 0x0A:
				switch ( lvs ) {
					case lvs_string:
						LEVEL_DEBUG("No CR before LF char in <%s>",version_string);
						return gbBAD ;
					case lvs_0d:
						return LinkVersion_knownstring( version_string, in ) ;
				}
			default:
				switch ( lvs ) {
					case lvs_string:
						// add to string
						break ; 
					case lvs_0d:
						++in->CRLF_size;
						break ;
				}
				break ;
		}
	}
	LEVEL_DEFAULT("LINK version string too long. <%s> greater than %d chars",version_string,MAX_LINK_VERSION_LENGTH);
	return gbBAD ;
}
コード例 #4
0
ファイル: ow_ds9097.c プロジェクト: GrandHsu/iicontrollibs
// 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 ;
}