Skip to content

Commit

Permalink
Merge pull request robotology#3165 from randaz81/mas_fix
Browse files Browse the repository at this point in the history
MultipleAnalogSensorServer fix
  • Loading branch information
randaz81 authored Jan 22, 2025
2 parents 916b4e0 + 7c873c0 commit f22181c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,33 +365,11 @@ bool MultipleAnalogSensorsServer::resizeAllMeasureVectors(SensorStreamingData& s
return ok;
}

bool MultipleAnalogSensorsServer::attachAll(const yarp::dev::PolyDriverList& p)
bool MultipleAnalogSensorsServer::attach(yarp::dev::PolyDriver* poly)
{
// Attach the device
if (p.size() > 1)
{
yCError(MULTIPLEANALOGSENSORSSERVER,
"This device only supports exposing a "
"single MultipleAnalogSensors device on YARP ports, but %d devices have been passed in attachAll.",
p.size());
yCError(MULTIPLEANALOGSENSORSSERVER,
"Please use the multipleanalogsensorsremapper device to combine several device in a new device.");
close();
return false;
}

if (p.size() == 0)
{
yCError(MULTIPLEANALOGSENSORSSERVER, "No device passed to attachAll, please pass a device to expose on YARP ports.");
close();
return false;
}

yarp::dev::PolyDriver* poly = p[0]->poly;

if (!poly)
{
yCError(MULTIPLEANALOGSENSORSSERVER, "Null pointer passed to attachAll.");
yCError(MULTIPLEANALOGSENSORSSERVER, "Null pointer passed to attach.");
close();
return false;
}
Expand Down Expand Up @@ -460,7 +438,7 @@ bool MultipleAnalogSensorsServer::attachAll(const yarp::dev::PolyDriverList& p)
return true;
}

bool MultipleAnalogSensorsServer::detachAll()
bool MultipleAnalogSensorsServer::detach()
{
// Stop the thread on detach
if (this->isRunning())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <yarp/os/Stamp.h>
#include <yarp/dev/DeviceDriver.h>
#include <yarp/dev/PolyDriver.h>
#include <yarp/dev/IMultipleWrapper.h>
#include <yarp/dev/WrapperSingle.h>
#include <yarp/dev/MultipleAnalogSensorsInterfaces.h>

// Thrift-generated classes
Expand All @@ -33,7 +33,7 @@
class MultipleAnalogSensorsServer :
public yarp::os::PeriodicThread,
public yarp::dev::DeviceDriver,
public yarp::dev::IMultipleWrapper,
public yarp::dev::WrapperSingle,
public MultipleAnalogSensorsMetadata,
public MultipleAnalogSensorsServer_ParamsParser
{
Expand Down Expand Up @@ -108,9 +108,9 @@ class MultipleAnalogSensorsServer :
bool open(yarp::os::Searchable &params) override;
bool close() override;

/* IMultipleWrapper methods */
bool attachAll(const yarp::dev::PolyDriverList &p) override;
bool detachAll() override;
/* IWrapper methods */
bool attach(yarp::dev::PolyDriver* p) override;
bool detach() override;

/* RateThread methods */
void threadRelease() override;
Expand Down

0 comments on commit f22181c

Please sign in to comment.