vrpn 07.35
Virtual Reality Peripheral Network
Loading...
Searching...
No Matches
vrpn_Shared.C File Reference
#include <math.h>
#include <stddef.h>
#include <stdio.h>
#include <ctime>
#include "vrpn_Shared.h"
#include <sys/select.h>
#include <netinet/in.h>
Include dependency graph for vrpn_Shared.C:

Go to the source code of this file.

Macros

#define CHECK(a)    if (a == -1) return -1
 

Functions

timeval vrpn_TimevalNormalize (const timeval &in_tv)
 
timeval vrpn_TimevalSum (const timeval &tv1, const timeval &tv2)
 
timeval vrpn_TimevalDiff (const timeval &tv1, const timeval &tv2)
 
timeval vrpn_TimevalScale (const timeval &tv, double scale)
 
bool vrpn_TimevalGreater (const timeval &tv1, const timeval &tv2)
 
bool vrpn_TimevalEqual (const timeval &tv1, const timeval &tv2)
 
unsigned long vrpn_TimevalDuration (struct timeval endT, struct timeval startT)
 Return number of microseconds between startT and endT.
 
double vrpn_TimevalDurationSeconds (struct timeval endT, struct timeval startT)
 Return the number of seconds between startT and endT as a floating-point value.
 
double vrpn_TimevalMsecs (const timeval &tv)
 
timeval vrpn_MsecsTimeval (const double dMsecs)
 
void vrpn_SleepMsecs (double dMilliSecs)
 
vrpn_float64 vrpn_htond (vrpn_float64 d)
 
vrpn_float64 vrpn_ntohd (vrpn_float64 d)
 
VRPN_API int vrpn_buffer (char **insertPt, vrpn_int32 *buflen, const timeval t)
 Utility routine for placing a timeval struct into a buffer that is to be sent as a message.
 
VRPN_API int vrpn_buffer (char **insertPt, vrpn_int32 *buflen, const char *string, vrpn_int32 length)
 Utility routine for placing a character string of given length into a buffer that is to be sent as a message.
 
VRPN_API int vrpn_unbuffer (const char **buffer, timeval *t)
 Utility routine for taking a struct timeval from a buffer that was sent as a message.
 
VRPN_API int vrpn_unbuffer (const char **buffer, char *string, vrpn_int32 length)
 Utility routine for taking a string of specified length from a buffer that was sent as a message.
 
bool vrpn_test_pack_unpack (void)
 

Macro Definition Documentation

◆ CHECK

#define CHECK (   a)     if (a == -1) return -1

Definition at line 23 of file vrpn_Shared.C.

Function Documentation

◆ vrpn_buffer() [1/2]

VRPN_API int vrpn_buffer ( char **  insertPt,
vrpn_int32 *  buflen,
const char *  string,
vrpn_int32  length 
)

Utility routine for placing a character string of given length into a buffer that is to be sent as a message.

Handles packing into an unaligned buffer (though this should not be done). Advances the insertPt pointer to just after newly-inserted value. Decreases the buflen (space remaining) by the length of the value. Returns zero on success and -1 on failure.

Part of a family of routines that buffer different VRPN types based on their type (vrpn_buffer is overloaded based on the third parameter type). These routines handle byte-swapping to the VRPN standard wire protocol.

If the length is specified as -1, then the string will be assumed to be NULL-terminated and will be copied using the string-copy routines.

Definition at line 280 of file vrpn_Shared.C.

◆ vrpn_buffer() [2/2]

VRPN_API int vrpn_buffer ( char **  insertPt,
vrpn_int32 *  buflen,
const timeval  t 
)

Utility routine for placing a timeval struct into a buffer that is to be sent as a message.

Handles packing into an unaligned buffer (though this should not be done). Advances the insertPt pointer to just after newly-inserted value. Decreases the buflen (space remaining) by the length of the value. Returns zero on success and -1 on failure.

Part of a family of routines that buffer different VRPN types based on their type (vrpn_buffer is overloaded based on the third parameter type). These routines handle byte-swapping to the VRPN standard wire protocol.

Definition at line 250 of file vrpn_Shared.C.

References vrpn_buffer().

Referenced by vrpn_Imager_Channel::buffer(), vrpn_Shared_String::encode(), vrpn_Shared_float64::encode(), vrpn_Shared_int32::encode(), vrpn_Tracker::encode_acc_to(), vrpn_ForceDevice::encode_addObject(), vrpn_ForceDevice::encode_addObjectExScene(), vrpn_Analog_Output_Remote::encode_change_channels_to(), vrpn_Analog_Output_Remote::encode_change_to(), vrpn_FunctionGenerator_Remote::encode_channel(), vrpn_FunctionGenerator_Server::encode_channel_reply(), vrpn_FunctionGenerator_Remote::encode_channel_request(), vrpn_ForceDevice::encode_clearTrimesh(), vrpn_ForceDevice::encode_custom_effect(), vrpn_RedundantController_Protocol::encode_enable(), vrpn_ForceDevice::encode_enableConstraint(), vrpn_ForceDevice::encode_error(), vrpn_FunctionGenerator_Server::encode_error_report(), vrpn_ForceDevice::encode_force(), vrpn_ForceDevice::encode_forcefield(), vrpn_FunctionGenerator_Server::encode_interpreterDescription_reply(), vrpn_ForceDevice::encode_moveToParent(), vrpn_ForceDevice::encode_normal(), vrpn_Analog_Output_Server::encode_num_channels_to(), vrpn_National_Instruments_Server::encode_num_channels_to(), vrpn_Analog_Output_Server_NI::encode_num_channels_to(), vrpn_ForceDevice::encode_objectOrientation(), vrpn_ForceDevice::encode_objectPosition(), vrpn_ForceDevice::encode_objectScale(), vrpn_ForceDevice::encode_plane(), vrpn_ForceDevice::encode_removeObject(), vrpn_ForceDevice::encode_removeTriangle(), vrpn_FunctionGenerator_Server::encode_sampleRate_reply(), vrpn_FunctionGenerator_Remote::encode_sampleRate_request(), vrpn_ForceDevice::encode_scp(), vrpn_RedundantController_Protocol::encode_set(), vrpn_ForceDevice::encode_setConstraintKSpring(), vrpn_ForceDevice::encode_setConstraintMode(), vrpn_ForceDevice::encode_setHapticOrigin(), vrpn_ForceDevice::encode_setHapticScale(), vrpn_ForceDevice::encode_setObjectIsTouchable(), vrpn_ForceDevice::encode_setSceneOrigin(), vrpn_ForceDevice::encode_setTrimeshType(), vrpn_FunctionGenerator_Server::encode_start_reply(), vrpn_Button::encode_states_to(), vrpn_Button_Filter::encode_states_to(), vrpn_FunctionGenerator_Server::encode_stop_reply(), vrpn_ForceDevice::encode_surface_effects(), vrpn_BaseClassUnique::encode_text_message_to_buffer(), vrpn_FunctionGenerator_function_script::encode_to(), vrpn_FunctionGenerator_channel::encode_to(), vrpn_Analog::encode_to(), vrpn_Poser::encode_to(), vrpn_Tracker::encode_to(), vrpn_Dial::encode_to(), vrpn_Button::encode_to(), vrpn_Tracker::encode_tracker2room_to(), vrpn_ForceDevice::encode_triangle(), vrpn_ForceDevice::encode_trimeshTransform(), vrpn_Tracker::encode_unit2sensor_to(), vrpn_ForceDevice::encode_updateTrimeshChanges(), vrpn_Poser::encode_vel_to(), vrpn_Tracker::encode_vel_to(), vrpn_ForceDevice::encode_vertex(), vrpn_Tracker::encode_workspace_to(), vrpn_Shared_int32::encodeLamport(), vrpn_Sound::encodeListenerPose(), vrpn_Sound::encodeListenerVelocity(), vrpn_Sound::encodeLoadMaterial(), vrpn_Sound::encodeLoadModel_local(), vrpn_Sound::encodeLoadPolyQuad(), vrpn_Sound::encodeLoadPolyTri(), vrpn_ForceDevice::encodePoint(), vrpn_Sound::encodeSetPolyMaterial(), vrpn_Sound::encodeSetPolyOF(), vrpn_Sound::encodeSetQuadVert(), vrpn_Sound::encodeSetTriVert(), vrpn_Sound::encodeSound_local(), vrpn_Sound::encodeSoundConeInfo(), vrpn_Sound::encodeSoundDef(), vrpn_Sound::encodeSoundDistInfo(), vrpn_Sound::encodeSoundDoplerScale(), vrpn_Sound::encodeSoundEqFactor(), vrpn_Sound::encodeSoundID(), vrpn_Sound::encodeSoundPitch(), vrpn_Sound::encodeSoundPlay(), vrpn_Sound::encodeSoundPose(), vrpn_Sound::encodeSoundVelocity(), vrpn_Sound::encodeSoundVolume(), vrpn_Imager_Stream_Buffer::handle_server_messages(), vrpn_YEI_3Space::init(), vrpn_Endpoint::pack_log_description(), vrpn_Auxiliary_Logger::pack_log_message_of_type(), vrpn_Mutex_Remote::requestIndex(), vrpn_YEI_3Space::reset(), vrpn_Imager_Server::send_begin_frame(), vrpn_Imager_Server::send_description(), vrpn_ImagerPose_Server::send_description(), vrpn_Imager_Server::send_discarded_frames(), vrpn_Imager_Server::send_end_frame(), vrpn_Imager_Server::send_region_using_base_pointer(), vrpn_PeerMutex::sendDenyRequest(), vrpn_Mutex::sendDenyRequest(), vrpn_PeerMutex::sendGrantRequest(), vrpn_Mutex::sendGrantRequest(), vrpn_PeerMutex::sendRelease(), vrpn_PeerMutex::sendRequest(), vrpn_Mutex::sendRequest(), vrpn_YEI_3Space_Sensor_Wireless::set_logical_id(), vrpn_File_Controller::set_replay_rate(), vrpn_Tracker_Remote::set_update_rate(), vrpn_Imager_Remote::throttle_sender(), vrpn_buffer(), and vrpn_test_pack_unpack().

Here is the call graph for this function:

◆ vrpn_htond()

vrpn_float64 vrpn_htond ( vrpn_float64  d)

Definition at line 199 of file vrpn_Shared.C.

Referenced by vrpn_byte_order::hton(), and vrpn_ntohd().

◆ vrpn_MsecsTimeval()

timeval vrpn_MsecsTimeval ( const double  dMsecs)

◆ vrpn_ntohd()

vrpn_float64 vrpn_ntohd ( vrpn_float64  d)

Definition at line 235 of file vrpn_Shared.C.

References vrpn_htond().

Referenced by vrpn_byte_order::ntoh().

Here is the call graph for this function:

◆ vrpn_SleepMsecs()

void vrpn_SleepMsecs ( double  dMilliSecs)

Definition at line 166 of file vrpn_Shared.C.

Referenced by vrpn_Tracker_Flock::checkError(), vrpn_IDEA::get_report(), vrpn_Tracker_Flock::getMeasurementRate(), vrpn_Imager_Stream_Buffer::handle_got_first_connection(), vrpn_Imager_Stream_Buffer::handle_request_logging(), vrpn_Tracker_LibertyHS::launch_markers(), vrpn_Imager_Stream_Buffer::logging_thread_func(), vrpn_ADBox::mainloop(), vrpn_Analog_USDigital_A2::mainloop(), vrpn_Tracker_Flock_Parallel::mainloop(), vrpn_WiiMote::mainloop(), vrpn_Imager_Stream_Buffer::make_new_logging_connection(), vrpn_Tracker_Crossbow::recalibrate(), vrpn_National_Instruments_Server::reportError(), vrpn_Tracker_3Space::reset(), vrpn_Tracker_Dyna::reset(), vrpn_Tracker_Flock::reset(), vrpn_Tracker_Flock_Parallel_Slave::reset(), vrpn_raw_SGIBox::reset(), vrpn_Streaming_Arduino::reset(), vrpn_Tracker_3DMouse::reset(), vrpn_Tracker_Crossbow::reset(), vrpn_Tracker_Fastrak::reset(), vrpn_Tracker_Isotrak::reset(), vrpn_Tracker_Liberty::reset(), vrpn_Tracker_LibertyHS::reset(), vrpn_Joystick::reset(), vrpn_5dt16::reset(), vrpn_5dt::reset(), vrpn_BiosciencesTools::reset(), vrpn_IDEA::reset(), vrpn_Nikon_Controls::reset(), vrpn_Poser_Tek4662::reset(), vrpn_YEI_3Space::reset(), vrpn_Zaber::reset(), vrpn_Tracker_3DMouse::set_filtering_count(), vrpn_Tracker_Fastrak::set_sensor_output_format(), vrpn_Tracker_Isotrak::set_sensor_output_format(), vrpn_Tracker_Liberty::set_sensor_output_format(), vrpn_Tracker_LibertyHS::set_sensor_output_format(), vrpn_Imager_Stream_Buffer::stop_logging_thread(), vrpn_Tracker_NDI_Polaris::switchToHigherBaudRate(), vrpn_Tracker_LibertyHS::test_markers(), vrpn_LUDL_USBMAC6000::vrpn_LUDL_USBMAC6000(), vrpn_Magellan::vrpn_Magellan(), vrpn_test_threads_and_semaphores(), vrpn_Tracker_NDI_Polaris::vrpn_Tracker_NDI_Polaris(), vrpn_write_slowly(), vrpn_Tracker_LibertyHS::~vrpn_Tracker_LibertyHS(), vrpn_Tracker_RazerHydra::~vrpn_Tracker_RazerHydra(), and vrpn_WiiMote::~vrpn_WiiMote().

◆ vrpn_test_pack_unpack()

bool vrpn_test_pack_unpack ( void  )

Definition at line 995 of file vrpn_Shared.C.

References vrpn_buffer(), and vrpn_buffer_to_little_endian().

Here is the call graph for this function:

◆ vrpn_TimevalDiff()

◆ vrpn_TimevalDuration()

unsigned long vrpn_TimevalDuration ( struct timeval  endT,
struct timeval  startT 
)

◆ vrpn_TimevalDurationSeconds()

◆ vrpn_TimevalEqual()

bool vrpn_TimevalEqual ( const timeval &  tv1,
const timeval &  tv2 
)

◆ vrpn_TimevalGreater()

◆ vrpn_TimevalMsecs()

double vrpn_TimevalMsecs ( const timeval &  tv)

◆ vrpn_TimevalNormalize()

timeval vrpn_TimevalNormalize ( const timeval &  in_tv)

Definition at line 43 of file vrpn_Shared.C.

Referenced by vrpn_BaseClassUnique::client_mainloop().

◆ vrpn_TimevalScale()

timeval vrpn_TimevalScale ( const timeval &  tv,
double  scale 
)

◆ vrpn_TimevalSum()

◆ vrpn_unbuffer() [1/2]

VRPN_API int vrpn_unbuffer ( const char **  buffer,
char *  string,
vrpn_int32  length 
)

Utility routine for taking a string of specified length from a buffer that was sent as a message.

Does NOT handle unpacking from an unaligned buffer, because the semantics of VRPN require message buffers and the values in them to be aligned, in order to reduce the amount of copying that goes on. Advances the read pointer to just after newly-read value. Assumes that the buffer holds a complete value. Returns zero on success and -1 on failure.

Part of a family of routines that unbuffer different VRPN types based on their type (vrpn_buffer is overloaded based on the third parameter type). These routines handle byte-swapping to and from the VRPN defined wire protocol.

If the length is specified as less than zero, then the string will be assumed to be NULL-terminated and will be read using the string-copy routines with a length that is at most the magnitude of the number (-16 means at most 16). NEVER use this on a string that was packed with other than the NULL-terminating condition, since embedded NULL characters will ruin the argument parsing for any later arguments in the message.

Definition at line 356 of file vrpn_Shared.C.

◆ vrpn_unbuffer() [2/2]

VRPN_API int vrpn_unbuffer ( const char **  buffer,
timeval *  t 
)

Utility routine for taking a struct timeval from a buffer that was sent as a message.

Handles unpacking from an unaligned buffer, because people did this anyway. Advances the reading pointer to just after newly-read value. Assumes that the buffer holds a complete value. Returns zero on success and -1 on failure.

Part of a family of routines that unbuffer different VRPN types based on their type (vrpn_buffer is overloaded based on the third parameter type). These routines handle byte-swapping to and from the VRPN defined wire protocol.

Definition at line 321 of file vrpn_Shared.C.

References CHECK, and vrpn_unbuffer().

Referenced by vrpn_Radamec_SPI::convert_16bit_unsigned(), vrpn_Radamec_SPI::convert_24bit_unsigned(), vrpn_Shared_String::decode(), vrpn_Shared_float64::decode(), vrpn_Shared_int32::decode(), vrpn_ForceDevice::decode_addObject(), vrpn_ForceDevice::decode_addObjectExScene(), vrpn_FunctionGenerator_Server::decode_channel(), vrpn_FunctionGenerator_Remote::decode_channel_reply(), vrpn_FunctionGenerator_Server::decode_channel_request(), vrpn_ForceDevice::decode_clearTrimesh(), vrpn_ForceDevice::decode_custom_effect(), vrpn_RedundantController_Protocol::decode_enable(), vrpn_ForceDevice::decode_enableConstraint(), vrpn_ForceDevice::decode_error(), vrpn_FunctionGenerator_Remote::decode_error_reply(), vrpn_ForceDevice::decode_force(), vrpn_ForceDevice::decode_forcefield(), vrpn_FunctionGenerator_function_script::decode_from(), vrpn_FunctionGenerator_channel::decode_from(), vrpn_FunctionGenerator_Remote::decode_interpreterDescription_reply(), vrpn_ForceDevice::decode_moveToParent(), vrpn_ForceDevice::decode_normal(), vrpn_ForceDevice::decode_objectOrientation(), vrpn_ForceDevice::decode_objectPosition(), vrpn_ForceDevice::decode_objectScale(), vrpn_ForceDevice::decode_plane(), vrpn_ForceDevice::decode_removeObject(), vrpn_ForceDevice::decode_removeTriangle(), vrpn_FunctionGenerator_Remote::decode_sampleRate_reply(), vrpn_FunctionGenerator_Server::decode_sampleRate_request(), vrpn_ForceDevice::decode_scp(), vrpn_RedundantController_Protocol::decode_set(), vrpn_ForceDevice::decode_setConstraintKSpring(), vrpn_ForceDevice::decode_setConstraintMode(), vrpn_ForceDevice::decode_setHapticOrigin(), vrpn_ForceDevice::decode_setHapticScale(), vrpn_ForceDevice::decode_setObjectIsTouchable(), vrpn_ForceDevice::decode_setSceneOrigin(), vrpn_ForceDevice::decode_setTrimeshType(), vrpn_FunctionGenerator_Remote::decode_start_reply(), vrpn_FunctionGenerator_Remote::decode_stop_reply(), vrpn_ForceDevice::decode_surface_effects(), vrpn_BaseClassUnique::decode_text_message_from_buffer(), vrpn_ForceDevice::decode_triangle(), vrpn_ForceDevice::decode_trimeshTransform(), vrpn_ForceDevice::decode_updateTrimeshChanges(), vrpn_ForceDevice::decode_vertex(), vrpn_Shared_int32::decodeLamport(), vrpn_Sound::decodeListenerPose(), vrpn_Sound::decodeListenerVelocity(), vrpn_Sound::decodeLoadMaterial(), vrpn_Sound::decodeLoadModel_local(), vrpn_Sound::decodeLoadPolyQuad(), vrpn_Sound::decodeLoadPolyTri(), vrpn_ForceDevice::decodePoint(), vrpn_Sound::decodeSetPolyMaterial(), vrpn_Sound::decodeSetPolyOF(), vrpn_Sound::decodeSetQuadVert(), vrpn_Sound::decodeSetTriVert(), vrpn_Sound::decodeSound_local(), vrpn_Sound::decodeSoundConeInfo(), vrpn_Sound::decodeSoundDef(), vrpn_Sound::decodeSoundDistInfo(), vrpn_Sound::decodeSoundDoplerScale(), vrpn_Sound::decodeSoundEqFactor(), vrpn_Sound::decodeSoundID(), vrpn_Sound::decodeSoundPitch(), vrpn_Sound::decodeSoundPlay(), vrpn_Sound::decodeSoundPose(), vrpn_Sound::decodeSoundVelocity(), vrpn_Sound::decodeSoundVolume(), vrpn_Tracker_Remote::handle_acc_change_message(), vrpn_Imager_Remote::handle_begin_frame_message(), vrpn_Analog_Remote::handle_change_message(), vrpn_Button_Remote::handle_change_message(), vrpn_Dial_Remote::handle_change_message(), vrpn_Poser_Server::handle_change_message(), vrpn_Poser_Analog::handle_change_message(), vrpn_Poser_Tek4662::handle_change_message(), vrpn_Tracker_Remote::handle_change_message(), vrpn_Mutex_Remote::handle_denyRequest(), vrpn_PeerMutex::handle_denyRequest(), vrpn_Imager_Remote::handle_description_message(), vrpn_ImagerPose_Remote::handle_description_message(), vrpn_Imager_Remote::handle_discarded_frames_message(), vrpn_Imager_Remote::handle_end_frame_message(), vrpn_Mutex_Remote::handle_grantRequest(), vrpn_PeerMutex::handle_grantRequest(), vrpn_Mutex_Remote::handle_initialize(), vrpn_Connection::handle_log_message(), vrpn_Imager_Remote::handle_region_message(), vrpn_Poser_Server::handle_relative_change_message(), vrpn_Poser_Server::handle_relative_vel_change_message(), vrpn_PeerMutex::handle_release(), vrpn_YEI_3Space::handle_report(), vrpn_Analog_Output_Remote::handle_report_num_channels(), vrpn_PeerMutex::handle_request(), vrpn_Analog_Output_Server::handle_request_channels_message(), vrpn_BiosciencesTools::handle_request_channels_message(), vrpn_IDEA::handle_request_channels_message(), vrpn_LUDL_USBMAC6000::handle_request_channels_message(), vrpn_National_Instruments_Server::handle_request_channels_message(), vrpn_Analog_Output_Server_NI::handle_request_channels_message(), vrpn_Nikon_Controls::handle_request_channels_message(), vrpn_WiiMote::handle_request_channels_message(), vrpn_Zaber::handle_request_channels_message(), vrpn_Analog_Output_Server::handle_request_message(), vrpn_BiosciencesTools::handle_request_message(), vrpn_IDEA::handle_request_message(), vrpn_LUDL_USBMAC6000::handle_request_message(), vrpn_National_Instruments_Server::handle_request_message(), vrpn_Analog_Output_Server_NI::handle_request_message(), vrpn_Nikon_Controls::handle_request_message(), vrpn_WiiMote::handle_request_message(), vrpn_Zaber::handle_request_message(), vrpn_Mutex_Server::handle_requestMutex(), vrpn_Button_Remote::handle_states_message(), vrpn_Imager_Server::handle_throttle_message(), vrpn_Tracker_Remote::handle_tracker2room_change_message(), vrpn_Tracker_Remote::handle_unit2sensor_change_message(), vrpn_Tracker_PhaseSpace::handle_update_rate_request(), vrpn_Poser_Server::handle_vel_change_message(), vrpn_Poser_Analog::handle_vel_change_message(), vrpn_Poser_Tek4662::handle_vel_change_message(), vrpn_Tracker_Remote::handle_vel_change_message(), vrpn_Tracker_Remote::handle_workspace_change_message(), vrpn_YEI_3Space_Sensor::receive_LED_values_response(), vrpn_YEI_3Space_Sensor_Wireless::receive_LED_values_response(), vrpn_Tracker_Crossbow::reset(), vrpn_Imager_Stream_Buffer::static_handle_throttle_message(), vrpn_Imager_Channel::unbuffer(), vrpn_Tracker_Crossbow::unbuffer_packet(), vrpn_Auxiliary_Logger::unpack_log_message_from_buffer(), and vrpn_unbuffer().

Here is the call graph for this function: