Skip to content

Commit

Permalink
Report availability of Jr3 CAN nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Oct 7, 2023
1 parent 0836160 commit 840be2b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions libraries/YarpPlugins/Jr3Mbed/DeviceDriverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,21 @@ bool Jr3Mbed::open(yarp::os::Searchable & config)
{
status = yarp::dev::MAS_WAITING_FOR_FIRST_READ;

if (sender)
{
sender->reportAvailability(true, canId);
}

if (!initialize())
{
// perhaps it did initialize correctly, but CAN comms timed out;
// otherwise, we could have used MAS_ERROR here instead
status = yarp::dev::MAS_TIMEOUT;

if (sender)
{
sender->reportAvailability(false, canId);
}
}

isBooting = false;
Expand All @@ -158,12 +168,22 @@ bool Jr3Mbed::open(yarp::os::Searchable & config)
{
yCIInfo(JR3M, id()) << "Sensor is responding";
status = yarp::dev::MAS_OK;

if (sender)
{
sender->reportAvailability(true, canId);
}
}
}
else if (status == yarp::dev::MAS_OK) // timeout!
{
yCIWarning(JR3M, id()) << "Sensor has timed out, last data was received" << elapsed << "seconds ago";
status = yarp::dev::MAS_TIMEOUT;

if (sender)
{
sender->reportAvailability(false, canId);
}
}
else
{
Expand Down

0 comments on commit 840be2b

Please sign in to comment.