-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added first commit for diagnostics for the phidgets. #20
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ namespace phidgets { | |
|
||
Phidget::Phidget() | ||
{ | ||
updater.add("IMU Driver Status", this, &phidgets::Phidget::phidgetsDiagnostics); | ||
|
||
} | ||
|
||
|
@@ -17,7 +18,7 @@ void Phidget::registerHandlers() | |
{ | ||
CPhidget_set_OnAttach_Handler(handle_, &Phidget::AttachHandler, this); | ||
CPhidget_set_OnDetach_Handler(handle_, &Phidget::DetachHandler, this); | ||
CPhidget_set_OnError_Handler (handle_, &Phidget::ErrorHandler, this); | ||
CPhidget_set_OnError_Handler (handle_, &Phidget::ErrorHandler, this); | ||
} | ||
|
||
void Phidget::init(CPhidgetHandle handle) | ||
|
@@ -27,6 +28,7 @@ void Phidget::init(CPhidgetHandle handle) | |
|
||
int Phidget::open(int serial_number) | ||
{ | ||
updater.setHardwareID("none"); | ||
return CPhidget_open(handle_, serial_number); | ||
} | ||
|
||
|
@@ -111,19 +113,49 @@ void Phidget::errorHandler(int error) | |
int Phidget::AttachHandler(CPhidgetHandle handle, void *userptr) | ||
{ | ||
((Phidget*)userptr)->attachHandler(); | ||
is_connected = true; | ||
updater.force_update(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move these two lines to the non-static function ( |
||
return 0; | ||
} | ||
|
||
int Phidget::DetachHandler(CPhidgetHandle handle, void *userptr) | ||
{ | ||
((Phidget*)userptr)->detachHandler(); | ||
is_connected = false; | ||
updater.force_update(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
return 0; | ||
} | ||
|
||
int Phidget::ErrorHandler(CPhidgetHandle handle, void *userptr, int ErrorCode, const char *unknown) | ||
{ | ||
((Phidget*)userptr)->errorHandler(ErrorCode); | ||
is_error = true; | ||
updater.force_update(); | ||
is_error = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
return 0; | ||
} | ||
|
||
// Added for diagnostics | ||
void Phidget::phidgetsDiagnostics(diagnostic_updater::DiagnosticStatusWrapper &stat) | ||
{ | ||
if (is_connected) | ||
{ | ||
stat.summary(diagnostic_msgs::DiagnosticStatus::OK, "The Phidget is connected."); | ||
stat.add("Device Serial Number", getDeviceSerialNumber()); | ||
stat.add("Device Name", getDeviceName()); | ||
stat.add("Device Type", getDeviceType()); | ||
} | ||
else | ||
{ | ||
stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, "The Phidget is not connected. Check USB."); | ||
} | ||
|
||
if (is_error && error_number != 0) | ||
{ | ||
stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, "The Phidget is in Error."); | ||
stat.addf("Error Number","%f",error_number); | ||
stat.add("Error message",getErrorDescription(error_number)); | ||
} | ||
} | ||
|
||
} //namespace phidgets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing slash ("/") in the two closing tags above.