~hitmuri/vjpirate/trunk

« back to all changes in this revision

Viewing changes to os/win/include/vrpn_Serial.h

  • Committer: Florent Berthaut
  • Date: 2014-07-26 18:53:16 UTC
  • mfrom: (5.1.12 mac)
  • Revision ID: flo@localhost.localdomain-20140726185316-c2ucnwmgm5kij4e2
Merged mac branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef VRPN_SERIAL_H
 
2
#define VRPN_SERIAL_H
 
3
#ifndef _WIN32_WCE
 
4
#include <time.h>
 
5
#endif
 
6
#include <math.h>
 
7
#include <stdlib.h>
 
8
#include <stdio.h>
 
9
#ifdef _WIN32
 
10
#ifndef _WIN32_WCE
 
11
#include <io.h>
 
12
#endif
 
13
#else
 
14
#include <sys/time.h>
 
15
#endif
 
16
 
 
17
// vrpn_Serial
 
18
//
 
19
// Russ Taylor, 1998
 
20
 
 
21
// Pulls all the serial port routines into one file to make porting to
 
22
// new operating systems easier.
 
23
 
 
24
typedef enum {vrpn_SER_PARITY_NONE, vrpn_SER_PARITY_ODD, vrpn_SER_PARITY_EVEN,
 
25
                        vrpn_SER_PARITY_MARK, vrpn_SER_PARITY_SPACE} vrpn_SER_PARITY;
 
26
 
 
27
// flush discards characters in buffer
 
28
// drain blocks until they are written
 
29
 
 
30
// Open a serial port, given its name and baud rate. Settings are 8 bits,
 
31
// no parity, 1 start and stop bits.  Also, set the port so that it will
 
32
// return immediately if there are no characters or less than the number
 
33
// of characters requested.  Returns the file descriptor on success,
 
34
// -1 on failure.
 
35
extern VRPN_API int vrpn_open_commport(const char *portname, long baud, int charsize = 8, vrpn_SER_PARITY parity = vrpn_SER_PARITY_NONE);
 
36
 
 
37
// Set and clear functions for the RTS ("ready to send") hardware flow-
 
38
// control bit.  These are used on a port that is already open.  Some
 
39
// devices (like the Ascension Flock of Birds) use this to reset the
 
40
// device.  Return 0 on success, nonzero on error.
 
41
extern VRPN_API int vrpn_set_rts(int comm);
 
42
extern VRPN_API int vrpn_clear_rts(int comm);
 
43
 
 
44
extern VRPN_API int vrpn_close_commport(int comm);
 
45
// Throw out any characters within the input buffer.
 
46
//  Return 0 on success, -1 on error.
 
47
extern VRPN_API int vrpn_flush_input_buffer( int comm );
 
48
 
 
49
// Throw out any characters (do not send) within the output buffer
 
50
// Return 0 on success, tc err codes (whatever those are) on error.
 
51
extern VRPN_API int vrpn_flush_output_buffer( int comm );
 
52
 
 
53
// Wait until all of the characters in the output buffer are sent, then
 
54
// return.  Return 0 on success, -1 on error.
 
55
extern VRPN_API int vrpn_drain_output_buffer( int comm );
 
56
 
 
57
// Read up the the requested count of characters from the input buffer,
 
58
// return with less if less (or none) are there.  Return the number of
 
59
// characters read, or -1 if there is an error.  The second of these
 
60
// will keep looking until the timeout period expires before returning
 
61
// (NULL pointer will cause it to block indefinitely).
 
62
 
 
63
extern VRPN_API int vrpn_read_available_characters(int comm, unsigned char *buffer,
 
64
                int count);
 
65
extern VRPN_API int vrpn_read_available_characters(int comm, unsigned char *buffer,
 
66
                int count, struct timeval *timeout);
 
67
 
 
68
extern VRPN_API int vrpn_write_characters(int comm, const unsigned char *buffer, int bytes); 
 
69
#endif