BIG deep clean
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
COM
|
||||
PIP - Platform Independent Primitives
|
||||
COM
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "piincludes_p.h"
|
||||
#include "piserial.h"
|
||||
#include "piconfig.h"
|
||||
@@ -627,16 +628,6 @@ void PISerial::applySettings() {
|
||||
PRIVATE->desc.Parity = params[PISerial::ParityOdd] ? 1 : 2;
|
||||
}
|
||||
PRIVATE->desc.StopBits = params[PISerial::TwoStopBits] ? TWOSTOPBITS : ONESTOPBIT;
|
||||
|
||||
/*PRIVATE->desc.fOutxCtsFlow = 0;
|
||||
PRIVATE->desc.fOutxDsrFlow = 0;
|
||||
PRIVATE->desc.fDtrControl = 0;
|
||||
PRIVATE->desc.fRtsControl = 0;
|
||||
PRIVATE->desc.fInX = 0;
|
||||
PRIVATE->desc.fOutX = 0;
|
||||
PRIVATE->desc.fBinary = 1;
|
||||
PRIVATE->desc.fAbortOnError = 0;
|
||||
PRIVATE->desc.fNull = 0;*/
|
||||
if (SetCommState(PRIVATE->hCom, &PRIVATE->desc) == -1) {
|
||||
piCoutObj << "Unable to set comm state for \"" << path() << "\"";
|
||||
return;
|
||||
@@ -704,7 +695,6 @@ int PISerial::readDevice(void * read_to, int max_size) {
|
||||
if (!canRead()) return -1;
|
||||
if (sending) return -1;
|
||||
// piCoutObj << "com event ...";
|
||||
//WaitCommEvent(PRIVATE->hCom, 0, 0);
|
||||
//piCoutObj << "read ..." << PRIVATE->hCom;
|
||||
ReadFile(PRIVATE->hCom, read_to, max_size, &PRIVATE->readed, 0);
|
||||
DWORD err = GetLastError();
|
||||
@@ -729,12 +719,6 @@ int PISerial::writeDevice(const void * data, int max_size) {
|
||||
return -1;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
// if (block_write != wait) {
|
||||
// block_write = wait;
|
||||
// piCoutObj << "set timeout ...";
|
||||
// setReadIsBlocking(block_read);
|
||||
// piCoutObj << "set timeout ok";
|
||||
// }
|
||||
DWORD wrote;
|
||||
// piCoutObj << "send ...";// << max_size;// << ": " << PIString((char*)data, max_size);
|
||||
sending = true;
|
||||
@@ -943,24 +927,6 @@ PIVector<PISerial::DeviceInfo> PISerial::availableDevicesInfo(bool test) {
|
||||
PIVector<DeviceInfo> ret;
|
||||
DeviceInfo di;
|
||||
#ifdef WINDOWS
|
||||
/*HKEY key = 0;
|
||||
RegOpenKey(HKEY_LOCAL_MACHINE, (LPCTSTR)"HARDWARE\\DEVICEMAP\\SERIALCOMM", &key);
|
||||
if (key != 0) {
|
||||
char name[1024], data[1024];
|
||||
DWORD index = 0;
|
||||
LONG res = ERROR_SUCCESS;
|
||||
while (res != ERROR_NO_MORE_ITEMS) {
|
||||
memset(name, 0, 1024);
|
||||
memset(data, 0, 1024);
|
||||
DWORD name_len = 1024, data_len = 1024, type = 0;
|
||||
res = RegEnumValue(key, index, (LPTSTR)name, &name_len, NULL, &type, (uchar * )data, &data_len);
|
||||
if (res == ERROR_NO_MORE_ITEMS) break;
|
||||
di.path = PIString(data, data_len).trim();
|
||||
ret << di;
|
||||
index++;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}*/
|
||||
static const GUID guids[] = {GUID_DEVINTERFACE_MODEM, GUID_DEVINTERFACE_COMPORT};
|
||||
static const int guids_cnt = sizeof(guids) / sizeof(GUID);
|
||||
for (int i = 0; i < guids_cnt; ++i) {
|
||||
@@ -1076,17 +1042,7 @@ PIVector<PISerial::DeviceInfo> PISerial::availableDevicesInfo(bool test) {
|
||||
continue;
|
||||
}
|
||||
bool rok = true;
|
||||
#ifdef WINDOWS
|
||||
/*COMMTIMEOUTS times;
|
||||
times.ReadIntervalTimeout = MAXDWORD;
|
||||
times.ReadTotalTimeoutConstant = 0;
|
||||
times.ReadTotalTimeoutMultiplier = 0;
|
||||
times.WriteTotalTimeoutConstant = 1;
|
||||
times.WriteTotalTimeoutMultiplier = 0;
|
||||
SetCommTimeouts(hComm, ×);
|
||||
if (ReadFile(hComm, &void_, 1, &readed_, 0) == 0)
|
||||
rok = GetLastError() == ;*/
|
||||
#else
|
||||
#ifndef WINDOWS
|
||||
int void_ = 0;
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
if (::read(fd, &void_, 1) == -1)
|
||||
@@ -1122,7 +1078,6 @@ void PISerial::threadedReadBufferSizeChanged() {
|
||||
//piCoutObj << "b" << ss.xmit_fifo_size;
|
||||
ss.xmit_fifo_size = piMaxi(threadedReadBufferSize(), 4096);
|
||||
ioctl(fd, TIOCSSERIAL, &ss);
|
||||
//ioctl(fd, TIOCGSERIAL, &ss);
|
||||
//piCoutObj << "a" << ss.xmit_fifo_size;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user