Diffstat (limited to 'noncore/apps/opie-console/io_serial.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index b89a53b..cc63c58 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp | |||
@@ -25,48 +25,49 @@ void IOSerial::send(const QByteArray &data) { | |||
25 | } else { | 25 | } else { |
26 | emit error(Refuse, tr("Not connected")); | 26 | emit error(Refuse, tr("Not connected")); |
27 | } | 27 | } |
28 | } | 28 | } |
29 | 29 | ||
30 | void IOSerial::close() { | 30 | void IOSerial::close() { |
31 | if (m_fd) { | 31 | if (m_fd) { |
32 | delete m_read; | 32 | delete m_read; |
33 | delete m_error; | 33 | delete m_error; |
34 | ::close(m_fd); | 34 | ::close(m_fd); |
35 | m_fd = 0; | 35 | m_fd = 0; |
36 | m_connected = false; | 36 | m_connected = false; |
37 | } else { | 37 | } else { |
38 | m_connected = false; | 38 | m_connected = false; |
39 | emit error(Refuse, tr("Not connected")); | 39 | emit error(Refuse, tr("Not connected")); |
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | bool IOSerial::open() { | 43 | bool IOSerial::open() { |
44 | if (!m_fd) { | 44 | if (!m_fd) { |
45 | struct termios tty; | 45 | struct termios tty; |
46 | m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); | 46 | m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); |
47 | if (m_fd < 0) { | 47 | if (m_fd < 0) { |
48 | emit error(CouldNotOpen, strerror(errno)); | 48 | emit error(CouldNotOpen, strerror(errno)); |
49 | m_fd = 0; | ||
49 | return FALSE; | 50 | return FALSE; |
50 | } | 51 | } |
51 | tcgetattr(m_fd, &tty); | 52 | tcgetattr(m_fd, &tty); |
52 | 53 | ||
53 | /* Baud rate */ | 54 | /* Baud rate */ |
54 | int speed = baud(m_baud); | 55 | int speed = baud(m_baud); |
55 | if (speed == -1) { | 56 | if (speed == -1) { |
56 | emit error(Refuse, tr("Invalid baud rate")); | 57 | emit error(Refuse, tr("Invalid baud rate")); |
57 | } | 58 | } |
58 | cfsetospeed(&tty, speed); | 59 | cfsetospeed(&tty, speed); |
59 | cfsetispeed(&tty, speed); | 60 | cfsetispeed(&tty, speed); |
60 | 61 | ||
61 | /* Take care of Space / Mark parity */ | 62 | /* Take care of Space / Mark parity */ |
62 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { | 63 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { |
63 | m_dbits = 8; | 64 | m_dbits = 8; |
64 | } | 65 | } |
65 | 66 | ||
66 | /* Data bits */ | 67 | /* Data bits */ |
67 | switch (m_dbits) { | 68 | switch (m_dbits) { |
68 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; | 69 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; |
69 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; | 70 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; |
70 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; | 71 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; |
71 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; | 72 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; |
72 | default: break; | 73 | default: break; |