Log.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef _ROS_rosserial_msgs_Log_h
19 #define _ROS_rosserial_msgs_Log_h
20 
21 #include <stdint.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include "ros/msg.h"
25 
26 namespace rosserial_msgs
27 {
28 
29  class Log : public ros::Msg
30  {
31  public:
32  uint8_t level;
33  const char* msg;
34  enum { ROSDEBUG = 0 };
35  enum { INFO = 1 };
36  enum { WARN = 2 };
37  enum { ERROR = 3 };
38  enum { FATAL = 4 };
39 
40  Log():
41  level(0),
42  msg("")
43  {
44  }
45 
46  virtual int serialize(unsigned char *outbuffer) const
47  {
48  int offset = 0;
49  *(outbuffer + offset + 0) = (this->level >> (8 * 0)) & 0xFF;
50  offset += sizeof(this->level);
51  uint32_t length_msg = strlen(this->msg);
52  memcpy(outbuffer + offset, &length_msg, sizeof(uint32_t));
53  offset += 4;
54  memcpy(outbuffer + offset, this->msg, length_msg);
55  offset += length_msg;
56  return offset;
57  }
58 
59  virtual int deserialize(unsigned char *inbuffer)
60  {
61  int offset = 0;
62  this->level = ((uint8_t) (*(inbuffer + offset)));
63  offset += sizeof(this->level);
64  uint32_t length_msg;
65  memcpy(&length_msg, (inbuffer + offset), sizeof(uint32_t));
66  offset += 4;
67  for(unsigned int k= offset; k< offset+length_msg; ++k){
68  inbuffer[k-1]=inbuffer[k];
69  }
70  inbuffer[offset+length_msg-1]=0;
71  this->msg = (char *)(inbuffer + offset-1);
72  offset += length_msg;
73  return offset;
74  }
75 
76  const char * getType(){ return "rosserial_msgs/Log"; };
77  const char * getMD5(){ return "11abd731c25933261cd6183bd12d6295"; };
78 
79  };
80 
81 }
82 #endif
uint8_t level
Definition: Log.h:32
const char * getType()
Definition: Log.h:76
virtual int deserialize(unsigned char *inbuffer)
Definition: Log.h:59
const char * getMD5()
Definition: Log.h:77
Definition: msg.h:26
virtual int serialize(unsigned char *outbuffer) const
Definition: Log.h:46
const char * msg
Definition: Log.h:33


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Tue Oct 20 2020 03:35:57