Class Mraa
API to common functions of MRAA.
Inheritance
Namespace:MraaSharp
Assembly:MraaSharp.dll
Syntax
public class Mraa
Properties
View SourceAdcRawBits
Check the board's bit size when reading the value. raw bits being read from kernel module. zero if no ADC
Declaration
public static uint AdcRawBits
{
get;
}
Property Value
Type | Description |
---|---|
System.UInt32 |
AdcSupportedBits
Return value that the raw value should be shifted to. Zero if no ADC. return actual bit size the adc value should be understood as.
Declaration
public static uint AdcSupportedBits
{
get;
}
Property Value
Type | Description |
---|---|
System.UInt32 |
HasSubPlatform
Detect presence of sub platform.
Declaration
public static bool HasSubPlatform
{
get;
}
Property Value
Type | Description |
---|---|
System.Boolean |
I2cBusCount
Get platform usable I2C bus count, board must be initialised. number if usable I2C bus count on the current platform. Function will return -1 on failure.
Declaration
public static int I2cBusCount
{
get;
}
Property Value
Type | Description |
---|---|
System.Int32 |
LogLevel
Sets the log level to use from 0-7 where 7 is very verbose. These are the syslog log levels, see syslog(3) for more information on the levels.
Declaration
public static int LogLevel
{
set;
}
Property Value
Type | Description |
---|---|
System.Int32 |
PinCount
Get platform pincount, board must be initialised. uint of physical pin count on the in-use platform.
Declaration
public static uint PinCount
{
get;
}
Property Value
Type | Description |
---|---|
System.UInt32 |
PlatformCombinedType
Get combined platform type, board must be initialised. The combined type is represented as (sub_platform_type << 8) | main_platform_type
Declaration
public static int PlatformCombinedType
{
get;
}
Property Value
Type | Description |
---|---|
System.Int32 |
PlatformName
Return the Platform's Name, If no platform detected return NULL
Declaration
public static string PlatformName
{
get;
}
Property Value
Type | Description |
---|---|
System.String |
PlatformType
Get platform type, board must be initialised.
Declaration
public static MraaPlatform PlatformType
{
get;
}
Property Value
Type | Description |
---|---|
MraaPlatform |
Priority
This function attempts to set the mraa process to a given priority and the scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0. This function * will set to MAX if * priority is > MAX. Function will return -1 on failure.
Declaration
public static int Priority
{
set;
}
Property Value
Type | Description |
---|---|
System.Int32 |
Version
Get the version string of mraa autogenerated from git tag The version returned may not be what is expected however it is a reliable number associated with the git tag closest to that version at build time
Declaration
public static string Version
{
get;
}
Property Value
Type | Description |
---|---|
System.String |
Methods
View SourceDeinitialize()
De-Initilise MRAA This is not a strict requirement but useful to test memory leaks and for people who like super clean code.If dynamically loading & unloading libmraa you need to call this before unloading the library.
Declaration
public static void Deinitialize()
GetDefaultI2cBus(MraaPlatformOffset)
Get default i2c bus, board must be initialised.
Declaration
public static int GetDefaultI2cBus(MraaPlatformOffset platformOffset)
Parameters
Type | Name | Description |
---|---|---|
MraaPlatformOffset | platformOffset | platform offset; 0 for main platform, 1 foor sub platform |
Returns
Type | Description |
---|---|
System.Int32 | default i2c bus index |
GetI2cBusId(UInt32)
Get I2C adapter number in sysfs.
Declaration
public static int GetI2cBusId(uint i2cBus)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | i2cBus | the logical I2C bus number |
Returns
Type | Description |
---|---|
System.Int32 | I2C adapter number in sysfs. Function will return -1 on failure. |
GetPinName(Int32)
Get name of pin, board must be initialised.
Declaration
public static string GetPinName(int pin)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pin | number |
Returns
Type | Description |
---|---|
System.String | char* of pin name |
GetPlatformAdcRawBits(MraaPlatformOffset)
Check the specified board's bit size when reading the value
Declaration
public static uint GetPlatformAdcRawBits(MraaPlatformOffset platformOffset)
Parameters
Type | Name | Description |
---|---|---|
MraaPlatformOffset | platformOffset | specified platform offset; 0 for main platform, 1 foor sub platform |
Returns
Type | Description |
---|---|
System.UInt32 | raw bits being read from kernel module. zero if no ADC |
GetPlatformAdcSupportedBits(MraaPlatformOffset)
Return value that the raw value should be shifted to. Zero if no ADC
Declaration
public static uint GetPlatformAdcSupportedBits(MraaPlatformOffset platformOffset)
Parameters
Type | Name | Description |
---|---|---|
MraaPlatformOffset | platformOffset | specified platform offset; 0 for main platform, 1 foor sub platform |
Returns
Type | Description |
---|---|
System.UInt32 | return actual bit size the adc value should be understood as. |
GetPlatformPinCount(MraaPlatformOffset)
Get specified platform pincount, board must be initialised.
Declaration
public static uint GetPlatformPinCount(MraaPlatformOffset platformOffset)
Parameters
Type | Name | Description |
---|---|---|
MraaPlatformOffset | platformOffset | platform offset; 0 for main platform, 1 foor sub platform |
Returns
Type | Description |
---|---|
System.UInt32 | uint of physical pin count on the in-use platform |
GetPlatformVersion(MraaPlatformOffset)
Return the platform's versioning info, the information given depends per platform and can be NULL. platform_offset has to be given. Do not modify this pointer
Declaration
public static string GetPlatformVersion(MraaPlatformOffset platformOffset)
Parameters
Type | Name | Description |
---|---|---|
MraaPlatformOffset | platformOffset | specified platform offset; 0 for main platform, 1 for sub platform |
Returns
Type | Description |
---|---|
System.String | platform's versioning string |
GetSubPlatformId(Int32)
Convert pin or bus index to corresponding sub platform id.
Declaration
public static int GetSubPlatformId(int pinOrBusIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pinOrBusIndex | pin or bus index |
Returns
Type | Description |
---|---|
System.Int32 | sub platform pin or bus number |
GetSubPlatformIndex(Int32)
Convert pin or bus sub platform id to index.
Declaration
public static int GetSubPlatformIndex(int pinOrBusId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pinOrBusId |
Returns
Type | Description |
---|---|
System.Int32 | pin or bus index |
Initialize()
Initialise MRAA Detects running platform and attempts to use included pinmap, this is run on module/library init/load but is handy to rerun to check board initialised correctly.MRAA_SUCCESS inidicates correct (first time) initialisation whilst MRAA_ERROR_PLATFORM_ALREADY_INITIALISED indicates the board is already initialised correctly
Declaration
public static void Initialize()
IsSubPlatformId(Int32)
Check if pin or bus id includes sub platform mask.
Declaration
public static bool IsSubPlatformId(int pinOrBusId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pinOrBusId | pin or bus number |
Returns
Type | Description |
---|---|
System.Boolean | mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise |
PinModeTest(Int32, MraaPinModes)
Checks if a pin is able to use the passed in mode.
Declaration
public static bool PinModeTest(int pin, MraaPinModes mode)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pin | Physical Pin to be checked. |
MraaPinModes | mode | the mode to be tested. |
Returns
Type | Description |
---|---|
System.Boolean | boolean if the mode is supported, 0=false. |
ResultPrint(MraaResult)
Print a textual representation of the mraa_result_t
Declaration
public static void ResultPrint(MraaResult result)
Parameters
Type | Name | Description |
---|---|---|
MraaResult | result | the result to print |