Commit 7fbce2ac authored by Pierre NARVOR's avatar Pierre NARVOR
Browse files

[messages] Added PingResp and PingReq messages

parent 92617edf
......@@ -14,6 +14,8 @@
#include <seatrac_driver/messages/SettingsSet.h>
#include <seatrac_driver/messages/PingSend.h>
#include <seatrac_driver/messages/PingReq.h>
#include <seatrac_driver/messages/PingResp.h>
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_MESSAGES_H_
......
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_PING_REQ_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_PING_REQ_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct PingReq : public Message<PingReq>
{
static const CID_E Identifier = CID_PING_REQ;
ACOFIX_T acoFix;
PingReq& operator=(const std::vector<uint8_t>& other)
{
if(other[0] != this->msgId) {
throw std::runtime_error("Wrong message for decoding.");
}
acoFix.assign(other.size() - 1, other.data() + 1);
return *this;
}
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::PingReq& msg)
{
const char* prefix = "\n- ";
//os << "PingReq : " << msg.acoFix;
os << "PingReq";
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_PING_REQ_H_
#ifndef _DEF_SEATRAC_DRIVER_MESSAGES_PING_RESP_H_
#define _DEF_SEATRAC_DRIVER_MESSAGES_PING_RESP_H_
#include <seatrac_driver/SeatracTypes.h>
#include <seatrac_driver/messages/MessageBase.h>
namespace narval { namespace seatrac { namespace messages {
struct PingResp : public Message<PingResp>
{
static const CID_E Identifier = CID_PING_RESP;
ACOFIX_T acoFix;
PingResp& operator=(const std::vector<uint8_t>& other)
{
if(other[0] != this->msgId) {
throw std::runtime_error("Wrong message for decoding.");
}
acoFix.assign(other.size() - 1, other.data() + 1);
return *this;
}
}__attribute__((packed));
}; //namespace messages
}; //namespace seatrac
}; //namespace narval
inline std::ostream& operator<<(std::ostream& os,
const narval::seatrac::messages::PingResp& msg)
{
const char* prefix = "\n- ";
//os << "PingResp : " << msg.acoFix;
os << "PingResp";
return os;
}
#endif //_DEF_SEATRAC_DRIVER_MESSAGES_PING_RESP_H_
......@@ -29,6 +29,16 @@ void SeatracDriver::on_receive(const std::vector<uint8_t>& data)
}
}
}
switch(msgId) {
default:
break;
case CID_PING_REQ:
std::cout << "Got a Ping Request" << std::endl;
break;
case CID_PING_RESP:
std::cout << "Got a Ping Repsonse" << std::endl;
break;
}
// std::cout << "Received : " << data.size() << " bytes." << std::endl;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment