47 #define STATUS_RESETTING (-1) // Resetting the device 48 #define STATUS_SYNCING (0) // Looking for the first character of report 49 #define STATUS_READING (1) // Looking for the rest of the report 51 #define TIMEOUT_TIME_INTERVAL (2000000L) // max time between reports (usec) 59 const char * port,
float temp1,
float temp2,
bool control_on):
82 fprintf(stderr,
"vrpn_BiosciencesTools: can't register handler\n");
87 fprintf(stderr,
"vrpn_BiosciencesTools: can't register handler\n");
92 fprintf(stderr,
"vrpn_BiosciencesTools: can't register handler\n");
96 fprintf(stderr,
"vrpn_BiosciencesTools: Can't get connection!\n");
115 int whole = static_cast<int>(value);
116 int dec = static_cast<int>(value*10) - whole*10;
117 sprintf(command,
"S%d %03d%d\r",
channel+1, whole,dec);
132 sprintf(command,
"ON\r");
134 sprintf(command,
"OFF\r");
154 sprintf(command,
"T%d\r",
channel+1);
156 printf(
"Sending command: %s", command);
174 if (*buf ==
'-') { buf++; }
177 if (sscanf(buf,
"%f%c", &val, &c) != 2) {
184 if ( (c !=
'E') && (c !=
'C') && (c !=
'\r') ) {
204 fprintf(stderr,
"vrpn_BiosciencesTools::reset(): Cannot send set ref temp 0, trying again\n");
208 fprintf(stderr,
"vrpn_BiosciencesTools::reset(): Cannot send set ref temp 1, trying again\n");
212 fprintf(stderr,
"vrpn_BiosciencesTools::reset(): Cannot send set control status, trying again\n");
221 fprintf(stderr,
"vrpn_BiosciencesTools::reset(): Cannot request temperature, trying again\n");
265 for (i = 1; i <
sizeof(
d_buffer); i++) {
269 printf(
"... Got the 1st char\n");
287 if (ret != 0) printf(
"... got %d total characters\n",
d_bufcount);
301 printf(
" Complete report: \n%s\n",
d_buffer);
304 if (value == -1000) {
313 printf(
"got a complete report (%d chars)!\n",
d_bufcount);
361 const char *bufptr = p.
buffer;
376 sprintf(msg,
"vrpn_BiosciencesTools::handle_request_message(): Index out of bounds (%d of %d), value %lg\n",
389 const char* bufptr = p.
buffer;
399 sprintf(msg,
"vrpn_BiosciencesTools::handle_request_channels_message(): Index out of bounds (%d of %d), clipping\n",
404 for (i = 0; i < num; i++) {
468 struct timeval current_time;
471 sprintf(errmsg,
"Timeout... current_time=%ld:%ld, timestamp=%ld:%ld",
472 current_time.tv_sec, static_cast<long>(current_time.tv_usec),
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
int vrpn_write_characters(int comm, const unsigned char *buffer, size_t bytes)
Write the buffer to the serial port.
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
void vrpn_SleepMsecs(double dMsecs)
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_int32 request_channels_m_id
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
int vrpn_flush_input_buffer(int comm)
Throw out any characters within the input buffer.
Header containing macros formerly duplicated in a lot of implementation files.
vrpn_Serial: Pulls all the serial port routines into one file to make porting to new operating system...
vrpn_float64 o_channel[vrpn_CHANNEL_MAX]
vrpn_float64 channel[vrpn_CHANNEL_MAX]
vrpn_int32 d_ping_message_id
Ask the server if they are there.
Generic connection class not specific to the transport mechanism.
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
#define VRPN_MSG_WARNING(msg)
All types of client/server/peer objects in VRPN should be derived from the vrpn_BaseClass type descri...
int vrpn_read_available_characters(int comm, unsigned char *buffer, size_t bytes)
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
vrpn_Connection * d_connection
Connection that this object talks to.
This structure is what is passed to a vrpn_Connection message callback.
int send_text_message(const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0)
Sends a NULL-terminated text message from the device d_sender_id.
#define vrpn_gettimeofday
vrpn_int32 d_sender_id
Sender ID registered with the connection.
unsigned long vrpn_TimevalDuration(struct timeval endT, struct timeval startT)
Return number of microseconds between startT and endT.
#define VRPN_MSG_ERROR(msg)