Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Mart Lubbers
CleanSerial
Commits
6b9486bd
Commit
6b9486bd
authored
Oct 05, 2016
by
Mart Lubbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
2fc04768
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
tty.c
tty.c
+9
-4
No files found.
tty.c
View file @
6b9486bd
...
...
@@ -17,7 +17,6 @@
#endif
#define INITIAL_BUFFERSIZE 2
#define DEVICE_TIMEOUT {0, 0}
#define die(s) {perror(s);exit(EXIT_FAILURE);}
...
...
@@ -102,8 +101,9 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity,
debug
(
"ttyopen"
);
struct
termios
tio
;
char
*
cs_fn
=
cleanStringToCString
(
fn
);
*
fd
=
open
(
cs_fn
,
O_RDWR
|
O_NOCTTY
);
*
fd
=
open
(
cs_fn
,
O_RDWR
|
O_NOCTTY
|
O_NDELAY
|
O_NONBLOCK
);
*
status
=
0
;
fcntl
(
*
fd
,
F_SETFL
,
0
);
if
(
*
fd
<
0
){
error
=
strerror
(
errno
);
}
else
{
...
...
@@ -142,6 +142,9 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity,
//Set
tio
.
c_oflag
=
0
;
tio
.
c_lflag
|=
ICANON
;
tio
.
c_cc
[
VMIN
]
=
5
;
tio
.
c_cc
[
VTIME
]
=
0
;
tcsetattr
(
*
fd
,
TCSANOW
,
&
tio
);
*
status
=
1
;
...
...
@@ -198,12 +201,14 @@ void ttyavailable(int fd, int *r, int *fdo)
{
debug
(
"ttyavailable"
);
fd_set
fds
;
struct
timeval
tv
=
DEVICE_TIMEOUT
;
struct
timeval
tv
;
tv
.
tv_sec
=
0
;
tv
.
tv_usec
=
0
;
FD_ZERO
(
&
fds
);
FD_SET
(
fd
,
&
fds
);
*
r
=
select
(
fd
+
1
,
&
fds
,
NULL
,
NULL
,
NULL
);
*
r
=
select
(
fd
+
1
,
&
fds
,
NULL
,
NULL
,
&
tv
);
if
(
*
r
==
-
1
)
die
(
"select"
);
*
fdo
=
fd
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment