Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Commit

Permalink
Opening with O_NONBLOCK is tty-damaging.
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Zotov committed Jun 5, 2010
1 parent 5fc9b66 commit 753ee20
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions software/vuxprog.cpp
Expand Up @@ -26,7 +26,6 @@
#include <fstream>
#include <cctype>
#include <cstdlib>
#include <cerrno>
#include "picoopt.h"

#include <unistd.h>
Expand Down Expand Up @@ -123,7 +122,7 @@ class vuxboot {

public:
vuxboot(string filename, unsigned baud = B115200) : _debug(false) {
_fd = open(filename.c_str(), O_RDWR | O_NONBLOCK | O_NOCTTY);
_fd = open(filename.c_str(), O_RDWR | O_NOCTTY);
if(!_fd) throw new io_error("cannot open port");

// Serial initialization was written with FTDI USB-to-serial converters
Expand All @@ -142,9 +141,7 @@ class vuxboot {
}

~vuxboot() {
// do you ever want to kitten(1) your ttyUSB?
tcsetattr(_fd, TCSANOW, &_termios);

close(_fd);
}

Expand Down Expand Up @@ -310,14 +307,10 @@ class vuxboot {
}

retval = ::read(_fd, data + received, length);
if(retval == -1 && errno != EAGAIN) {
if(retval == -1) {
throw new io_error("cannot read()");
} else if(retval == 0) {
throw new io_error("read() == 0");
} else if(retval == -1) {
if(_debug)
cerr << "{EAGAIN} ";
continue;
}

if(_debug) {
Expand Down

0 comments on commit 753ee20

Please sign in to comment.