Skip to content

Commit 3b509af

Browse files
authored
Merge pull request #3300 from elandini84/fix/battery_bindings/missing_checks
Added missing checks on IBattery methods in yarp.i
2 parents 737a67f + 976b866 commit 3b509af

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

bindings/yarp.i

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,13 +1572,15 @@ MAKE_COMMS (Sound, yarp::sig::Sound)
15721572
%extend yarp::dev::IBattery {
15731573
double getBatteryVoltage() {
15741574
double voltage;
1575-
self->getBatteryVoltage(voltage);
1575+
bool ok = self->getBatteryVoltage(voltage);
1576+
if (!ok) return 0;
15761577
return voltage;
15771578
}
15781579

15791580
double getBatteryCurrent() {
15801581
double current;
1581-
self->getBatteryCurrent(current);
1582+
bool ok = self->getBatteryCurrent(current);
1583+
if (!ok) return 0;
15821584
return current;
15831585
}
15841586

@@ -1590,19 +1592,22 @@ MAKE_COMMS (Sound, yarp::sig::Sound)
15901592

15911593
yarp::dev::IBattery::Battery_status getBatteryStatus() {
15921594
yarp::dev::IBattery::Battery_status status;
1593-
self->getBatteryStatus(status);
1595+
bool ok = self->getBatteryStatus(status);
1596+
if (!ok) return yarp::dev::IBattery::Battery_status::BATTERY_GENERAL_ERROR;
15941597
return status;
15951598
}
15961599

15971600
double getBatteryTemperature() {
15981601
double temperature;
1599-
self->getBatteryTemperature(temperature);
1602+
bool ok = self->getBatteryTemperature(temperature);
1603+
if (!ok) return 0;
16001604
return temperature;
16011605
}
16021606

16031607
std::string getBatteryInfo() {
16041608
std::string info;
1605-
self->getBatteryInfo(info);
1609+
bool ok = self->getBatteryInfo(info);
1610+
if (!ok) return "";
16061611
return info;
16071612
}
16081613
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fix_battery_bindings_missing_checks {#yarp_3_12}
2+
-----------------------
3+
4+
## Bindings
5+
6+
### `dev`
7+
8+
#### `IBattery`
9+
10+
* Added missing checks for IBattery methods in yarp.i

0 commit comments

Comments
 (0)