CCAux  2.20.0.0
CCAux API reference
Functions
Battery functions

Functions

EXTERN_C CCAUXDLL_API BATTERYHANDLE CCAUXDLL_CALLING_CONV GetBattery (void)
 
EXTERN_C CCAUXDLL_API void CCAUXDLL_CALLING_CONV Battery_release (BATTERYHANDLE)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_isBatteryPresent (BATTERYHANDLE, bool *batteryIsPresent)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatteryVoltageStatus (BATTERYHANDLE, uint8_t *batteryVoltagePercent)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatteryChargingStatus (BATTERYHANDLE, ChargingStatus *status)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getPowerSource (BATTERYHANDLE, PowerSource *status)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatteryTemp (BATTERYHANDLE, int16_t *temperature)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getHwErrorStatus (BATTERYHANDLE, ErrorStatus *errorCode)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getTimer (BATTERYHANDLE, BatteryTimerType *times)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getMinMaxTemp (BATTERYHANDLE, int16_t *minTemp, int16_t *maxTemp)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatteryHWversion (BATTERYHANDLE, char_t *buff, int32_t len)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatterySwVersion (BATTERYHANDLE, uint16_t *major, uint16_t *minor, uint16_t *release, uint16_t *build)
 
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatterySerial (BATTERYHANDLE, char_t *buff, int32_t len)
 

Detailed Description

Functions in the Battery class

Function Documentation

◆ Battery_getBatteryChargingStatus()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getBatteryChargingStatus ( BATTERYHANDLE  ,
ChargingStatus status 
)

Get battery charging status.

Supported Platform(s): XM

Parameters
statusthe current charging mode of the battery.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

error = Battery_getBatteryChargingStatus(pBattery, &cs);
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getBatteryChargingStatus: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getBatteryChargingStatus: " << GetErrorStringA(error) << std::endl;
}
else
{
switch (cs)
{
cout << "getBatteryChargingStatus: Battery is not being charged" << std::endl;
break;
cout << "getBatteryChargingStatus: Battery is being charged" << std::endl;
break;
cout << "getBatteryChargingStatus: Battery is fully charged" << std::endl;
break;
cout << "getBatteryChargingStatus: Temperature is too low to charge the battery" << std::endl;
break;
cout << "getBatteryChargingStatus: Temperature is too high to charge the battery" << std::endl;
break;
cout << "getBatteryChargingStatus: ChargingStatus_Unknown" << std::endl;
break;
default:
cout << "getBatteryChargingStatus: invalid return value" << std::endl;
break;
}
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatteryChargingStatus(BATTERYHANDLE, ChargingStatus *status)
EXTERN_C CCAUXDLL_API char_t const *CCAUXDLL_CALLING_CONV GetErrorStringA(eErr errCode)
ChargingStatus
Definition: Battery.h:53
@ ChargingStatus_TempHigh
Definition: Battery.h:58
@ ChargingStatus_NoCharge
Definition: Battery.h:54
@ ChargingStatus_Unknown
Definition: Battery.h:59
@ ChargingStatus_TempLow
Definition: Battery.h:57
@ ChargingStatus_Charging
Definition: Battery.h:55
@ ChargingStatus_FullyCharged
Definition: Battery.h:56
@ ERR_SUCCESS
Definition: CCAuxTypes.h:163
@ ERR_NOT_SUPPORTED
Definition: CCAuxTypes.h:165

◆ Battery_getBatteryHWversion()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getBatteryHWversion ( BATTERYHANDLE  ,
char_t buff,
int32_t  len 
)

Get battery hardware version (PCB revision).

Supported Platform(s): XM

Parameters
buffText output buffer.
lenMaximum length of the output buffer. If the actual length of the data is greater, an error will be returned.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

char buf[255];
error = Battery_getBatteryHWversion(pBattery, buf, sizeof(buf));
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getBatteryHWversion: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getBatteryHWversion: " << GetErrorStringA(error) << std::endl;
}
else
{
cout << "getBatteryHWversion: " << buf << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatteryHWversion(BATTERYHANDLE, char_t *buff, int32_t len)

◆ Battery_getBatterySerial()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getBatterySerial ( BATTERYHANDLE  ,
char_t buff,
int32_t  len 
)

Get battery serial number.

Supported Platform(s): XM

Parameters
buffText output buffer.
lenMaximum length of the output buffer. If the actual length of the data is greater, an error will be returned. The serial number is 10 characters plus terminating zero, in total 11 bytes in size.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

error = Battery_getBatterySerial(pBattery, buf, sizeof(buf));
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getBatterySerial: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getBatterySerial: " << GetErrorStringA(error) << std::endl;
}
else
{
cout << "getBatterySerial: " << buf << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatterySerial(BATTERYHANDLE, char_t *buff, int32_t len)

◆ Battery_getBatterySwVersion()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getBatterySwVersion ( BATTERYHANDLE  ,
uint16_t major,
uint16_t minor,
uint16_t release,
uint16_t build 
)

Get the battery software version

Supported Platform(s): XM

Parameters
majorMajor version number
minorMinor version number
releaseRelease version number
buildBuild version number
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

unsigned short major;
unsigned short minor;
unsigned short release;
unsigned short build;
error = Battery_getBatterySwVersion(pBattery, &major, &minor, &release, &build);
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getBatterySwVersion: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getBatterySwVersion: " << GetErrorStringA(error) << std::endl;
}
else
{
cout << "getBatterySwVersion: v" << major << "." << minor << "." << release << "." << build << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatterySwVersion(BATTERYHANDLE, uint16_t *major, uint16_t *minor, uint16_t *release, uint16_t *build)

◆ Battery_getBatteryTemp()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getBatteryTemp ( BATTERYHANDLE  ,
int16_t temperature 
)

Get battery temperature.

Supported Platform(s): XM

Parameters
temperaturePCB Temperature in degrees Celsius.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

short temp;
error = Battery_getBatteryTemp(pBattery, &temp);
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getBatteryTemp: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getBatteryTemp: " << GetErrorStringA(error) << std::endl;
}
else
{
cout << "getBatteryTemp: " << temp << " deg C" << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatteryTemp(BATTERYHANDLE, int16_t *temperature)

◆ Battery_getBatteryVoltageStatus()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getBatteryVoltageStatus ( BATTERYHANDLE  ,
uint8_t batteryVoltagePercent 
)

Get battery voltage status.

Supported Platform(s): XM

Parameters
batteryVoltagePercentthe current voltage level of the battery, in percent [0..100].
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

unsigned char s;
error = Battery_getBatteryVoltageStatus(pBattery, &s);
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getBatteryVoltageStatus: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getBatteryVoltageStatus: " << GetErrorStringA(error) << std::endl;
}
else
{
cout << "getBatteryVoltageStatus: " << (int)s << " %" << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getBatteryVoltageStatus(BATTERYHANDLE, uint8_t *batteryVoltagePercent)

◆ Battery_getHwErrorStatus()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getHwErrorStatus ( BATTERYHANDLE  ,
ErrorStatus errorCode 
)

Get hardware error code. If hardware errors are found or other problems are discovered by the battery pack, they are reported here.

Supported Platform(s): XM

Parameters
errorCodeError code. Zero means no error.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

error = Battery_getHwErrorStatus(pBattery, &es);
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getHwErrorStatus: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getHwErrorStatus: " << GetErrorStringA(error) << std::endl;
}
else
{
switch (es)
{
cout << "getHwErrorStatus: "
<< "Battery reports no HW errors" << std::endl;
break;
cout << "getHwErrorStatus: "
<< "Battery error! The thermistor temp sensor is not working" << std::endl;
break;
cout << "getHwErrorStatus: "
<< "Battery error! The secondary temp sensor is not working" << std::endl;
break;
cout << "getHwErrorStatus: "
<< "Battery error! Charging failed" << std::endl;
break;
cout << "getHwErrorStatus: "
<< "Battery error! Overcurrent detected" << std::endl;
break;
cout << "getHwErrorStatus: "
<< "Battery error! Battery not initiated" << std::endl;
break;
default:
cout << "getHwErrorStatus: "
<< "invalid return value" << std::endl;
break;
}
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getHwErrorStatus(BATTERYHANDLE, ErrorStatus *errorCode)
ErrorStatus
Definition: Battery.h:75
@ ErrorStatus_ThermistorTempSensor
Definition: Battery.h:77
@ ErrorStatus_Overcurrent
Definition: Battery.h:80
@ ErrorStatus_Init
Definition: Battery.h:81
@ ErrorStatus_NoError
Definition: Battery.h:76
@ ErrorStatus_SecondaryTempSensor
Definition: Battery.h:78
@ ErrorStatus_ChargeFail
Definition: Battery.h:79

◆ Battery_getMinMaxTemp()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getMinMaxTemp ( BATTERYHANDLE  ,
int16_t minTemp,
int16_t maxTemp 
)

Get temperature interval of the battery.

Supported Platform(s): XM

Parameters
minTempMinimum measured temperature.
maxTempMaximum measured temperature.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

short max;
error = Battery_getMinMaxTemp(pBattery, &temp, &max);
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getMinMaxTemp: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getMinMaxTemp: " << GetErrorStringA(error) << std::endl;
}
else
{
cout << "getMinMaxTemp: MinTemp:" << temp << ", MaxTemp: " << max << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getMinMaxTemp(BATTERYHANDLE, int16_t *minTemp, int16_t *maxTemp)

◆ Battery_getPowerSource()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getPowerSource ( BATTERYHANDLE  ,
PowerSource status 
)

Get the currently used power source.

Supported Platform(s): XM

Parameters
statusthe current power source, external power or battery.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

error = Battery_getPowerSource(pBattery, &ps);
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getPowerSource: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getPowerSource: " << GetErrorStringA(error) << std::endl;
}
else
{
cout << "getPowerSource: Power source: Battery" << std::endl;
else
cout << "getPowerSource: Power source: External Power" << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getPowerSource(BATTERYHANDLE, PowerSource *status)
PowerSource
Definition: Battery.h:66
@ PowerSource_Battery
Definition: Battery.h:67

◆ Battery_getTimer()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_getTimer ( BATTERYHANDLE  ,
BatteryTimerType times 
)

Get battery diagnostic timer.

Supported Platform(s): XM

Parameters
timesGet a struct with the current diagnostic times.
Returns
error status. 0 = ERR_SUCCESS, otherwise error code. See the enum eErr for details.

Example Usage:

BatteryTimerType times;
memset(&times, 0, sizeof(times));
error = Battery_getTimer(pBattery, &times);
if (error == ERR_NOT_SUPPORTED && !bpresent)
{
cout << "getTimer: " << GetErrorStringA(error) << " - battery is not present!" << std::endl;
}
else if (error != ERR_SUCCESS)
{
cout << "getTimer: " << GetErrorStringA(error) << std::endl;
}
else
{
cout << "getTimer: " << std::endl;
cout << "Total run time on main power=" << times.TotRunTimeMain * 60 << " min(s)" << std::endl
<< "Total run time on battery power=" << times.TotRunTimeBattery * 60 << " min(s)" << std::endl
<< "Total run time below -20C=" << times.RunTime_m20 << " min(s)" << std::endl
<< "Total run time -20-0C=" << times.RunTime_m20_0 << " min(s)" << std::endl
<< "Total run time 0-40C=" << times.RunTime_0_40 << " min(s)" << std::endl
<< "Total run time 40-60C=" << times.RunTime_40_60 << " min(s)" << std::endl
<< "Total run time 60-70C=" << times.RunTime_60_70 << " min(s)" << std::endl
<< "Total run time 70-80C=" << times.RunTime_70_80 << " min(s)" << std::endl
<< "Total run time above 80C=" << times.RunTime_Above80 << " min(s)" << std::endl;
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_getTimer(BATTERYHANDLE, BatteryTimerType *times)

◆ Battery_isBatteryPresent()

EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV CrossControl::Battery_isBatteryPresent ( BATTERYHANDLE  ,
bool *  batteryIsPresent 
)

Is an external battery connected?

Supported Platform(s): XM

Parameters
batteryIsPresenttrue if a battery is connected, otherwise false.
Returns
-

Example Usage:

error = Battery_isBatteryPresent(pBattery, &bpresent);
if (error != ERR_SUCCESS)
{
cout << "isBatteryPresent: " << GetErrorStringA(error) << std::endl;
}
else
{
if (bpresent)
{
cout << "Battery is present. Testing functionality... " << std::endl;
}
else
{
cout << "Battery is NOT present." << std::endl;
}
}
EXTERN_C CCAUXDLL_API eErr CCAUXDLL_CALLING_CONV Battery_isBatteryPresent(BATTERYHANDLE, bool *batteryIsPresent)

◆ Battery_release()

EXTERN_C CCAUXDLL_API void CCAUXDLL_CALLING_CONV CrossControl::Battery_release ( BATTERYHANDLE  )

Delete the Battery object

Supported Platform(s): XM.

Returns
-

Example Usage:

assert(pBattery);
readBatteryInfo(pBattery);
Battery_release(pBattery);
EXTERN_C CCAUXDLL_API BATTERYHANDLE CCAUXDLL_CALLING_CONV GetBattery(void)
EXTERN_C CCAUXDLL_API void CCAUXDLL_CALLING_CONV Battery_release(BATTERYHANDLE)
void * BATTERYHANDLE
Definition: Battery.h:84

◆ GetBattery()

EXTERN_C CCAUXDLL_API BATTERYHANDLE CCAUXDLL_CALLING_CONV CrossControl::GetBattery ( void  )

Factory function that creates instances of the Battery object.

Supported Platform(s): XM

Returns
BATTERYHANDLE to an allocated battery object. The returned handle needs to be deallocated using the Battery_release(BATTERYHANDLE) method when it's no longer needed. Returns NULL if it fails to allocate memory.

Example Usage:

assert(pBattery);
readBatteryInfo(pBattery);
Battery_release(pBattery);