Description
setVariableStatus()
– modifies the current status of a data pool variable
Syntax
myPool.setVariableStatus( ou8_variable_index, ou8_status )
;
Parameters
uint8_t ou8_variable_index: the number (index) of the variable of interest.
uint8_t ou8_status: the new status of the variable:
– DP_VARIABLE_TO_BE_SENT
– if you want to force the value to be sent on the bus
– DP_VARIABLE_INVALID
– use this to check if another node is (still) updating this value. (eg. in order to validate that a sending node is still alive)
Returns
uint8_t 0: OK
1: ERROR an argument is out of range
2: ERROR pool is not initialised yet (->begin())
Example Codes:
The following code example checks the variable status of the data pool and prints them. If a variable was written (e.g. from the datapool-monitor) it will be printed and declared ‘invalid’ again. 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) ));
}
myPool.setVariableStatus( i, DP_VARIABLE_INVALID );
}
delay(2000);
}
Notes and Warnings
—
Examples can be found in the Arduino IDE menu:
File -> Examples -> Datapool ->