Seeed Grove ++  v0.0.1-2019
Linux C++ Library For Seeed Grove Devices
SG::BeagleBone::Detect Namespace Reference

The Detect namespace contains several related functions to help determine if the device where the code is running is a BeagleBone Black, BeagleBone Green, or some other type of device. More...

Typedefs

typedef std::vector< ECompatibilityCompatibilities
 A vector of capabilities describing a device. More...
 

Enumerations

enum  ECompatibility {
  ECompatibility::invalid = 0,
  ECompatibility::other,
  ECompatibility::ti_am33xx,
  ECompatibility::ti_am335x_bone,
  ECompatibility::ti_am335x_bone_black,
  ECompatibility::ti_am335x_bone_green,
  ECompatibility::ti_am335x_bone_green_wireless
}
 Compability enums for this device. More...
 

Functions

std::string to_string (const ECompatibility type)
 Convert a single compatibility to a text string. More...
 
VStr to_string (const Compatibilities &compabilities)
 Convert a vector of capabilities to a vector of strings. More...
 
Compatibilities get_compatibilities (void)
 Get the vector of compabilities for this device. More...
 
bool has (const ECompatibility type)
 Determine if the device compatibilities contains the given type. More...
 
std::string get_model (void)
 Return the device model or product name as a text string. More...
 
bool is_beaglebone_compatible (void)
 Determine if the device is compatible with the given type. More...
 
bool is_beaglebone_black_compatible (void)
 Determine if the device is compatible with the given type. More...
 
bool is_beaglebone_green_compatible (void)
 Determine if the device is compatible with the given type. More...
 
bool is_beaglebone_green_wireless_compatible (void)
 Determine if the device is compatible with the given type. More...
 

Detailed Description

The Detect namespace contains several related functions to help determine if the device where the code is running is a BeagleBone Black, BeagleBone Green, or some other type of device.

For example, note the following code:

{
std::cout << "This device is a BeagleBone Green with Grove connections." << std::endl;
}
{
std::cout << "This device is a BeagleBone Black." << std::endl;
}
{
std::cout << "This device is a BeagleBone." << std::endl;
}
else
{
std::cout << "This is an unknown type of computer." << std::endl;
}

In addition, the actual model name can also be obtained. This contains a single text string which looks similar to "TI AM335x BeagleBone Green". For example:

const std::string model = SG::BeagleBone::Detect::get_model();
std::cout << model << std::endl;

Typedef Documentation

A vector of capabilities describing a device.

You'd typically obtain this by calling SG::BeagleBone::Detect::get_compatibilities(). BeagleBone devices typically report they are compatible with multiple devices. For example, a BeagleBone Green doesn't just call itself a BeagleBone Green, but also reports as a BeagleBone and a BeagleBone Black.

Enumeration Type Documentation

Compability enums for this device.

Enumerator
invalid 
other 
ti_am33xx 

Texas Instrument Sitara ARM processor AM33XX.

ti_am335x_bone 

BeagleBone

ti_am335x_bone_black 

BeagleBone Black

ti_am335x_bone_green 

BeagleBone Green

ti_am335x_bone_green_wireless 

BeagleBone Green Wireless

Function Documentation

SG::BeagleBone::Detect::Compatibilities SG::BeagleBone::Detect::get_compatibilities ( void  )

Get the vector of compabilities for this device.

See also
/proc/device-tree/compatible

References SG::BeagleBone::all, get_model(), SG::read_file(), and to_string().

Referenced by bb_detect(), and has().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string SG::BeagleBone::Detect::get_model ( void  )

Return the device model or product name as a text string.

For example:

  • TI AM335x BeagleBone Black
  • TI AM335x BeagleBone Green
Note
Even on non-BeagleBone devices, this is likely to return a text string. For example, this can return strings such as "VirtualBox" or "Vostro 470".
See also
/proc/device-tree/model
/sys/devices/virtual/dmi/id/product_name

References SG::file_exists(), SG::read_file(), and SG::trim().

Referenced by bb_detect(), and get_compatibilities().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SG::BeagleBone::Detect::has ( const ECompatibility  type)

Determine if the device compatibilities contains the given type.

For example:

The equivalent functionality can be obtained by calling the individual type functions, such as:

See also
is_beaglebone_compatible()
is_beaglebone_black_compatible()
is_beaglebone_green_compatible()
is_beaglebone_green_wireless_compatible()

References get_compatibilities().

Referenced by is_beaglebone_black_compatible(), is_beaglebone_compatible(), is_beaglebone_green_compatible(), and is_beaglebone_green_wireless_compatible().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SG::BeagleBone::Detect::is_beaglebone_black_compatible ( void  )
inline

Determine if the device is compatible with the given type.

References has(), and ti_am335x_bone_black.

Referenced by bb_detect().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SG::BeagleBone::Detect::is_beaglebone_compatible ( void  )
inline

Determine if the device is compatible with the given type.

References has(), and ti_am335x_bone.

Referenced by bb_detect().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SG::BeagleBone::Detect::is_beaglebone_green_compatible ( void  )
inline

Determine if the device is compatible with the given type.

References has(), and ti_am335x_bone_green.

Referenced by bb_detect().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SG::BeagleBone::Detect::is_beaglebone_green_wireless_compatible ( void  )
inline

Determine if the device is compatible with the given type.

References has(), and ti_am335x_bone_green_wireless.

Here is the call graph for this function:

SG::VStr SG::BeagleBone::Detect::to_string ( const Compatibilities compabilities)

Convert a vector of capabilities to a vector of strings.

References to_string().

Here is the call graph for this function: