-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgertbot_winserial.h
58 lines (47 loc) · 1.24 KB
/
gertbot_winserial.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Serial comm port SW
// Simplified system using local handle
// and blocking (non overlapped) operation
//
// G.J. van Loo, 30 April, 2014
//
#include <windows.h>
#include <stdint.h>
#define SLEEP_MS(x) Sleep(x)
//
// open comm port <n>
//
// Return 0 on success
// return 1 on error
//
int open_uart(int number);
//
// Set up comm port using settings string
// e.g. "9600,n,8,1"
// or "baud=19200 parity=n data=8 stop=1"
// port must previoulsy been opened
//
// Return 0 on success
// return 1 on error
//
// Needs TCHAR pointer which can be obtained by using
// setup_comm_port ( L "...");
// ^!!
int setup_comm_port(TCHAR *com_format);
// Closes comm port
void close_uart();
// Read bytes from comm port
// returns actual number of bytes read
int read_uart(unsigned char *read_buffer,int bytes);
// Write bytes to comm port
// returns actual number of bytes written
int write_uart(unsigned char *write_buffer,int bytes);
/** Windows has some extra routines **/
int setup_comm_port(TCHAR *com_format);
//
// Returns 32-bit integer with a bit set for each comm port found
// Thus limited to comm ports 1-32
//
uint32_t available_com_ports(void);
// Find bit 'p' which is set
int index_comport(int available_ports,int p);