c++/drivers/ld/sickld-1.0/SickLDUtility.hh

Go to the documentation of this file.
00001 /*!
00002  * \file SickLDUtility.hh
00003  * \brief Defines simple utility functions for working with the Sick LD.
00004  *
00005  * Code by Jason C. Derenick and Thomas H. Miller.
00006  * Contact derenick(at)lehigh(dot)edu
00007  *
00008  * The Sick LIDAR Matlab/C++ Toolbox
00009  * Copyright (c) 2008, Jason C. Derenick and Thomas H. Miller
00010  * All rights reserved.
00011  *
00012  * This software is released under a BSD Open-Source License.
00013  * See http://sicktoolbox.sourceforge.net
00014  */
00015 
00016 /* Auto-generated header */
00017 #include "SickConfig.hh"
00018 
00019 /**
00020  * \def REVERSE_BYTE_ORDER_16
00021  * \brief Reverses the byte order of the given 16 bit unsigned integer
00022  */ 
00023 #define REVERSE_BYTE_ORDER_16( y ) ( ( ( y & 0x00FF ) << 8 ) | ( ( y & 0xFF00 ) >> 8 ) )
00024 
00025 /**
00026  * \def REVERSE_BYTE_ORDER_32
00027  * \brief Reverses the byte order of the given 32 bit unsigned integer
00028  */ 
00029 #define REVERSE_BYTE_ORDER_32( y ) ( ( ( y & 0x000000FF ) << 24 ) | ( ( y & 0x0000FF00 ) << 8 ) | ( ( y & 0x00FF0000 ) >> 8 ) | ( ( y & 0xFF000000 ) >> 24 ) )
00030 
00031 /* Associate the namespace */
00032 namespace SickToolbox {
00033   
00034 #ifndef WORDS_BIGENDIAN
00035 
00036 /* NOTE: The following functions are necessary since the Sick LD doesn't adopt the
00037  *       convention of converting from network byte order.
00038  */
00039 
00040 /**
00041  * \brief Converts host byte order (little-endian) to Sick LD byte order (big-endian)
00042  * \param value The 2-byte value to convert to big-endian
00043  * \return Value in Sick LD byte order (big-endian)
00044  */
00045 inline uint16_t host_to_sick_ld_byte_order( uint16_t value ) {
00046   return REVERSE_BYTE_ORDER_16(value);
00047 }
00048 
00049 /**
00050  * \brief Converts host byte order (little-endian) to Sick LD byte order (big-endian)
00051  * \param value The 4-byte value to convert to big-endian
00052  * \return Value in Sick LD byte order (big-endian)
00053  */
00054 inline uint32_t host_to_sick_ld_byte_order( uint32_t value ) {
00055   return REVERSE_BYTE_ORDER_32(value);
00056 }
00057 
00058 /**
00059  * \brief Converts Sick LD byte order (big-endian) to host byte order (little-endian)
00060  * \param value The 2-byte value to convert to little-endian
00061  * \return Value in host byte order (little-endian)
00062  */
00063 inline uint16_t sick_ld_to_host_byte_order( uint16_t value ) {
00064   return REVERSE_BYTE_ORDER_16(value);
00065 }
00066 
00067 /**
00068  * \brief Converts Sick LD byte order (big-endian) to host byte order (little-endian)
00069  * \param value The 4-byte value to convert to little-endian
00070  * \return Value in host byte order (little-endian)
00071  */
00072 inline uint32_t sick_ld_to_host_byte_order( uint32_t value ) {
00073   return REVERSE_BYTE_ORDER_32(value);
00074 }
00075 
00076 #else // The host has a big-endian architecture
00077 
00078 /**
00079  * \brief Converts host byte order (big-endian) to Sick LD byte order (big-endian)
00080  * \param value The 2-byte value to convert to big-endian
00081  * \return Value in Sick LD byte order (big-endian)
00082  */
00083 inline uint16_t host_to_sick_ld_byte_order( uint16_t value ) {
00084   return value;
00085 }
00086 
00087 /**
00088  * \brief Converts host byte order (big-endian) to Sick LD byte order (big-endian)
00089  * \param value The 4-byte value to convert to big-endian
00090  * \return Value in Sick LD byte order (big-endian)
00091  */
00092 inline uint32_t host_to_sick_ld_byte_order( uint32_t value ) {
00093   return value;
00094 }
00095 
00096 /**
00097  * \brief Converts Sick LD byte order (big-endian) to host byte order (big-endian)
00098  * \param value The 2-byte value to convert to big-endian
00099  * \return Value in host byte order (big-endian)
00100  */
00101 inline uint16_t sick_ld_to_host_byte_order( uint16_t value ) {
00102   return value;
00103 }
00104 
00105 /**
00106  * \brief Converts Sick LD byte order (big-endian) to host byte order (big-endian)
00107  * \param value The 4-byte value to convert to big-endian
00108  * \return Value in host byte order (big-endian)
00109  */
00110 inline uint32_t sick_ld_to_host_byte_order( uint32_t value ) {
00111   return value;
00112 }
00113 
00114 #endif /* _LITTLE_ENDIAN_HOST */
00115 
00116 /*
00117  * NOTE: Other utility functions can be defined here
00118  */
00119   
00120 } //namespace SickToolbox

Generated on Thu Mar 20 09:41:42 2008 for sicktoolbox-1.0 by  doxygen 1.5.1