1 #include "MsgConfirm.h"
2 namespace remote
{ namespace protocols
{ namespace motecontrol
{
4 MsgConfirm::MsgConfirm(uint8_t command
, result_t result
, status_t status
)
5 : command(command
), result(result
), status(status
)
9 MsgConfirm::MsgConfirm(uint8_t*& buffer
, uint32_t& buflen
)
11 buffer
= this->read(buffer
,buflen
);
14 void MsgConfirm::operator = (const MsgConfirm
& o
)
21 uint32_t MsgConfirm::getLength()
23 return sizeof(command
)+sizeof(result
)+sizeof(status
);
26 uint8_t* MsgConfirm::write(uint8_t* buffer
, uint32_t& buflen
)
28 buffer
= writevalue(command
,buffer
,buflen
);
29 buffer
= writevalue(result
,buffer
,buflen
);
30 buffer
= writevalue(status
,buffer
,buflen
);
34 uint8_t* MsgConfirm::read(uint8_t* buffer
, uint32_t& buflen
)
36 buffer
= readvalue(command
,buffer
,buflen
);
37 buffer
= readvalue(result
,buffer
,buflen
);
38 buffer
= readvalue(status
,buffer
,buflen
);
42 void MsgConfirm::print(FILE* s
)
44 fprintf(s
,"MESSAGE MsgConfirm\n");
45 fprintf(s
,"command: ");
48 case MOTECOMMAND_PROGRAM
:
49 fprintf(s
,"MOTECOMMAND_PROGRAM\n");
51 case MOTECOMMAND_STATUS
:
52 fprintf(s
,"MOTECOMMAND_STATUS\n");
54 case MOTECOMMAND_RESET
:
55 fprintf(s
,"MOTECOMMAND_RESET\n");
57 case MOTECOMMAND_STOP
:
58 fprintf(s
,"MOTECOMMAND_STOP\n");
60 case MOTECOMMAND_START
:
61 fprintf(s
,"MOTECOMMAND_START\n");
64 fprintf(s
,"Invalid command!\n");
67 fprintf(s
,"result: ");
71 fprintf(s
,"NOT_SUPPORTED\n");
74 fprintf(s
,"SUCCESS\n");
77 fprintf(s
,"FAILURE\n");
80 fprintf(s
,"Invalid result!\n");
83 fprintf(s
,"status: ");
86 case MOTE_STATUS_UNKNOWN
:
87 fprintf(s
,"MOTE_STATUS_UNKNOWN\n");
89 case MOTE_UNAVAILABLE
:
90 fprintf(s
,"MOTE_UNAVAILABLE\n");
93 fprintf(s
,"MOTE_STOPPED\n");
96 fprintf(s
,"MOTE_RUNNING\n");
98 case MOTE_PROGRAMMING
:
99 fprintf(s
,"MOTE_PROGRAMMING\n");
102 fprintf(s
,"Invalid status!\n");
107 uint8_t MsgConfirm::getCommand()
112 result_t
MsgConfirm::getResult()
117 status_t
MsgConfirm::getStatus()