moc_qserialport.cpp:195: ошибка: definition of static data member 'QSerialPort::staticMetaObjectExtraData' of dllimport'd class
moc_qserialport.cpp:195: ошибка: definition of static data member 'QSerialPort::staticMetaObjectExtraData' of dllimport'd class
moc_qserialport.cpp:195: ошибка: definition of static data member 'QSerialPort::staticMetaObjectExtraData' of dllimport'd class
// qserialport_win.cpp
// line 235
if (descriptor == INVALID_HANDLE_VALUE) {
q_ptr->setError(decodeSystemError()); // сюда выбивает
return false;
}
::SetupComm(descriptor, 1024, 1024);
::PurgeComm(descriptor, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR);
// +
currentCommTimeouts.ReadTotalTimeoutConstant = 0;
currentCommTimeouts.ReadTotalTimeoutMultiplier = 0;
currentCommTimeouts.WriteTotalTimeoutMultiplier = 0;
currentCommTimeouts.WriteTotalTimeoutConstant = 0;
QWinEventNotifier *n = new CommOverlappedEventNotifier(this, originalEventMask, q_ptr);
function TfrmMain.OpenCOMDevice( port:string ) : boolean;
var
ii: Integer;
IsAvail:boolean;
begin
if IsCOMConnected then
CloseCOMDevice;
LOG_INFO('OpenCOMDevice()', 'Подключение к порту: ' + PChar('\\.\\' + port));
Result := False;
try
hComm:=CreateFile(PChar('\\.\\' + port),//cbDevPorts.Items[cbDevPorts.ItemIndex]),
GENERIC_READ or GENERIC_WRITE,
0,
Nil,
OPEN_EXISTING,
0,
0);
if hComm = INVALID_HANDLE_VALUE then
begin
LOG_ERR('OpenCOMDevice()', 'hComm = INVALID_HANDLE_VALUE ('+SysErrorMessage(GetLastError)+')');
Exit;
end;
ResBool := SetupComm(hComm, 1024, 1024);
if ResBool = false then
begin
LOG_WARN('OpenCOMDevice()', 'SetupComm(hComm, 2048, 2048) = false');
end;
if not PurgeComm(hComm, PURGE_TXABORT or PURGE_RXABORT or PURGE_TXCLEAR or PURGE_RXCLEAR) then
begin
LOG_WARN('OpenCOMDevice()', 'PurgeComm(hComm, PURGE_TXABORT or PURGE_RXABORT or PURGE_TXCLEAR or PURGE_RXCLEAR) = false');
end;
CommTimeouts.ReadIntervalTimeout:=MAXDWORD;
CommTimeouts.ReadTotalTimeoutMultiplier:=0;
CommTimeouts.ReadTotalTimeoutConstant:=0;
CommTimeouts.WriteTotalTimeoutMultiplier:=0;
CommTimeouts.WriteTotalTimeoutConstant:=0;
ResBool := SetCommTimeouts(hComm,CommTimeouts);
if ResBool = false then
begin
LOG_ERR('OpenCOMDevice()', 'SetCommTimeouts(hComm,CommTimeouts) = false');
raise Exception.Create('[SetCommTimeouts(..)] Ошибка при утановке таймингов порта!');
end;
OnDeviceConnect;
Result := True;
except
SysErrorMessage(GetLastError);
CloseHandle(hComm);
hComm := INVALID_HANDLE_VALUE;
Result:=False;
end;
end;
CONFIG += serialport
LIBS += -lqtserialport
CMainWindow::CMainWindow(QWidget *parent) :
QDialog(parent,Qt::Window),
ui(new Ui::CMainWindow)
{
ui->setupUi(this);
...
...
m_sp=new QSerialPort("//./com5",0);
m_sp->setBaudRate(QSerialPort::Baud115200);
m_sp->setDataBits(QSerialPort::Data8);
m_sp->setParity(QSerialPort::NoParity);
m_sp->setStopBits(QSerialPort::OneStop);
// m_sp->setFlowControl(QSerialPort::NoFlowControl);
if(m_sp->open(m_sp->ReadWrite))
{
QSerialPort::SerialPortError e=m_sp->error();
qDebug()<<"port opened";
qDebug()<<"error="<<e;
}
connect(m_sp,SIGNAL(readyRead()),this,SLOT(readyRead()));
}
void CMainWindow::readyRead()
{
//сюда не попадаем вообще
QByteArray d=m_sp->readAll();
qDebug()<<d;
}
m_sp=new QSerialPort("//./com5",0);
m_sp=new QSerialPort("\\\\.\\COM5",0);
m_sp=new QSerialPort("//./com5",0);
m_sp=new QSerialPort("\\\\.\\COM5",0);