Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: rosserial_mbed_hello_world_publisher_melodic Motortest Nucleo_vr_servo_project NucleoFM ... more
std_msgs/Int16.h@1:da82487f547e, 2019-11-08 (annotated)
- Committer:
- Gary Servin
- Date:
- Fri Nov 08 14:55:04 2019 -0300
- Revision:
- 1:da82487f547e
- Parent:
- 0:04ac6be8229a
Add missing round() method
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Gary Servin |
0:04ac6be8229a | 1 | #ifndef _ROS_std_msgs_Int16_h |
| Gary Servin |
0:04ac6be8229a | 2 | #define _ROS_std_msgs_Int16_h |
| Gary Servin |
0:04ac6be8229a | 3 | |
| Gary Servin |
0:04ac6be8229a | 4 | #include <stdint.h> |
| Gary Servin |
0:04ac6be8229a | 5 | #include <string.h> |
| Gary Servin |
0:04ac6be8229a | 6 | #include <stdlib.h> |
| Gary Servin |
0:04ac6be8229a | 7 | #include "ros/msg.h" |
| Gary Servin |
0:04ac6be8229a | 8 | |
| Gary Servin |
0:04ac6be8229a | 9 | namespace std_msgs |
| Gary Servin |
0:04ac6be8229a | 10 | { |
| Gary Servin |
0:04ac6be8229a | 11 | |
| Gary Servin |
0:04ac6be8229a | 12 | class Int16 : public ros::Msg |
| Gary Servin |
0:04ac6be8229a | 13 | { |
| Gary Servin |
0:04ac6be8229a | 14 | public: |
| Gary Servin |
0:04ac6be8229a | 15 | typedef int16_t _data_type; |
| Gary Servin |
0:04ac6be8229a | 16 | _data_type data; |
| Gary Servin |
0:04ac6be8229a | 17 | |
| Gary Servin |
0:04ac6be8229a | 18 | Int16(): |
| Gary Servin |
0:04ac6be8229a | 19 | data(0) |
| Gary Servin |
0:04ac6be8229a | 20 | { |
| Gary Servin |
0:04ac6be8229a | 21 | } |
| Gary Servin |
0:04ac6be8229a | 22 | |
| Gary Servin |
0:04ac6be8229a | 23 | virtual int serialize(unsigned char *outbuffer) const |
| Gary Servin |
0:04ac6be8229a | 24 | { |
| Gary Servin |
0:04ac6be8229a | 25 | int offset = 0; |
| Gary Servin |
0:04ac6be8229a | 26 | union { |
| Gary Servin |
0:04ac6be8229a | 27 | int16_t real; |
| Gary Servin |
0:04ac6be8229a | 28 | uint16_t base; |
| Gary Servin |
0:04ac6be8229a | 29 | } u_data; |
| Gary Servin |
0:04ac6be8229a | 30 | u_data.real = this->data; |
| Gary Servin |
0:04ac6be8229a | 31 | *(outbuffer + offset + 0) = (u_data.base >> (8 * 0)) & 0xFF; |
| Gary Servin |
0:04ac6be8229a | 32 | *(outbuffer + offset + 1) = (u_data.base >> (8 * 1)) & 0xFF; |
| Gary Servin |
0:04ac6be8229a | 33 | offset += sizeof(this->data); |
| Gary Servin |
0:04ac6be8229a | 34 | return offset; |
| Gary Servin |
0:04ac6be8229a | 35 | } |
| Gary Servin |
0:04ac6be8229a | 36 | |
| Gary Servin |
0:04ac6be8229a | 37 | virtual int deserialize(unsigned char *inbuffer) |
| Gary Servin |
0:04ac6be8229a | 38 | { |
| Gary Servin |
0:04ac6be8229a | 39 | int offset = 0; |
| Gary Servin |
0:04ac6be8229a | 40 | union { |
| Gary Servin |
0:04ac6be8229a | 41 | int16_t real; |
| Gary Servin |
0:04ac6be8229a | 42 | uint16_t base; |
| Gary Servin |
0:04ac6be8229a | 43 | } u_data; |
| Gary Servin |
0:04ac6be8229a | 44 | u_data.base = 0; |
| Gary Servin |
0:04ac6be8229a | 45 | u_data.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0); |
| Gary Servin |
0:04ac6be8229a | 46 | u_data.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
| Gary Servin |
0:04ac6be8229a | 47 | this->data = u_data.real; |
| Gary Servin |
0:04ac6be8229a | 48 | offset += sizeof(this->data); |
| Gary Servin |
0:04ac6be8229a | 49 | return offset; |
| Gary Servin |
0:04ac6be8229a | 50 | } |
| Gary Servin |
0:04ac6be8229a | 51 | |
| Gary Servin |
0:04ac6be8229a | 52 | const char * getType(){ return "std_msgs/Int16"; }; |
| Gary Servin |
0:04ac6be8229a | 53 | const char * getMD5(){ return "8524586e34fbd7cb1c08c5f5f1ca0e57"; }; |
| Gary Servin |
0:04ac6be8229a | 54 | |
| Gary Servin |
0:04ac6be8229a | 55 | }; |
| Gary Servin |
0:04ac6be8229a | 56 | |
| Gary Servin |
0:04ac6be8229a | 57 | } |
| Gary Servin |
0:04ac6be8229a | 58 | #endif |