SerialPort.cpp   SerialPort.cpp 
skipping to change at line 28 skipping to change at line 28
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this library; if not, write to the Free Software along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, US A. Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, US A.
*/ */
#include "SerialPort.hpp" #include "SerialPort.hpp"
#include "LogFile.hpp" #include "LogFile.hpp"
#ifndef Q_OS_WIN32 #ifndef Q_OS_WIN
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <string.h> // memset #include <string.h> // memset
using namespace std; using namespace std;
SerialPort::SerialPort(Server &server, const char *serial_device) SerialPort::SerialPort(Server &server, const char *serial_device)
: Connection(server, INVALID_SOCKET) : Connection(server, INVALID_SOCKET)
#ifndef Q_OS_WIN32 #ifndef Q_OS_WIN
, termios_original(termios()) , termios_original(termios())
#endif #endif
{ {
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN
handle = CreateFile(serial_device, GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); handle = CreateFile(serial_device, GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
if (handle == INVALID_HANDLE_VALUE) if (handle == INVALID_HANDLE_VALUE)
{ {
*log_file << Now() << "SerialPort::SerialPort(" << serial_de vice << "): " *log_file << Now() << "SerialPort::SerialPort(" << serial_de vice << "): "
"CreateFile() failed: " << GetLastErro r() << endl; "CreateFile() failed: " << GetLastErro r() << endl;
} }
else else
{ {
COMMTIMEOUTS timeouts; COMMTIMEOUTS timeouts;
timeouts.ReadIntervalTimeout = MAXDWORD; timeouts.ReadIntervalTimeout = MAXDWORD;
skipping to change at line 145 skipping to change at line 145
else else
{ {
// success // success
return; return;
} }
} }
} }
close(fd); close(fd);
fd = -1; fd = -1;
} }
#endif //Q_OS_WIN32 #endif //Q_OS_WIN
} }
SerialPort::~SerialPort(void) SerialPort::~SerialPort(void)
{ {
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN
if (handle != INVALID_HANDLE_VALUE) if (handle != INVALID_HANDLE_VALUE)
{ {
// restore original settings // restore original settings
SetCommState(handle, &dcb_original); SetCommState(handle, &dcb_original);
CloseHandle(handle); CloseHandle(handle);
} }
#else #else
if (fd >= 0) if (fd >= 0)
{ {
// restore original settings // restore original settings
tcsetattr(fd, TCSANOW, &termios_original); tcsetattr(fd, TCSANOW, &termios_original);
close(fd); close(fd);
} }
#endif #endif
} }
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN
int SerialPort::readNonblocking(char *buf, int count) int SerialPort::readNonblocking(char *buf, int count)
{ {
DWORD rval; DWORD rval;
if (ReadFile(handle, buf, count, &rval, 0)) if (ReadFile(handle, buf, count, &rval, 0))
return (int)rval; return (int)rval;
if (GetLastError() == ERROR_IO_PENDING) if (GetLastError() == ERROR_IO_PENDING)
return 0; return 0;
return -1; return -1;
} }
skipping to change at line 195 skipping to change at line 195
return 0; return 0;
return -1; return -1;
} }
#endif #endif
void SerialPort::prepareSelectFds(fd_set &read_fds, void SerialPort::prepareSelectFds(fd_set &read_fds,
fd_set &write_fds, fd_set &write_fds,
int &fd_max) int &fd_max)
{ {
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN
// handle all IO here // handle all IO here
if (write_buff_end > write_buff) if (write_buff_end > write_buff)
performWriting(); performWriting();
performReading(); performReading();
#else #else
Connection::prepareSelectFds(read_fds, write_fds, fd_max); Connection::prepareSelectFds(read_fds, write_fds, fd_max);
#endif //Q_OS_WIN32 #endif //Q_OS_WIN
} }
 End of changes. 8 change blocks. 
8 lines changed or deleted 8 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/