• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ BAD函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中BAD函数的典型用法代码示例。如果您正苦于以下问题:C++ BAD函数的具体用法?C++ BAD怎么用?C++ BAD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了BAD函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: BUS_ERROR_fix

static void BUS_ERROR_fix(const struct parsedname *pn)
{
	LEVEL_DEBUG("DS9490_Reset: ERROR -- will attempt a fix");
	/* FIXME: FIXED. In ow_usb_msg.c an USB-reset was was issued:
	* USB_Control_Msg(CONTROL_CMD, CTL_RESET_DEVICE, 0x0000, pn) ;
	* So we need to setup the Adapter again 
	* Though here is probably the wrong place, duplicated code from _setup_adaptor
	*/

	// enable both program and strong pulses
	if ( BAD( USB_Control_Msg(MODE_CMD, MOD_PULSE_EN, ENABLE_PROGRAM_AND_PULSE, pn)) ) {
		LEVEL_DATA("EnableProgram error");
	}
	// enable speed changes
	if ( BAD( USB_Control_Msg(MODE_CMD, MOD_SPEED_CHANGE_EN, 1, pn)) ) {
		LEVEL_DATA("RESET_Error: SpeedEnable error");
	}
	// set the strong pullup duration to infinite
	if ( BAD( USB_Control_Msg(COMM_CMD, COMM_SET_DURATION | COMM_IM, 0x0000, pn)) ) {
		LEVEL_DATA("StrongPullup error");
	}
	
	// Don't set speed right now, it calls reset for infinite recursion. Just set for next pass
	++ 	pn->selected_connection->changed_bus_settings ;
}
开发者ID:M-o-a-T,项目名称:owfs,代码行数:25,代码来源:ow_ds9490.c


示例2: DS9490_overdrive

// Switch to overdrive speed -- 3 tries
static GOOD_OR_BAD DS9490_overdrive(const struct parsedname *pn)
{
	BYTE sp = _1W_OVERDRIVE_SKIP_ROM;
	BYTE resp;
	int i;

	// we need to change speed to overdrive
	for (i = 0; i < 3; i++) {
		LEVEL_DATA("set overdrive speed. Attempt %d",i);
		if ( BAD( gbRESET(BUS_reset(pn)) ) ) {
			continue;
		}
		if ( BAD( DS9490_sendback_data(&sp, &resp, 1, pn) ) || (_1W_OVERDRIVE_SKIP_ROM != resp) ) {
			LEVEL_DEBUG("error setting overdrive %.2X/0x%02X", _1W_OVERDRIVE_SKIP_ROM, resp);
			continue;
		}
		if ( GOOD( USB_Control_Msg(MODE_CMD, MOD_1WIRE_SPEED, ONEWIREBUSSPEED_OVERDRIVE, pn)) ) {
			LEVEL_DEBUG("speed is now set to overdrive");
			return gbGOOD;
		}
	}

	LEVEL_DEBUG("Error setting overdrive after 3 retries");
	return gbBAD;
}
开发者ID:M-o-a-T,项目名称:owfs,代码行数:26,代码来源:ow_ds9490.c


示例3: FS_w_vib_mode

static ZERO_OR_ERROR FS_w_vib_mode(struct one_wire_query *owq)
{
	struct parsedname *pn = PN(owq);
	UINT vib_request = OWQ_U(owq) ;
	BYTE vib_stored ;

	switch (vib_request) {
		case e_mVM001_peak:
		case e_mVM001_rms:
		case e_mVM001_multi:
			break ;
		default:
			return -EINVAL ;
	}
	
	if ( BAD( Cache_Get_SlaveSpecific(&vib_stored, sizeof(vib_stored), SlaveSpecificTag(VIB), pn)) ) {
		if ( vib_stored == vib_request ) {
			return 0 ;
		}
	}
	
	if ( BAD( OW_set_vib_mode( vib_request, pn ) ) ) {
		return -EINVAL ;
	}

	Cache_Add_SlaveSpecific(&vib_request, sizeof(vib_request), SlaveSpecificTag(VIB), pn);
	
	return 0 ;
}
开发者ID:GrandHsu,项目名称:iicontrollibs,代码行数:29,代码来源:ow_cmciel.c


示例4: LINK_reset_in

static RESET_TYPE LINK_reset_in(struct connection_in * in)
{
	BYTE resp[1+in->CRLF_size];

	if (in->changed_bus_settings > 0) {
		--in->changed_bus_settings ;
		LINK_set_baud(in);	// reset paramters
	} else {
		LINK_flush(in);
	}

	if ( BAD(LINK_write(LINK_string("r"), 1, in) || BAD( LINK_read(resp, 1, in))) ) {
		LEVEL_DEBUG("Error resetting LINK device");
		LINK_slurp(in);
		return BUS_RESET_ERROR;
	}

	switch (resp[0]) {

	case 'P':
		in->AnyDevices = anydevices_yes;
		return BUS_RESET_OK;
	case 'N':
		in->AnyDevices = anydevices_no;
		return BUS_RESET_OK;
	case 'S':
		return BUS_RESET_SHORT;
	default:
		LEVEL_DEBUG("bad, Unknown LINK response %c", resp[0]);
		LINK_slurp(in);
		return BUS_RESET_ERROR;
	}
}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:33,代码来源:ow_link.c


示例5: DS2482_reset

// return 1 shorted, 0 ok, <0 error
static RESET_TYPE DS2482_reset(const struct parsedname *pn)
{
    BYTE status_byte;
    struct connection_in * in = pn->selected_connection ;
    FILE_DESCRIPTOR_OR_ERROR file_descriptor = in->pown->file_descriptor;

    /* Make sure we're using the correct channel */
    if ( BAD(DS2482_channel_select(in)) ) {
        return BUS_RESET_ERROR;
    }

    /* write the RESET code */
    if (i2c_smbus_write_byte(file_descriptor, DS2482_CMD_1WIRE_RESET)) {
        return BUS_RESET_ERROR;
    }

    /* wait */
    // rstl+rsth+.25 usec

    /* read status */
    if ( BAD( DS2482_readstatus(&status_byte, file_descriptor, DS2482_1wire_reset_usec) ) ) {
        return BUS_RESET_ERROR;			// 8 * Tslot
    }

    in->AnyDevices = (status_byte & DS2482_REG_STS_PPD) ? anydevices_yes : anydevices_no ;
    LEVEL_DEBUG("DS2482 "I2Cformat" Any devices found on reset? %s",I2Cvar(in),in->AnyDevices==anydevices_yes?"Yes":"No");
    return (status_byte & DS2482_REG_STS_SD) ? BUS_RESET_SHORT : BUS_RESET_OK;
}
开发者ID:GrandHsu,项目名称:iicontrollibs,代码行数:29,代码来源:ow_ds2482.c


示例6: DS9097_reset_in

/* Puts in 9600 baud, sends 11110000 then reads response */
static RESET_TYPE DS9097_reset_in( struct connection_in * in )
{
	BYTE resetbyte = RESET_BYTE;
	BYTE responsebyte;

	if ( BAD( DS9097_pre_reset( in ) ) ) {
		return BUS_RESET_ERROR ;
	}

	if ( BAD( DS9097_send_and_get(&resetbyte, &responsebyte, 1, in )) ) {
		DS9097_post_reset( in) ;
		return BUS_RESET_ERROR ;
	}

	DS9097_post_reset(in) ;
	
	switch (responsebyte) {
	case 0x00:
		return BUS_RESET_SHORT;
	case RESET_BYTE:
		// no presence
		in->AnyDevices = anydevices_no ;
		return BUS_RESET_OK;
	default:
		in->AnyDevices = anydevices_yes ;
		return BUS_RESET_OK;
	}
}
开发者ID:GrandHsu,项目名称:iicontrollibs,代码行数:29,代码来源:ow_ds9097.c


示例7: FS_volts

/* 2450 A/D */
static ZERO_OR_ERROR FS_volts(struct one_wire_query *owq)
{
	struct parsedname *pn = PN(owq);
	int resolution ;
	int range ;
	_FLOAT V[4] ;

	switch ( pn->selected_filetype->data.i ) {
		case r_2V_8bit:
			range = 2 ;
			resolution = 8 ;
			break ;
		case r_5V_8bit:
			range = 5 ;
			resolution = 8 ;
			break ;
		case r_2V_16bit:
			range = 2 ;
			resolution = 16 ;
			break ;
		case r_5V_16bit:
		default:
			range = 5 ;
			resolution = 16 ;
			break ;
	}
	if ( BAD( OW_set_resolution( resolution, pn ) ) ) {
		return -EINVAL ;
	}	
	if ( BAD( OW_set_range( range, pn ) ) ) {
		return -EINVAL ;
	}	
	// Start A/D process if needed
	if ( BAD( OW_convert( OWQ_SIMUL_TEST(owq), (int)(.5+.16+4.*resolution*.08), pn) )) {
		return -EINVAL ;
	}	
	
	if ( BAD( OW_volts( V, pn ) )) {
		return -EINVAL ;
	}
	switch ( pn->selected_filetype->data.i ) {
		case r_2V_8bit:
		case r_2V_16bit:
			OWQ_array_F(owq, 0) = V[0]*.5;
			OWQ_array_F(owq, 1) = V[1]*.5;
			OWQ_array_F(owq, 2) = V[2]*.5;
			OWQ_array_F(owq, 3) = V[3]*.5;
			break ;
		case r_5V_8bit:
		case r_5V_16bit:
		default:
			OWQ_array_F(owq, 0) = V[0];
			OWQ_array_F(owq, 1) = V[1];
			OWQ_array_F(owq, 2) = V[2];
			OWQ_array_F(owq, 3) = V[3];
			break ;
	}
	return 0 ;
}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:60,代码来源:ow_2450.c


示例8: TestConnection

/* USB is a special case, in gets reenumerated, so we look for similar DS2401 chip */
GOOD_OR_BAD TestConnection(const struct parsedname *pn)
{
	GOOD_OR_BAD ret = 0;
	struct connection_in *in ;

	if ( pn == NO_PARSEDNAME ) {
		return gbGOOD ;
	}

	in = pn->selected_connection ;
	if ( in == NO_CONNECTION ) {
		return gbGOOD ;
	}
	
	// Test without a lock -- efficient
	if ( in->reconnect_state < reconnect_error ) {
		return gbGOOD;
	}
	
	// Lock the bus
	BUSLOCK(pn);
	// Test again
	if (in->reconnect_state >= reconnect_error) {
		// Add Statistics
		STAT_ADD1_BUS(e_bus_reconnects, in);

		// Close the bus (should leave enough reconnection information available)
		BUS_close(in);	// already locked

		// Call reconnection
		in->AnyDevices = anydevices_unknown ;
		if ( in->iroutines.reconnect != NO_RECONNECT_ROUTINE ) {
			// reconnect method exists
			ret = (in->iroutines.reconnect) (pn) ;	// call bus-specific reconnect
		} else {
			ret = BUS_detect(in->pown) ;	// call initial opener
		}
		if ( BAD( ret ) ) {
			in->reconnect_state = reconnect_ok + 1 ;
			// delay to slow thrashing
			UT_delay(200);
		} else {
			in->reconnect_state = reconnect_ok;
		}
	}
	BUSUNLOCK(pn);

	if ( BAD( ret ) ) {
		LEVEL_DEFAULT("Failed to reconnect %s bus master!", in->adapter_name);
	} else {
		LEVEL_DEFAULT("%s bus master reconnected", in->adapter_name);
	}

	return ret;
}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:56,代码来源:ow_reconnect.c


示例9: c3db_dump

int c3db_dump( C3HDL *h, FILE *to, int show_empty, int ts_fmt )
{
	if( !h )
	  	return C3E_BAD_HANDLE;

	if( h->state == C3DB_ST_DIRTY )
	  	BAD( C3E_BAD_STATE );

	if( ts_fmt < C3DB_TS_SEC || ts_fmt >= C3DB_TS_MAX )
		BAD( C3E_BAD_FORMAT );

	return (h->f_dump)( h, to, show_empty, ts_fmt );
}
开发者ID:ghostflame,项目名称:libc3db,代码行数:13,代码来源:actions.c


示例10: DS9490_detect_all_adapters

/* Open a DS9490  -- low level code (to allow for repeats)  */
static GOOD_OR_BAD DS9490_detect_all_adapters(struct port_in * pin_first)
{
	// discover devices
	struct port_in * pin = pin_first ;
	libusb_device **device_list;
	int n_devices = libusb_get_device_list( Globals.luc, &device_list) ;
	int i_device ;
	
	if ( n_devices < 1 ) {
		LEVEL_CONNECT("Could not find a list of USB devices");
		if ( n_devices<0 ) {
			LEVEL_DEBUG("<%s>",libusb_error_name(n_devices));
		}
		return gbBAD ;
	}

	for ( i_device = 0 ; i_device < n_devices ; ++i_device ) {
		libusb_device * current = device_list[i_device] ;
		if ( GOOD( USB_match( current ) ) ) {
			struct connection_in * in = pin->first ;
			if ( BAD(DS9490_open_and_name( current, in)) ) {
				LEVEL_DEBUG("Cannot open USB device %.d:%.d", libusb_get_device_address(current), libusb_get_bus_number(current) );
				continue ;
			} else if ( BAD(DS9490_ID_this_master(in)) ) {
				DS9490_close(in) ;
				LEVEL_DEBUG("Cannot access USB device %.d:%.d", libusb_get_device_address(current), libusb_get_bus_number(current) );
				continue;
			} else{
				pin = NewPort(NULL) ; // no reason to copy anything
				if ( pin == NULL ) {
					return gbGOOD ;
				}
				// set up the new connection for the next adapter
				DS9490_setroutines(in);
			}
		}
	}
	
	libusb_free_device_list(device_list, 1);

	if ( pin == pin_first ) {
		LEVEL_CONNECT("No USB DS9490 bus masters used");
		return gbBAD;
	}
	// Remove the extra connection
	RemovePort(pin);
	return gbGOOD ;
}
开发者ID:M-o-a-T,项目名称:owfs,代码行数:49,代码来源:ow_ds9490.c


示例11: DS9490_detect_specific_adapter

/* Open a DS9490  -- low level code (to allow for repeats)  */
static GOOD_OR_BAD DS9490_detect_specific_adapter(int bus_nr, int dev_nr, struct connection_in * in)
{
	// discover devices
	libusb_device **device_list;
	int n_devices = libusb_get_device_list( Globals.luc, &device_list) ;
	int i_device ;
	
	if ( n_devices < 1 ) {
		LEVEL_CONNECT("Could not find a list of USB devices");
		if ( n_devices<0 ) {
			LEVEL_DEBUG("<%s>",libusb_error_name(n_devices));
		}
		return gbBAD ;
	}

	// Mark this connection as taking only this address pair. Important for reconnections.
	in->master.usb.specific_usb_address = 1 ;

	for ( i_device = 0 ; i_device < n_devices ; ++i_device ) {
		libusb_device * current = device_list[i_device] ;
		if ( GOOD( USB_match( current ) ) ) {
			if ( libusb_get_bus_number(current) != bus_nr ) {
				continue ;
			}
			
			if ( libusb_get_device_address(current) != dev_nr ) {
				continue ;
			}
			
			if ( BAD(DS9490_open_and_name( current, in)) ) {
				LEVEL_DEBUG("Cannot open USB device %.d:%.d", libusb_get_device_address(current), libusb_get_bus_number(current) );
				break ;
			} else if ( BAD(DS9490_ID_this_master(in)) ) {
				DS9490_close(in) ;
				LEVEL_DEBUG("Cannot access USB device %.d:%.d", libusb_get_device_address(current), libusb_get_bus_number(current) );
				break ;
			} else{
				libusb_free_device_list(device_list, 1);
				return gbGOOD ;
			}
		}
	}
	
	libusb_free_device_list(device_list, 1);

	LEVEL_CONNECT("No USB DS9490 bus master found matching %d:%d", bus_nr,dev_nr);
	return gbBAD;
}
开发者ID:M-o-a-T,项目名称:owfs,代码行数:49,代码来源:ow_ds9490.c


示例12: FS_w_given_bus

/* Write now that connection is set */
static ZERO_OR_ERROR FS_w_given_bus(struct one_wire_query *owq)
{
	struct parsedname *pn = PN(owq);

	if ( BAD(TestConnection(pn)) ) {
		return -ECONNABORTED;
	} else if (KnownBus(pn) && BusIsServer(pn->selected_connection)) {
		return ServerWrite(owq);
	} else if (OWQ_pn(owq).type == ePN_real) {
		ZERO_OR_ERROR write_or_error = DeviceLockGet(pn);
		if (write_or_error == 0) {
			write_or_error = FS_w_local(owq);
			DeviceLockRelease(pn);
		} else {
			LEVEL_DEBUG("Cannot lock device for writing") ;
		}
		return write_or_error ;
	} else if ( IsInterfaceDir(pn) ) {
		ZERO_OR_ERROR write_or_error;
		BUSLOCK(pn);
		write_or_error = FS_w_local(owq);
		BUSUNLOCK(pn);
		return write_or_error ;
	} else {
		return FS_w_local(owq);
	}
}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:28,代码来源:ow_write.c


示例13: EDIT_scale_misfit

float EDIT_scale_misfit( int nxyz , float fac , short *sar , float *far )
{
    float sf , ff , sum=0.0f , df ;
    int ii , nf=0 ;

    ENTRY("EDIT_scale_misfit") ;

    if( nxyz <= 0 || sar == NULL || far == NULL ) RETURN(0.0f) ;

    if( fac == 0.0f ) fac = 1.0f ;
    df = 1.0f / fac ;

    for( ii=0 ; ii < nxyz ; ii++ ) {
        if( BAD(ii) ) continue ;
        ff = far[ii] ;
        if( ff == 0.0f ) continue ;
        sf = (short)rintf(fac*sar[ii]) ;
        if( sf == 0.0f ) {
            if( fabsf(ff) < df ) sum += fabsf(ff)*fac ;
            else                 sum += 1.0f ;
        } else {
            sf = fabsf((sf-ff)/ff) ;
            if( sf > 1.0f ) sf = 1.0f ;
            sum += sf ;
        }
        nf++ ;
    }

    if( nf > 0 ) sum /= nf ;
    RETURN(sum) ;
}
开发者ID:ccraddock,项目名称:afni,代码行数:31,代码来源:edt_coerce.c


示例14: OW_set_range

// range is 5=5V or 2=2.5V
static GOOD_OR_BAD OW_set_range( int range, struct parsedname * pn )
{
	int stored_range ;
	/* Range */
	if ( BAD( Cache_Get_SlaveSpecific(&stored_range, sizeof(stored_range), SlaveSpecificTag(RAN), pn))
		|| stored_range != range) {
			// need to set resolution
		BYTE p[_1W_2450_PAGESIZE];
		RETURN_BAD_IF_BAD( OW_r_mem(p, _1W_2450_PAGESIZE, _ADDRESS_CONTROL_PAGE, pn) ) ;
		switch ( range ) {
			case 2:
				p[_1W_2450_REG_A+1] &= ~_1W_2450_IR ;
				p[_1W_2450_REG_B+1] &= ~_1W_2450_IR ;
				p[_1W_2450_REG_C+1] &= ~_1W_2450_IR ;
				p[_1W_2450_REG_D+1] &= ~_1W_2450_IR ;
				break ;
			case 5:
			default:
				p[_1W_2450_REG_A+1] |= _1W_2450_IR ;
				p[_1W_2450_REG_B+1] |= _1W_2450_IR ;
				p[_1W_2450_REG_C+1] |= _1W_2450_IR ;
				p[_1W_2450_REG_D+1] |= _1W_2450_IR ;
				break ;
		}
		RETURN_BAD_IF_BAD( OW_w_mem(p, _1W_2450_PAGESIZE, _ADDRESS_CONTROL_PAGE, pn) );
		return Cache_Add_SlaveSpecific(&range, sizeof(int), SlaveSpecificTag(RAN), pn);
	}
	return gbGOOD ;
}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:30,代码来源:ow_2450.c


示例15: FS_Mclear

static ZERO_OR_ERROR FS_Mclear(struct one_wire_query *owq)
{
	struct parsedname *pn = PN(owq);
	int init = 1;

	if ( BAD( Cache_Get_SlaveSpecific(&init, sizeof(init), SlaveSpecificTag(INI), pn)) ) {
		OWQ_Y(owq) = 1;
		if ( FS_r_strobe(owq) != 0 ) {	// set reset pin to strobe mode
			return -EINVAL;
		}
		RETURN_ERROR_IF_BAD( OW_w_pio(0x30, pn) );

		UT_delay(100);
		// init
		RETURN_ERROR_IF_BAD( OW_w_pio(0x38, pn) ) ;
		UT_delay(10);
		// Enable Display, Cursor, and Blinking
		// Entry-mode: auto-increment, no shift
		RETURN_ERROR_IF_BAD( OW_w_pio(0x0F, pn) ) ;
		RETURN_ERROR_IF_BAD( OW_w_pio(0x06, pn) ) ;
		Cache_Add_SlaveSpecific(&init, sizeof(init), SlaveSpecificTag(INI), pn);
	}
	// clear
	RETURN_ERROR_IF_BAD( OW_w_pio(0x01, pn) );
	UT_delay(2);
	return FS_Mhome(owq);
}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:27,代码来源:ow_2408.c


示例16: HeadChannel

/* All general stored data will be assigned to this "head" channel */
static GOOD_OR_BAD HeadChannel(struct connection_in *head)
{
    /* Intentionally put the wrong index */
    head->master.i2c.index = 1;

    if ( BAD(DS2482_channel_select(head)) ) {	/* Couldn't switch */
        head->master.i2c.index = 0;	/* restore correct value */
        LEVEL_CONNECT("DS2482-100 (Single channel)");
        if ( GOOD(DS2483_test(head->pown->file_descriptor)) ) {
            head->master.i2c.type = ds2483 ;
        } else {
            head->master.i2c.type = ds2482_100 ;
        }

        return gbGOOD;				/* happy as DS2482-100 */
    }

    // It's a DS2482-800 (8 channels) to set up other 7 with this one as "head"
    LEVEL_CONNECT("DS2482-800 (Eight channels)");
    /* Must be a DS2482-800 */
    head->master.i2c.channels = 8;
    head->master.i2c.type = ds2482_800 ;
    head->Adapter = adapter_DS2482_800;

    return CreateChannels(head);
}
开发者ID:GrandHsu,项目名称:iicontrollibs,代码行数:27,代码来源:ow_ds2482.c


示例17: OWQ_create_aggregate

/* Use an single OWQ as a template for the aggregate one */
struct one_wire_query * OWQ_create_aggregate( struct one_wire_query * owq_single )
{
    int sz = sizeof( struct one_wire_query ) + OWQ_DEFAULT_READ_BUFFER_SIZE;
	struct one_wire_query * owq_all = owmalloc( sz );
	
	LEVEL_DEBUG("%s with extension ALL", PN(owq_single)->path);

	if ( owq_all == NO_ONE_WIRE_QUERY) {
		LEVEL_DEBUG("No memory to create object for extension ALL") ;
		return NO_ONE_WIRE_QUERY ;
	}
	
	memset(owq_all, 0, sz);
	OWQ_cleanup(owq_all) = owq_cleanup_owq ;
	
	memcpy( PN(owq_all), PN(owq_single), sizeof(struct parsedname) ) ;
	PN(owq_all)->extension = EXTENSION_ALL ;
	OWQ_buffer(owq_all) = (char *) (& owq_all[1]) ; // point just beyond the one_wire_query struct
	OWQ_size(owq_all) = OWQ_DEFAULT_READ_BUFFER_SIZE ;
	OWQ_offset(owq_all) = 0 ;
	if ( BAD( OWQ_allocate_array(owq_all)) ) {
		OWQ_destroy(owq_all);
		return NO_ONE_WIRE_QUERY ;
	}
	return owq_all ;
}
开发者ID:GrandHsu,项目名称:iicontrollibs,代码行数:27,代码来源:ow_parseobject.c


示例18: LINK_next_both

static enum search_status LINK_next_both(struct device_search *ds, const struct parsedname *pn)
{
	struct connection_in * in = pn->selected_connection ;

	//Special case for DS2409 hub, use low-level code
	if ( pn->ds2409_depth>0 ) {
		return search_error ;
	}

	if (ds->LastDevice) {
		return search_done;
	}

	if (ds->index == -1) {
		if ( BAD(LINK_directory(ds, in)) ) {
			return search_error;
		}
	}

	// LOOK FOR NEXT ELEMENT
	++ds->index;
	LEVEL_DEBUG("Index %d", ds->index);

	switch ( DirblobGet(ds->index, ds->sn, &(ds->gulp) ) ) {
		case 0:
			LEVEL_DEBUG("SN found: " SNformat "", SNvar(ds->sn));
			return search_good;
		case -ENODEV:
		default:
			ds->LastDevice = 1;
			LEVEL_DEBUG("SN finished");
			return search_done;
	}
}
开发者ID:bootc,项目名称:owfs-cvsimport,代码行数:34,代码来源:ow_link.c


示例19: OW_r_counters

static GOOD_OR_BAD OW_r_counters(UINT * data, const struct parsedname *pn)
{
	BYTE d[8];
	UINT cum[4];

	RETURN_BAD_IF_BAD( LCD_byte(_LCD_COMMAND_COUNTER_READ_TO_SCRATCH, 1, pn)) ;
	RETURN_BAD_IF_BAD( OW_r_scratch(d, 8, pn)) ;
	
	data[0] = ((UINT) d[1]) << 8 | d[0];
	data[1] = ((UINT) d[3]) << 8 | d[2];
	data[2] = ((UINT) d[5]) << 8 | d[4];
	data[3] = ((UINT) d[7]) << 8 | d[6];

//printf("OW_COUNTER key=%s\n",key);
	if ( BAD( Cache_Get_SlaveSpecific((void *) cum, sizeof(cum), SlaveSpecificTag(CUM), pn)) ) {	/* First pass at cumulative */
		cum[0] = data[0];
		cum[1] = data[1];
		cum[2] = data[2];
		cum[3] = data[3];
	} else {
		cum[0] += data[0];
		cum[1] += data[1];
		cum[2] += data[2];
		cum[3] += data[3];
	}
	Cache_Add_SlaveSpecific((void *) cum, sizeof(cum), SlaveSpecificTag(CUM), pn);
	return gbGOOD;
}
开发者ID:M-o-a-T,项目名称:owfs,代码行数:28,代码来源:ow_lcd.c


示例20: DS9490_redetect_low

/* Open a DS9490  -- low level code (to allow for repeats)  */
static GOOD_OR_BAD DS9490_redetect_low(struct connection_in * in)
{
	// discover devices
	libusb_device **device_list;
	int n_devices = libusb_get_device_list( Globals.luc, &device_list) ;
	int i_device ;
	
	if ( n_devices < 1 ) {
		LEVEL_CONNECT("Could not find a list of USB devices");
		if ( n_devices<0 ) {
			LEVEL_DEBUG("<%s>",libusb_error_name(n_devices));
		}
		return gbBAD;
	}

	for ( i_device = 0 ; i_device < n_devices ; ++i_device ) {
		libusb_device * current = device_list[i_device] ;
		if ( GOOD( USB_match( current ) ) ) {
			// try to open the DS9490
			if ( BAD(DS9490_open_and_name( current, in )) ) {
				LEVEL_CONNECT("Cannot open USB bus master, Find next...");
				continue;
			}
			if ( GOOD( DS9490_redetect_match( in ) ) ) {
				break ;
			}
			DS9490_close(in);
		}
	}
	
	libusb_free_device_list(device_list, 1);
	return (in->master.usb.lusb_handle!=NULL) ? gbGOOD : gbBAD ;
}
开发者ID:M-o-a-T,项目名称:owfs,代码行数:34,代码来源:ow_ds9490.c



注:本文中的BAD函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BAD_CAST函数代码示例发布时间:2022-05-30
下一篇:
C++ B43_WARN_ON函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap