Add option to disable signal handlers (#65)
This gives the user the option to create their own signal handler without having create::Create interfere. They can disable the sigint/sigterm handler and be responsible for disconnecting from the robot themselves. Signed-off-by: Jacob Perron <jacobmperron@gmail.com>
This commit is contained in:
parent
fbc87dea3f
commit
1563e2b3e1
8 changed files with 35 additions and 19 deletions
|
@ -92,7 +92,7 @@ namespace create {
|
|||
float requestedLeftVel;
|
||||
float requestedRightVel;
|
||||
|
||||
void init();
|
||||
void init(bool install_signal_handler);
|
||||
// Add two matrices and handle overflow case
|
||||
Matrix addMatrices(const Matrix &A, const Matrix &B) const;
|
||||
void onData();
|
||||
|
@ -109,8 +109,10 @@ namespace create {
|
|||
* Calling this constructor Does not attempt to establish a serial connection to the robot.
|
||||
*
|
||||
* \param model the type of the robot. See RobotModel to determine the value for your robot.
|
||||
*/
|
||||
Create(RobotModel model = RobotModel::CREATE_2);
|
||||
* \param install_signal_handler if true, then register a signal handler to disconnect from
|
||||
* the robot on SIGINT or SIGTERM.
|
||||
*/
|
||||
Create(RobotModel model = RobotModel::CREATE_2, bool install_signal_handler = true);
|
||||
|
||||
/**
|
||||
* \brief Attempts to establish serial connection to Create.
|
||||
|
@ -119,8 +121,10 @@ namespace create {
|
|||
* \param baud rate to communicate with Create. Typically,
|
||||
* 115200 for Create 2 and 57600 for Create 1.
|
||||
* \param model type of robot. See RobotModel to determine the value for your robot.
|
||||
* \param install_signal_handler if true, then register a signal handler to disconnect from
|
||||
* the robot on SIGINT or SIGTERM.
|
||||
*/
|
||||
Create(const std::string& port, const int& baud, RobotModel model = RobotModel::CREATE_2);
|
||||
Create(const std::string& port, const int& baud, RobotModel model = RobotModel::CREATE_2, bool install_signal_handler = true);
|
||||
|
||||
/**
|
||||
* \brief Attempts to disconnect from serial.
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace create {
|
|||
void notifyDataReady();
|
||||
|
||||
public:
|
||||
Serial(std::shared_ptr<Data> data);
|
||||
Serial(std::shared_ptr<Data> data, bool install_signal_handler);
|
||||
~Serial();
|
||||
bool connect(const std::string& port, const int& baud = 115200, std::function<void()> cb = 0);
|
||||
void disconnect();
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace create {
|
|||
void processByte(uint8_t byteRead);
|
||||
|
||||
public:
|
||||
SerialQuery(std::shared_ptr<Data> data);
|
||||
SerialQuery(std::shared_ptr<Data> data, bool install_signal_handler = true);
|
||||
};
|
||||
} // namespace create
|
||||
|
||||
|
|
|
@ -69,7 +69,10 @@ namespace create {
|
|||
void processByte(uint8_t byteRead);
|
||||
|
||||
public:
|
||||
SerialStream(std::shared_ptr<Data> data, const uint8_t& header = create::util::STREAM_HEADER);
|
||||
SerialStream(
|
||||
std::shared_ptr<Data> data,
|
||||
const uint8_t& header = create::util::STREAM_HEADER,
|
||||
bool install_signal_handler = true);
|
||||
|
||||
};
|
||||
} // namespace create
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue