Skip to content

Commit

Permalink
Set upper bounds for a few config params
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Jan 5, 2024
1 parent 06d22f2 commit 43a3542
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libraries/YarpPlugins/CuiAbsolute/DeviceDriverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool CuiAbsolute::open(yarp::os::Searchable & config)
timeout = cuiGroup.check("timeout", yarp::os::Value(DEFAULT_TIMEOUT), "timeout (seconds)").asFloat64();
maxRetries = cuiGroup.check("maxRetries", yarp::os::Value(DEFAULT_MAX_RETRIES), "max retries on timeout").asFloat64();

if (canId <= 0)
if (canId <= 0 || canId > 127)
{
yCError(CUI) << "Illegal CAN ID:" << canId;
return false;
Expand Down
4 changes: 2 additions & 2 deletions libraries/YarpPlugins/Jr3Mbed/DeviceDriverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ bool Jr3Mbed::open(yarp::os::Searchable & config)
name = config.check("name", yarp::os::Value(""), "sensor name").asString(); // id-specific
filter = jr3Group.check("filter", yarp::os::Value(DEFAULT_FILTER), "cutoff frequency for low-pass filter (Hertz)").asFloat64();

if (canId <= 0)
if (canId <= 0 || canId > 127)
{
yCError(JR3M) << "Illegal CAN ID:" << canId;
return false;
}

if (filter < 0.0)
if (filter < 0.0 || filter > 655.35) // (2^16 - 1) / 100
{
yCError(JR3M) << "Illegal filter value:" << filter;
return false;
Expand Down

0 comments on commit 43a3542

Please sign in to comment.