AP_RangeFinder_PX4: Added the destructor to close the file descriptor

This commit is contained in:
akdslr 2014-07-16 15:57:03 -04:00 committed by Andrew Tridgell
parent 1083a89b0f
commit b08e3d0ee4
2 changed files with 13 additions and 0 deletions

View File

@ -62,6 +62,16 @@ AP_RangeFinder_PX4::AP_RangeFinder_PX4(RangeFinder &_ranger, uint8_t instance, R
state.healthy = true;
}
/*
close the file descriptor
*/
AP_RangeFinder_PX4::~AP_RangeFinder_PX4()
{
if (_fd != -1) {
close(_fd);
}
}
/*
open the PX4 driver, returning the file descriptor
*/

View File

@ -26,6 +26,9 @@ public:
// constructor
AP_RangeFinder_PX4(RangeFinder &ranger, uint8_t instance, RangeFinder::RangeFinder_State &_state);
// destructor
~AP_RangeFinder_PX4(void);
// static detection function
static bool detect(RangeFinder &ranger, uint8_t instance);