-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserial_posix.h
45 lines (36 loc) · 1.45 KB
/
serial_posix.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
/*
stm32flash - Open Source ST STM32 flash program for *nix
Copyright (C) 2010 Geoffrey McRae <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _SERIAL_POSIX_H
#define _SERIAL_POSIX_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
struct serial{
int fd;
struct termios oldtio;
struct termios newtio;
char setup_str[11];
};
typedef struct serial serial_t;
serial_t *serial_open(const char *device);
void serial_close(serial_t *h);
void serial_flush(const serial_t *h);
int serial_setup(serial_t *h,speed_t port_baud,tcflag_t port_bits,tcflag_t port_parity,tcflag_t port_stop);
void serial_it_config(serial_t *h);
int serial_read(const serial_t *h, void *buf,size_t nbyte);
int serial_write(const serial_t *h, void *buf,size_t nbyte);
#endif