![](/media/cache/profiles/94aef38441efa3380a3bed3faf1f9d5d.50x50_q85.jpg)
This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial. This program contains an example.
Dependencies: rosserial_mbed_lib mbed Servo
roscpp/SetLoggerLevel.h@3:dff241b66f84, 2011-11-12 (annotated)
- Committer:
- nucho
- Date:
- Sat Nov 12 23:53:04 2011 +0000
- Revision:
- 3:dff241b66f84
This program supported the revision of 167 of rosserial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 3:dff241b66f84 | 1 | #ifndef _ROS_SERVICE_SetLoggerLevel_h |
nucho | 3:dff241b66f84 | 2 | #define _ROS_SERVICE_SetLoggerLevel_h |
nucho | 3:dff241b66f84 | 3 | #include <stdint.h> |
nucho | 3:dff241b66f84 | 4 | #include <string.h> |
nucho | 3:dff241b66f84 | 5 | #include <stdlib.h> |
nucho | 3:dff241b66f84 | 6 | #include "ros/msg.h" |
nucho | 3:dff241b66f84 | 7 | |
nucho | 3:dff241b66f84 | 8 | namespace roscpp |
nucho | 3:dff241b66f84 | 9 | { |
nucho | 3:dff241b66f84 | 10 | |
nucho | 3:dff241b66f84 | 11 | static const char SETLOGGERLEVEL[] = "roscpp/SetLoggerLevel"; |
nucho | 3:dff241b66f84 | 12 | |
nucho | 3:dff241b66f84 | 13 | class SetLoggerLevelRequest : public ros::Msg |
nucho | 3:dff241b66f84 | 14 | { |
nucho | 3:dff241b66f84 | 15 | public: |
nucho | 3:dff241b66f84 | 16 | char * logger; |
nucho | 3:dff241b66f84 | 17 | char * level; |
nucho | 3:dff241b66f84 | 18 | |
nucho | 3:dff241b66f84 | 19 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 3:dff241b66f84 | 20 | { |
nucho | 3:dff241b66f84 | 21 | int offset = 0; |
nucho | 3:dff241b66f84 | 22 | uint32_t * length_logger = (uint32_t *)(outbuffer + offset); |
nucho | 3:dff241b66f84 | 23 | *length_logger = strlen( (const char*) this->logger); |
nucho | 3:dff241b66f84 | 24 | offset += 4; |
nucho | 3:dff241b66f84 | 25 | memcpy(outbuffer + offset, this->logger, *length_logger); |
nucho | 3:dff241b66f84 | 26 | offset += *length_logger; |
nucho | 3:dff241b66f84 | 27 | uint32_t * length_level = (uint32_t *)(outbuffer + offset); |
nucho | 3:dff241b66f84 | 28 | *length_level = strlen( (const char*) this->level); |
nucho | 3:dff241b66f84 | 29 | offset += 4; |
nucho | 3:dff241b66f84 | 30 | memcpy(outbuffer + offset, this->level, *length_level); |
nucho | 3:dff241b66f84 | 31 | offset += *length_level; |
nucho | 3:dff241b66f84 | 32 | return offset; |
nucho | 3:dff241b66f84 | 33 | } |
nucho | 3:dff241b66f84 | 34 | |
nucho | 3:dff241b66f84 | 35 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 3:dff241b66f84 | 36 | { |
nucho | 3:dff241b66f84 | 37 | int offset = 0; |
nucho | 3:dff241b66f84 | 38 | uint32_t length_logger = *(uint32_t *)(inbuffer + offset); |
nucho | 3:dff241b66f84 | 39 | offset += 4; |
nucho | 3:dff241b66f84 | 40 | for(unsigned int k= offset; k< offset+length_logger; ++k){ |
nucho | 3:dff241b66f84 | 41 | inbuffer[k-1]=inbuffer[k]; |
nucho | 3:dff241b66f84 | 42 | } |
nucho | 3:dff241b66f84 | 43 | inbuffer[offset+length_logger-1]=0; |
nucho | 3:dff241b66f84 | 44 | this->logger = (char *)(inbuffer + offset-1); |
nucho | 3:dff241b66f84 | 45 | offset += length_logger; |
nucho | 3:dff241b66f84 | 46 | uint32_t length_level = *(uint32_t *)(inbuffer + offset); |
nucho | 3:dff241b66f84 | 47 | offset += 4; |
nucho | 3:dff241b66f84 | 48 | for(unsigned int k= offset; k< offset+length_level; ++k){ |
nucho | 3:dff241b66f84 | 49 | inbuffer[k-1]=inbuffer[k]; |
nucho | 3:dff241b66f84 | 50 | } |
nucho | 3:dff241b66f84 | 51 | inbuffer[offset+length_level-1]=0; |
nucho | 3:dff241b66f84 | 52 | this->level = (char *)(inbuffer + offset-1); |
nucho | 3:dff241b66f84 | 53 | offset += length_level; |
nucho | 3:dff241b66f84 | 54 | return offset; |
nucho | 3:dff241b66f84 | 55 | } |
nucho | 3:dff241b66f84 | 56 | |
nucho | 3:dff241b66f84 | 57 | virtual const char * getType(){ return SETLOGGERLEVEL; }; |
nucho | 3:dff241b66f84 | 58 | virtual const char * getMD5(){ return "51da076440d78ca1684d36c868df61ea"; }; |
nucho | 3:dff241b66f84 | 59 | |
nucho | 3:dff241b66f84 | 60 | }; |
nucho | 3:dff241b66f84 | 61 | |
nucho | 3:dff241b66f84 | 62 | class SetLoggerLevelResponse : public ros::Msg |
nucho | 3:dff241b66f84 | 63 | { |
nucho | 3:dff241b66f84 | 64 | public: |
nucho | 3:dff241b66f84 | 65 | |
nucho | 3:dff241b66f84 | 66 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 3:dff241b66f84 | 67 | { |
nucho | 3:dff241b66f84 | 68 | int offset = 0; |
nucho | 3:dff241b66f84 | 69 | return offset; |
nucho | 3:dff241b66f84 | 70 | } |
nucho | 3:dff241b66f84 | 71 | |
nucho | 3:dff241b66f84 | 72 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 3:dff241b66f84 | 73 | { |
nucho | 3:dff241b66f84 | 74 | int offset = 0; |
nucho | 3:dff241b66f84 | 75 | return offset; |
nucho | 3:dff241b66f84 | 76 | } |
nucho | 3:dff241b66f84 | 77 | |
nucho | 3:dff241b66f84 | 78 | virtual const char * getType(){ return SETLOGGERLEVEL; }; |
nucho | 3:dff241b66f84 | 79 | virtual const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; }; |
nucho | 3:dff241b66f84 | 80 | |
nucho | 3:dff241b66f84 | 81 | }; |
nucho | 3:dff241b66f84 | 82 | |
nucho | 3:dff241b66f84 | 83 | class SetLoggerLevel { |
nucho | 3:dff241b66f84 | 84 | public: |
nucho | 3:dff241b66f84 | 85 | typedef SetLoggerLevelRequest Request; |
nucho | 3:dff241b66f84 | 86 | typedef SetLoggerLevelResponse Response; |
nucho | 3:dff241b66f84 | 87 | }; |
nucho | 3:dff241b66f84 | 88 | |
nucho | 3:dff241b66f84 | 89 | } |
nucho | 3:dff241b66f84 | 90 | #endif |