-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial.hpp
executable file
·39 lines (33 loc) · 1013 Bytes
/
serial.hpp
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
#ifndef __SERIAL__
#define __SERIAL__
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include <sys/poll.h>
/*
* 'open_port()' - Open serial port 1.
*
* Returns the file descriptor on success or -1 on error.
*/
class serialport
{
int fd;
struct termios options;
public:
serialport();
serialport(const char* port_adress, int baudrate);
int init(const char* port_adress, int baudrate);
int open(const char* port_adress);
void set_rate(int baudrate);
//void set_parity();
int read( void* destination, unsigned bytesize);
int write(void* data, unsigned bytesize);
int close();
int get_fd();
int flush();
};
void swap_endian(char* pt, unsigned char byte_size);
#endif