![]() |
Laelaps
2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
|
#include <laeWd.h>
Public Member Functions | |
LaeWd (LaeI2C &i2cBus, uint_t addr=LaeI2CAddrArduino) | |
Initialization constructor. More... | |
virtual | ~LaeWd () |
Destructor. | |
virtual void | sync () |
Synchronize watchdog state with subprocessor state. | |
virtual int | configure (const LaeDesc &desc) |
Configure watchdog from product description. More... | |
virtual int | configure (const LaeTunes &tunes) |
Configure watchdog from tunable parameters. More... | |
virtual int | reload (const LaeTunes &tunes) |
Reload with new configuration. More... | |
virtual void | exec () |
Execute cycle to pet/read/update Watchdog sub-processor. | |
virtual int | cmdPetTheDog () |
Pet the watchdog command. More... | |
virtual int | cmdGetFwVersion (uint_t &uVerNum) |
Get the firmware version command. More... | |
virtual int | cmdSetBatterySoC (uint_t uBatterySoC) |
Set battery's state of charge state command. More... | |
virtual int | cmdSetAlarms (uint_t uAlarms) |
Set (clear) alarms command. More... | |
virtual int | cmdSetRgbLed (uint_t red, uint_t green, uint_t blue) |
Set the LED RGB color command. More... | |
virtual int | cmdResetRgbLed () |
Reset the LED RGB color to state defaults. More... | |
virtual int | cmdConfigDPin (uint_t pin, uint_t dir) |
Configure a digital pin command. More... | |
virtual int | cmdReadDPin (uint_t pin, uint_t &val) |
Read the value of a digital pin command. More... | |
virtual int | cmdWriteDPin (uint_t pin, uint_t val) |
Write a value to a digital pin command. More... | |
virtual int | cmdReadAPin (uint_t pin, uint_t &val) |
Read the value of an analog pin command. More... | |
virtual int | cmdWriteAPin (uint_t pin, uint_t val) |
Write the value to an analog pin command. More... | |
virtual int | cmdEnableMotorCtlrs (bool bEnable) |
Enable/disable power in to motor controllers. More... | |
virtual int | cmdEnableAuxPort5V (bool bEnable) |
Enable/disable regulated 5 volt auxilliary port power out. More... | |
virtual int | cmdEnableAuxPortBatt (bool bEnable) |
Enable/disable battery auxilliary port power out. More... | |
virtual int | cmdReadEnables (bool &bMotorCtlrEn, bool &bAuxPort5vEn, bool &bAuxPortBattEn) |
Read enable lines. More... | |
virtual int | cmdReadVoltages (double &fJackV, double &fBattV) |
Read sensed voltages. More... | |
virtual int | cmdTest (uint_t &uSeqNum, uint_t &uOpState, uint_t &uAlarms, uint_t &uLedIndex) |
Test the firmware state command. More... | |
virtual int | cmdConfigOperation (unsigned long uTimeout) |
Configure firmware operation. More... | |
uint_t | getI2CAddr () |
Get watchdog's I2C address. More... | |
uint_t | getFwVersion () |
Get previously read firmware version. More... | |
bool | isCharging () |
Test if battery is charging. More... | |
Static Public Member Functions | |
static int | enableMotorCtlrs (void *pArg, bool bEnable) |
Enable/disable power in to motor controllers. More... | |
Protected Member Functions | |
void | lock () |
Lock the shared resource. More... | |
void | unlock () |
Unlock the shared resource. More... | |
uint_t | determineAlarms () |
Determine watchdog alarm state. More... | |
Protected Attributes | |
LaeI2C & | m_i2cBus |
bound I2C bus instance | |
uint_t | m_addrSubProc |
I2C sub-processor address. | |
uint_t | m_uFwVer |
firmware version number | |
ulong_t | m_uWatchdogTimeout |
watchdog timeout (msec) | |
bool | m_bBatteryIsCharging |
battery is [not] charging | |
double | m_fBatteryVoltage |
sensed battery voltage | |
double | m_fJackVoltage |
sensed power supply jack voltage | |
uint_t | m_uBatterySoC |
battery state of charge | |
uint_t | m_uAlarms |
alarms | |
bool | m_bMotorCtlrEn |
motor controller enable | |
bool | m_bAuxPortBattEn |
battery auxilliary port enable | |
bool | m_bAuxPort5vEn |
5 volt auxilliary port enable | |
rnr::chronos::Time | m_timeMotorCtlrs |
motor controller up time | |
pthread_mutex_t | m_mutex |
mutex | |
LaeWd::LaeWd | ( | LaeI2C & | i2cBus, |
uint_t | addr = LaeI2CAddrArduino |
||
) |
Initialization constructor.
i2cbus | Bound open I2C bus instance. |
addr | Arduino I2C address. |
Definition at line 113 of file laeWd.cxx.
References FWVER_UNKNOWN, laelaps::LaeWdArgAlarmNone, laelaps::LaeWdArgBattSoCMax, laelaps::LaeWdTimeoutDft, laelaps::LaeDbEnable::m_bAuxPort5v, m_bAuxPort5vEn, laelaps::LaeDbEnable::m_bAuxPortBatt, m_bAuxPortBattEn, laelaps::LaeDbEnergy::m_bBatteryIsCharging, m_bBatteryIsCharging, laelaps::LaeDbEnable::m_bMotorCtlr, m_bMotorCtlrEn, laelaps::LaeDb::m_enable, laelaps::LaeDb::m_energy, m_fBatteryVoltage, laelaps::LaeDbEnergy::m_fJackVoltage, m_fJackVoltage, m_mutex, m_uAlarms, m_uBatterySoC, m_uFwVer, m_uWatchdogTimeout, and laelaps::RtDb.
|
virtual |
Configure a digital pin command.
pin | Digital pin number. |
dir | Pin direction. 0 == input, 1 == output. |
Definition at line 396 of file laeWd.cxx.
References FWVER_UNKNOWN, laelaps::LAE_ECODE_BAD_VAL, laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdArgDPinDirIn, laelaps::LaeWdArgDPinDirOut, laelaps::LaeWdArgDPinNumWMax, laelaps::LaeWdArgDPinNumWMin, laelaps::LaeWdCmdIdConfigDPin, laelaps::LaeWdMaxCmdLen, lock(), m_addrSubProc, m_i2cBus, m_uFwVer, unlock(), and laelaps::LaeI2C::write().
Referenced by laelaps::LaeRobot::configDigitalPin().
|
virtual |
Configure firmware operation.
uTimeout | Watchdog timeout (msec). |
Definition at line 1028 of file laeWd.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdCmdIdConfigFw, laelaps::LaeWdMaxCmdLen, laelaps::LaeWdTimeoutDft, lock(), m_addrSubProc, laelaps::LaeDb::m_config, laelaps::LaeDbConfig::m_fWatchDogTimeout, m_i2cBus, m_uFwVer, m_uWatchdogTimeout, laelaps::RtDb, unlock(), and laelaps::LaeI2C::write().
Referenced by configure(), and sync().
|
virtual |
Enable/disable regulated 5 volt auxilliary port power out.
bEnable | Disable (false) or enable (true). |
Definition at line 759 of file laeWd.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdArgAuxPort5V, laelaps::LaeWdArgDPinValHigh, laelaps::LaeWdArgDPinValLow, laelaps::LaeWdCmdIdEnableAuxPort, laelaps::LaeWdMaxCmdLen, lock(), m_addrSubProc, laelaps::LaeDbEnable::m_bAuxPort5v, m_bAuxPort5vEn, laelaps::LaeDb::m_enable, m_i2cBus, m_uFwVer, laelaps::RtDb, unlock(), and laelaps::LaeI2C::write().
Referenced by laelaps::LaeRobot::setAuxPower(), sync(), and Laelaps.WatchDog.WatchDog::sync().
|
virtual |
Enable/disable battery auxilliary port power out.
bEnable | Disable (false) or enable (true). |
Definition at line 808 of file laeWd.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdArgAuxPortBatt, laelaps::LaeWdArgDPinValHigh, laelaps::LaeWdArgDPinValLow, laelaps::LaeWdCmdIdEnableAuxPort, laelaps::LaeWdMaxCmdLen, lock(), m_addrSubProc, laelaps::LaeDbEnable::m_bAuxPortBatt, m_bAuxPortBattEn, laelaps::LaeDb::m_enable, m_i2cBus, m_uFwVer, laelaps::RtDb, unlock(), and laelaps::LaeI2C::write().
Referenced by laelaps::LaeRobot::setAuxPower(), sync(), and Laelaps.WatchDog.WatchDog::sync().
|
virtual |
Enable/disable power in to motor controllers.
bEnable | Disable (false) or enable (true). |
Definition at line 668 of file laeWd.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdArgDPinValHigh, laelaps::LaeWdArgDPinValLow, laelaps::LaeWdArgPass, laelaps::LaeWdCmdIdEnableMotorCtlrs, laelaps::LaeWdMaxCmdLen, laelaps::LaeWdMaxRspLen, laelaps::LaeWdRspLenEnableMotorCtlrs, lock(), m_addrSubProc, laelaps::LaeDbEnable::m_bMotorCtlr, m_bMotorCtlrEn, laelaps::LaeDb::m_enable, m_i2cBus, m_timeMotorCtlrs, m_uFwVer, laelaps::RtDb, TMc, unlock(), and laelaps::LaeI2C::write_read().
Referenced by sync(), and Laelaps.WatchDog.WatchDog::sync().
|
virtual |
Get the firmware version command.
[out] | uVerNum | Firmware version number. |
Definition at line 263 of file laeWd.cxx.
References laelaps::LAE_OK, laelaps::LaeWdCmdIdGetVersion, laelaps::LaeWdMaxCmdLen, laelaps::LaeWdMaxRspLen, laelaps::LaeWdRspLenGetVersion, lock(), m_addrSubProc, m_i2cBus, laelaps::LaeDb::m_product, m_uFwVer, laelaps::LaeDbProduct::m_uWatchDogFwVer, laelaps::RtDb, TStd, unlock(), and laelaps::LaeI2C::write_read().
Referenced by laelaps::LaeRobot::connWatchDog(), sync(), and Laelaps.WatchDog.WatchDog::sync().
|
virtual |
Pet the watchdog command.
Definition at line 215 of file laeWd.cxx.
References FWVER_UNKNOWN, laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdArgDPinValHigh, laelaps::LaeWdCmdIdPetDog, laelaps::LaeWdMaxCmdLen, laelaps::LaeWdMaxRspLen, laelaps::LaeWdRspLenPetDog_2, lock(), m_addrSubProc, laelaps::LaeDbEnergy::m_bBatteryIsCharging, m_bBatteryIsCharging, laelaps::LaeDb::m_energy, m_i2cBus, m_uFwVer, laelaps::RtDb, TStd, unlock(), laelaps::LaeI2C::write(), and laelaps::LaeI2C::write_read().
Referenced by exec(), sync(), and Laelaps.WatchDog.WatchDog::sync().
|
virtual |
Read the value of an analog pin command.
pin | Analog pin number. | |
[out] | val | Analog 10-bit value [0-1023]. |
Definition at line 555 of file laeWd.cxx.
References FWVER_UNKNOWN, laelaps::LAE_ECODE_BAD_VAL, laelaps::LAE_OK, laelaps::LaeWdArgAInPinNumMax, laelaps::LaeWdArgAInPinNumMin, laelaps::LaeWdCmdIdReadAPin, laelaps::LaeWdMaxCmdLen, laelaps::LaeWdMaxRspLen, laelaps::LaeWdRspLenReadAPin, lock(), m_addrSubProc, m_i2cBus, m_uFwVer, TStd, unlock(), WD_DBG_BUF, and laelaps::LaeI2C::write_read().
Referenced by laelaps::LaeRobot::readAnalogPin().
|
virtual |
Read the value of a digital pin command.
pin | Digital pin number. | |
[out] | val | Digital pin low (0) or high (1) value. |
Definition at line 445 of file laeWd.cxx.
References FWVER_UNKNOWN, laelaps::LAE_ECODE_BAD_VAL, laelaps::LAE_OK, laelaps::LaeWdArgDPinNumMax, laelaps::LaeWdArgDPinNumMin, laelaps::LaeWdCmdIdReadDPin, laelaps::LaeWdMaxCmdLen, laelaps::LaeWdMaxRspLen, laelaps::LaeWdRspLenReadDPin, lock(), m_addrSubProc, m_i2cBus, m_uFwVer, TStd, unlock(), WD_DBG_BUF, and laelaps::LaeI2C::write_read().
Referenced by laelaps::LaeRobot::readDigitalPin().
|
virtual |
Read enable lines.
[out] | bMotorCtlrEn | Motor controllers enable. |
[out] | bAuxPort5vEn | Auxilliary port 5v out enable. |
[out] | bAuxPortBattEn | Auxilliary port battery out enable. |
Definition at line 857 of file laeWd.cxx.
References laelaps::LAE_OK, laelaps::LaeWdCmdIdReadEnables, laelaps::LaeWdMaxCmdLen, laelaps::LaeWdMaxRspLen, laelaps::LaeWdRspLenReadEnables, lock(), m_addrSubProc, laelaps::LaeDbEnable::m_bAuxPort5v, m_bAuxPort5vEn, laelaps::LaeDbEnable::m_bAuxPortBatt, m_bAuxPortBattEn, laelaps::LaeDbEnable::m_bMotorCtlr, m_bMotorCtlrEn, laelaps::LaeDb::m_enable, m_i2cBus, m_timeMotorCtlrs, m_uFwVer, laelaps::RtDb, TStd, unlock(), and laelaps::LaeI2C::write_read().
Referenced by exec().
|
virtual |
Read sensed voltages.
[out] | fJackV | Sensed charging jack input voltage. |
[out] | fBattV | Sensed battery output voltage. |
Definition at line 933 of file laeWd.cxx.
References laelaps::LAE_OK, laelaps::LaeWdArgVScale, laelaps::LaeWdCmdIdReadVolts, laelaps::LaeWdMaxCmdLen, laelaps::LaeWdMaxRspLen, laelaps::LaeWdRspLenReadVolts, lock(), m_addrSubProc, laelaps::LaeDb::m_energy, laelaps::LaeDbEnergy::m_fBatteryVoltage, m_fBatteryVoltage, laelaps::LaeDbEnergy::m_fJackVoltage, m_fJackVoltage, m_i2cBus, m_uFwVer, laelaps::RtDb, TStd, unlock(), and laelaps::LaeI2C::write_read().
Referenced by exec(), and sync().
|
virtual |
Reset the LED RGB color to state defaults.
Definition at line 376 of file laeWd.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdCmdIdResetRgbLed, laelaps::LaeWdMaxCmdLen, lock(), m_addrSubProc, m_i2cBus, unlock(), and laelaps::LaeI2C::write().
Referenced by sync(), and Laelaps.WatchDog.WatchDog::sync().
|
virtual |
Set (clear) alarms command.
uAlarms | Bit-or'ed alarm state. |
Definition at line 323 of file laeWd.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdCmdIdSetAlarms, laelaps::LaeWdMaxCmdLen, lock(), m_addrSubProc, m_i2cBus, m_uAlarms, unlock(), and laelaps::LaeI2C::write().
Referenced by exec(), sync(), and Laelaps.WatchDog.WatchDog::sync().
|
virtual |
Set battery's state of charge state command.
uBatterySoC | Battery state of charge as a percent [0-100]. |
Definition at line 289 of file laeWd.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdArgBattSoCMax, laelaps::LaeWdCmdIdSetBattCharge, laelaps::LaeWdMaxCmdLen, lock(), m_addrSubProc, m_i2cBus, m_uBatterySoC, unlock(), and laelaps::LaeI2C::write().
Referenced by exec(), sync(), and Laelaps.WatchDog.WatchDog::sync().
|
virtual |
Set the LED RGB color command.
red | Red component [0-255]. |
green | Green component [0-255]. |
blue | Blue component [0-255]. |
Definition at line 353 of file laeWd.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdCmdIdSetRgbLed, laelaps::LaeWdMaxCmdLen, lock(), m_addrSubProc, m_i2cBus, unlock(), and laelaps::LaeI2C::write().
|
virtual |
Test the firmware state command.
[out] | uSeqNum | This command's sequence number modulo 256. |
[out] | uOpState | Firmware's operational state. |
[out] | uAlarms | Firmware's view of alarms. |
[out] | uLedIndex | Firmware's current LED pattern index. |
Definition at line 984 of file laeWd.cxx.
References FWVER_UNKNOWN, laelaps::LAE_OK, laelaps::LaeWdCmdIdTest, laelaps::LaeWdMaxCmdLen, laelaps::LaeWdMaxRspLen, laelaps::LaeWdRspLenTest, lock(), m_addrSubProc, m_i2cBus, m_uFwVer, TStd, unlock(), and laelaps::LaeI2C::write_read().
|
virtual |
Write the value to an analog pin command.
pin | Analog pin number. |
val | Analog 10-bit value [0-1023]. |
Definition at line 616 of file laeWd.cxx.
References FWVER_UNKNOWN, laelaps::LAE_ECODE_BAD_VAL, laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdArgAOutPinNumMax, laelaps::LaeWdArgAOutPinNumMin, laelaps::LaeWdArgAOutPinValMax, laelaps::LaeWdCmdIdWriteAPin, laelaps::LaeWdMaxCmdLen, lock(), m_addrSubProc, m_i2cBus, m_uFwVer, unlock(), and laelaps::LaeI2C::write().
|
virtual |
Write a value to a digital pin command.
pin | Digital pin number. |
val | Digital pin low (0) or high (1) value. |
Definition at line 506 of file laeWd.cxx.
References FWVER_UNKNOWN, laelaps::LAE_ECODE_BAD_VAL, laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeWdArgDPinNumWMax, laelaps::LaeWdArgDPinNumWMin, laelaps::LaeWdArgDPinValHigh, laelaps::LaeWdArgDPinValLow, laelaps::LaeWdCmdIdWriteDPin, laelaps::LaeWdMaxCmdLen, lock(), m_addrSubProc, m_i2cBus, m_uFwVer, unlock(), and laelaps::LaeI2C::write().
Referenced by laelaps::LaeRobot::writeDigitalPin().
|
virtual |
Configure watchdog from product description.
Call after connection is opened.
desc | Product description. |
Definition at line 159 of file laeWd.cxx.
References laelaps::LAE_OK.
Referenced by laelaps::LaeRobot::configForOperation(), and reload().
|
virtual |
Configure watchdog from tunable parameters.
Call after connection is opened.
tunes | Laelaps tuning parameters. |
Definition at line 164 of file laeWd.cxx.
References cmdConfigOperation(), laelaps::LaeTunes::getWatchDogTimeout(), and laelaps::LAE_OK.
|
protected |
Determine watchdog alarm state.
The current real-time database alarm state is used for the determination.
Definition at line 1073 of file laeWd.cxx.
References laelaps::LAE_ALARM_BATT, laelaps::LAE_ALARM_ESTOP, laelaps::LAE_ALARM_TEMP, laelaps::LaeWdArgAlarmBatt, laelaps::LaeWdArgAlarmBattCrit, laelaps::LaeWdArgAlarmCrit, laelaps::LaeWdArgAlarmEStop, laelaps::LaeWdArgAlarmGen, laelaps::LaeWdArgAlarmNone, laelaps::LaeWdArgAlarmTemp, laelaps::LaeDb::m_alarms, laelaps::LaeDbAlarms::m_battery, laelaps::LaeAlarmInfo::m_bIsCritical, laelaps::LaeDbAlarms::m_system, laelaps::LaeAlarmInfo::m_uAlarms, and laelaps::RtDb.
Referenced by exec(), and unlock().
|
static |
Enable/disable power in to motor controllers.
pArg | Recast pointer to this class instance. |
bEnable | Disable (false) or enable (true). |
Definition at line 1117 of file laeWd.cxx.
Referenced by laelaps::LaeRobot::connMotorControllers().
|
inline |
|
inline |
Get watchdog's I2C address.
Definition at line 361 of file laeWd.h.
References m_addrSubProc.
|
inline |
Test if battery is charging.
Definition at line 381 of file laeWd.h.
References m_bBatteryIsCharging.
|
inlineprotected |
Lock the shared resource.
The lock()/unlock() primitives provide a safe threading. registered vServo data.
Definition at line 418 of file laeWd.h.
Referenced by cmdConfigDPin(), cmdConfigOperation(), cmdEnableAuxPort5V(), cmdEnableAuxPortBatt(), cmdEnableMotorCtlrs(), cmdGetFwVersion(), cmdPetTheDog(), cmdReadAPin(), cmdReadDPin(), cmdReadEnables(), cmdReadVoltages(), cmdResetRgbLed(), cmdSetAlarms(), cmdSetBatterySoC(), cmdSetRgbLed(), cmdTest(), cmdWriteAPin(), and cmdWriteDPin().
|
virtual |
Reload with new configuration.
tunes | Laelaps tuning parameters. |
Definition at line 182 of file laeWd.cxx.
References configure().
Referenced by laelaps::LaeThreadWd::reload().
|
inlineprotected |
Unlock the shared resource.
Definition at line 429 of file laeWd.h.
References determineAlarms().
Referenced by cmdConfigDPin(), cmdConfigOperation(), cmdEnableAuxPort5V(), cmdEnableAuxPortBatt(), cmdEnableMotorCtlrs(), cmdGetFwVersion(), cmdPetTheDog(), cmdReadAPin(), cmdReadDPin(), cmdReadEnables(), cmdReadVoltages(), cmdResetRgbLed(), cmdSetAlarms(), cmdSetBatterySoC(), cmdSetRgbLed(), cmdTest(), cmdWriteAPin(), and cmdWriteDPin().