ROS Serial library for Mbed platforms for ROS Melodic Morenia. Check http://wiki.ros.org/rosserial_mbed/ for more information.
roscpp/GetLoggers.h@2:4480021e9f58, 2022-08-18 (annotated)
- Committer:
- howanglam3
- Date:
- Thu Aug 18 07:35:12 2022 +0000
- Revision:
- 2:4480021e9f58
- Parent:
- 0:04ac6be8229a
unchanged
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gary Servin |
0:04ac6be8229a | 1 | #ifndef _ROS_SERVICE_GetLoggers_h |
Gary Servin |
0:04ac6be8229a | 2 | #define _ROS_SERVICE_GetLoggers_h |
Gary Servin |
0:04ac6be8229a | 3 | #include <stdint.h> |
Gary Servin |
0:04ac6be8229a | 4 | #include <string.h> |
Gary Servin |
0:04ac6be8229a | 5 | #include <stdlib.h> |
Gary Servin |
0:04ac6be8229a | 6 | #include "ros/msg.h" |
Gary Servin |
0:04ac6be8229a | 7 | #include "roscpp/Logger.h" |
Gary Servin |
0:04ac6be8229a | 8 | |
Gary Servin |
0:04ac6be8229a | 9 | namespace roscpp |
Gary Servin |
0:04ac6be8229a | 10 | { |
Gary Servin |
0:04ac6be8229a | 11 | |
Gary Servin |
0:04ac6be8229a | 12 | static const char GETLOGGERS[] = "roscpp/GetLoggers"; |
Gary Servin |
0:04ac6be8229a | 13 | |
Gary Servin |
0:04ac6be8229a | 14 | class GetLoggersRequest : public ros::Msg |
Gary Servin |
0:04ac6be8229a | 15 | { |
Gary Servin |
0:04ac6be8229a | 16 | public: |
Gary Servin |
0:04ac6be8229a | 17 | |
Gary Servin |
0:04ac6be8229a | 18 | GetLoggersRequest() |
Gary Servin |
0:04ac6be8229a | 19 | { |
Gary Servin |
0:04ac6be8229a | 20 | } |
Gary Servin |
0:04ac6be8229a | 21 | |
Gary Servin |
0:04ac6be8229a | 22 | virtual int serialize(unsigned char *outbuffer) const |
Gary Servin |
0:04ac6be8229a | 23 | { |
Gary Servin |
0:04ac6be8229a | 24 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 25 | return offset; |
Gary Servin |
0:04ac6be8229a | 26 | } |
Gary Servin |
0:04ac6be8229a | 27 | |
Gary Servin |
0:04ac6be8229a | 28 | virtual int deserialize(unsigned char *inbuffer) |
Gary Servin |
0:04ac6be8229a | 29 | { |
Gary Servin |
0:04ac6be8229a | 30 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 31 | return offset; |
Gary Servin |
0:04ac6be8229a | 32 | } |
Gary Servin |
0:04ac6be8229a | 33 | |
Gary Servin |
0:04ac6be8229a | 34 | const char * getType(){ return GETLOGGERS; }; |
Gary Servin |
0:04ac6be8229a | 35 | const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; |
Gary Servin |
0:04ac6be8229a | 36 | |
Gary Servin |
0:04ac6be8229a | 37 | }; |
Gary Servin |
0:04ac6be8229a | 38 | |
Gary Servin |
0:04ac6be8229a | 39 | class GetLoggersResponse : public ros::Msg |
Gary Servin |
0:04ac6be8229a | 40 | { |
Gary Servin |
0:04ac6be8229a | 41 | public: |
Gary Servin |
0:04ac6be8229a | 42 | uint32_t loggers_length; |
Gary Servin |
0:04ac6be8229a | 43 | typedef roscpp::Logger _loggers_type; |
Gary Servin |
0:04ac6be8229a | 44 | _loggers_type st_loggers; |
Gary Servin |
0:04ac6be8229a | 45 | _loggers_type * loggers; |
Gary Servin |
0:04ac6be8229a | 46 | |
Gary Servin |
0:04ac6be8229a | 47 | GetLoggersResponse(): |
Gary Servin |
0:04ac6be8229a | 48 | loggers_length(0), loggers(NULL) |
Gary Servin |
0:04ac6be8229a | 49 | { |
Gary Servin |
0:04ac6be8229a | 50 | } |
Gary Servin |
0:04ac6be8229a | 51 | |
Gary Servin |
0:04ac6be8229a | 52 | virtual int serialize(unsigned char *outbuffer) const |
Gary Servin |
0:04ac6be8229a | 53 | { |
Gary Servin |
0:04ac6be8229a | 54 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 55 | *(outbuffer + offset + 0) = (this->loggers_length >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 56 | *(outbuffer + offset + 1) = (this->loggers_length >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 57 | *(outbuffer + offset + 2) = (this->loggers_length >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 58 | *(outbuffer + offset + 3) = (this->loggers_length >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 59 | offset += sizeof(this->loggers_length); |
Gary Servin |
0:04ac6be8229a | 60 | for( uint32_t i = 0; i < loggers_length; i++){ |
Gary Servin |
0:04ac6be8229a | 61 | offset += this->loggers[i].serialize(outbuffer + offset); |
Gary Servin |
0:04ac6be8229a | 62 | } |
Gary Servin |
0:04ac6be8229a | 63 | return offset; |
Gary Servin |
0:04ac6be8229a | 64 | } |
Gary Servin |
0:04ac6be8229a | 65 | |
Gary Servin |
0:04ac6be8229a | 66 | virtual int deserialize(unsigned char *inbuffer) |
Gary Servin |
0:04ac6be8229a | 67 | { |
Gary Servin |
0:04ac6be8229a | 68 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 69 | uint32_t loggers_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 70 | loggers_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 71 | loggers_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 72 | loggers_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 73 | offset += sizeof(this->loggers_length); |
Gary Servin |
0:04ac6be8229a | 74 | if(loggers_lengthT > loggers_length) |
Gary Servin |
0:04ac6be8229a | 75 | this->loggers = (roscpp::Logger*)realloc(this->loggers, loggers_lengthT * sizeof(roscpp::Logger)); |
Gary Servin |
0:04ac6be8229a | 76 | loggers_length = loggers_lengthT; |
Gary Servin |
0:04ac6be8229a | 77 | for( uint32_t i = 0; i < loggers_length; i++){ |
Gary Servin |
0:04ac6be8229a | 78 | offset += this->st_loggers.deserialize(inbuffer + offset); |
Gary Servin |
0:04ac6be8229a | 79 | memcpy( &(this->loggers[i]), &(this->st_loggers), sizeof(roscpp::Logger)); |
Gary Servin |
0:04ac6be8229a | 80 | } |
Gary Servin |
0:04ac6be8229a | 81 | return offset; |
Gary Servin |
0:04ac6be8229a | 82 | } |
Gary Servin |
0:04ac6be8229a | 83 | |
Gary Servin |
0:04ac6be8229a | 84 | const char * getType(){ return GETLOGGERS; }; |
Gary Servin |
0:04ac6be8229a | 85 | const char * getMD5(){ return "32e97e85527d4678a8f9279894bb64b0"; }; |
Gary Servin |
0:04ac6be8229a | 86 | |
Gary Servin |
0:04ac6be8229a | 87 | }; |
Gary Servin |
0:04ac6be8229a | 88 | |
Gary Servin |
0:04ac6be8229a | 89 | class GetLoggers { |
Gary Servin |
0:04ac6be8229a | 90 | public: |
Gary Servin |
0:04ac6be8229a | 91 | typedef GetLoggersRequest Request; |
Gary Servin |
0:04ac6be8229a | 92 | typedef GetLoggersResponse Response; |
Gary Servin |
0:04ac6be8229a | 93 | }; |
Gary Servin |
0:04ac6be8229a | 94 | |
Gary Servin |
0:04ac6be8229a | 95 | } |
Gary Servin |
0:04ac6be8229a | 96 | #endif |