Example #1
0
int main( int argc, char* argv[] )
{
	mbug_device dev = 0;

	parse_options( argc, argv );

	if (action==List)
		{
			// List all attached devices
			int i;
			mbug_device_list list = mbug_get_device_list(2110);
			for (i=0; list[i]!=0; i++ ) {
				puts(list[i]); putchar('\n');
			}
			return 0;
		}

	// Open device
	dev = mbug_2110_open( device_id );
	if (dev ==0 ) {
		puts("Error opening device.");
		return 1;
	}

	mbug_2110_close(dev);
	return 0;
}
Example #2
0
	device_list get_device_list( int device_type = 0)
	{
		mbug_device_list p = 
			mbug_get_device_list(0);

		device_list list;
		for (int i=0; p[i]; i++)
		{
			list.push_back( std::string(p[i]) );
		}
		return list; 
	}
Example #3
0
int main( int argc, char* argv[] )
{
	mbug_device thermometer = 0;

	parse_options( argc, argv );

	if (action==List)
		{
			// List all attached thermometers
			int i;
			mbug_device_list list = mbug_get_device_list(2820);
			for (i=0; list[i]!=0; i++ ) {
				puts(list[i]);
			}
			return 0;
		}

	if (action==Help)
		{
			puts(usage);
			return 0;
		}

	// Open device
	thermometer = mbug_2820_open( device_serial );
	if (thermometer ==0 )
		errorf("#### Error opening device.");

	if (action==Read)
		{
			double tem, hum;
			mbug_2820_read( thermometer, &tem, &hum );
			printf( "%.2f,%.2f\n", tem, hum );
		}

	mbug_2820_close(thermometer);
	return 0;
}
Example #4
0
//------------------------------------------------------------------------------
// Get a list of all available mbug-2810 devices. 
const mbug_device_list  mbug_2810_list( void )
{
	return mbug_get_device_list(2810);
}
Example #5
0
int main( int argc, char* argv[] )
{
	int i = 0;
	mbug_device thermometer = 0;
	double tem[8] = {0};
	unsigned short raw[8] = {0};

	parse_options( argc, argv );

	if (action==List)
		{
			// List all attached thermometers
			int i;
			mbug_device_list list = mbug_get_device_list(2818);
			for (i=0; list[i]!=0; i++ ) {
				puts(list[i]);
			}
			return 0;
		}

	if (action==Help)
		{
			puts(usage);
			return 0;
		}

	// Open device
	thermometer = mbug_2818_open(device_serial);
	if (thermometer ==0 )
		errorf( "#### Error opening device." );

	if (action==Read)
	{
		if (format==Raw)
			mbug_2818_read_raw( thermometer, raw, 8 );
		else
			mbug_2818_read_all( thermometer, tem, 8);

		if (format==Fahrenheit)
			for (i=0; i<8; i++)
				tem[i] = tem[i] * 9./5 + 32.;
		else if (format==Kelvin)
			for (i=0; i<8; i++)
				if (tem[i] >= -273.15)
					tem[i] += 273.15;

		if (channels[0]<0)
		{
			// print all values
			for (i=0; i<8; i++) channels[i] = i;
			channels[8] = -1;
		}
		for (i=0; channels[i]>=0 ;i++)
		{
			if (channels[i] > 7)
				channels[i] = 0;
			if (format==Raw)
				printf( "%d", raw[channels[i]] );
			else
				printf( "%.2f", tem[channels[i]] );
			printf( (channels[i+1]<0) ? "\n" : "," );
		}
	}

	mbug_2818_close(thermometer);
	return 0;
}
Example #6
0
//------------------------------------------------------------------------------
// Get a list of all available mbug-2165 devices. 
const mbug_device_list  mbug_2165_list( void )
{
	return mbug_get_device_list(2165);
}