Description
getVariableStatus()
– returns the current status of the variable.
Syntax
myPool.getVariableStatus( ou8_variable_index )
;
Parameters
uint8_t ou8_variable_index: the number of the variable of interest.
Returns
DP_VARIABLE_INVALID
– variable or data pool is not initialized or index is out of rangeDP_VARIABLE_VALID
– ok – variable is initialized (either by some peer via CAN or by yourself)DP_VARIABLE_TO_BE_SENT
– ok – variable initialized and is currently waiting to be distributed by the background process
Example Codes:
The following code example checks the variable status of the data pool and prints them. Use the Datapool-Monitor in the CAN2SER monitor to modify / initialise the pool variables.
#include "Datapool.h"
#define NB_OF_VARIABLES 3
#define POOL_NAME "A_SimplePool_V1_1"
DATAPOOL myPool( &MCAN0, &BOOTLOADER_SETTING, POOL_NAME, NB_OF_VARIABLES );
void setup() {
while(!Serial);
myPool.begin();
}
void loop()
{
for(int i = 0; i < NB_OF_VARIABLES; i++)
{
if( myPool.getVariableStatus(i) == DP_VARIABLE_VALID )
{
Serial.println("Var"+String(i)+": "+
String( myPool.getValue_int32(i) ));
}
}
delay(2000);
}
Notes and Warnings
—
Examples can be found in the Arduino IDE menu:
File -> Examples -> Datapool ->