Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 352 → Rev 353

/Misc Projects/PcMarlinInterface/MainWindow.cpp
73,9 → 73,8
setWindowTitle("Marlin Controller");
setWindowIcon(QIcon(":/External/Resources/Icon_16.bmp"));
 
statusSerial = new QLabel("Serial Status: Disconnected");
statusSerial->setMinimumWidth(300);
statusBar()->addPermanentWidget(statusSerial);
labelSerialStatus = new QLabel("Serial: Disconnected");
statusBar()->addPermanentWidget(labelSerialStatus);
}
 
MainWindow::~MainWindow()
116,5 → 115,5
 
void MainWindow::UpdateSerialStatus(QString string)
{
statusSerial->setText(string);
labelSerialStatus->setText(string);
}
/Misc Projects/PcMarlinInterface/MainWindow.h
44,11 → 44,11
// Macro controller + UI
MacroController *macroController;
QDockWidget *macroDockWidget;
 
QGroupBox *groupMacro;
QPushButton *btnMacro;
 
QLabel *statusSerial;
// Status bar
QLabel *labelSerialStatus;
 
};
 
/Misc Projects/PcMarlinInterface/PcMarlinInterface.pro.user
1,6 → 1,6
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.3.0, 2015-01-07T23:41:29. -->
<!-- Written by QtCreator 3.3.0, 2015-01-08T06:54:51. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
/Misc Projects/PcMarlinInterface/SerialController.cpp
49,34 → 49,27
 
connect(serialHelper, SIGNAL(UpdateStatus(QString)), this, SIGNAL(UpdateStatus(QString)));
 
// Parameters
connect(this, SIGNAL(Serial_QueryParameters()), serialHelper, SLOT(Serial_QueryParameters()));
connect(serialHelper, SIGNAL(Serial_UpdateParameters(QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)),
this, SLOT(Serial_UpdateParameters(QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)));
 
// Connect
connect(this, SIGNAL(Serial_Connect(QString,QString,QString,QString,QString,QString)),
serialHelper, SLOT(Serial_Connect(QString,QString,QString,QString,QString,QString)));
connect(serialHelper, SIGNAL(Serial_Connected()), this, SIGNAL(Serial_Connected()));
connect(serialHelper, SIGNAL(Serial_Connected()), this, SLOT(Serial_LocalConnected()));
 
// Disconnect
connect(this, SIGNAL(Serial_Disconnect()), serialHelper, SLOT(Serial_Disconnect()));
connect(serialHelper, SIGNAL(Serial_Disconnected()), this, SIGNAL(Serial_Disconnected()));
connect(serialHelper, SIGNAL(Serial_Disconnected()), this, SLOT(Serial_LocalDisconnected()));
 
// Transmit
connect(this, SIGNAL(Serial_TransmitString(QString)), serialHelper, SLOT(Serial_TransmitString(QString)));
connect(this, SIGNAL(Serial_TransmitByteArray(QByteArray)), serialHelper, SLOT(Serial_TransmitByteArray(QByteArray)));
 
// Receive
connect(serialHelper, SIGNAL(Serial_ReceivedByte(char)), this, SIGNAL(Serial_ReceivedByte(char)));
 
// Threading
connect(serialThread, SIGNAL(finished()), serialHelper, SLOT(deleteLater()));
serialThread->start();
 
// Local GUI
connect(btnSerialConnect, SIGNAL(clicked()), this, SLOT(Serial_ConnectToggleBtn()));
connect(btnSerialRefresh, SIGNAL(clicked()), this, SIGNAL(Serial_QueryParameters()));
 
147,7 → 140,6
cboxSerialStopBits->hide();
cboxSerialParity->hide();
cboxSerialFlowControl->hide();
emit UpdateStatus("Serial: Connected");
}
 
void SerialController::Serial_LocalDisconnected()
173,7 → 165,6
cboxSerialStopBits->show();
cboxSerialParity->show();
cboxSerialFlowControl->show();
emit UpdateStatus("Serial: Disconnected");
}
 
void SerialController::Serial_ConnectToggleBtn()
/Misc Projects/PcMarlinInterface/SerialHelper.cpp
30,6 → 30,7
QString stopBits, QString parity, QString flowControl)
{
if (!connected) {
emit UpdateStatus("Serial: Connecting to " + port);
serialPort = new QSerialPort();
connect(serialPort, SIGNAL(readyRead()), this, SLOT(Serial_ProcessIncomingData()));
connect(serialPort, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(Serial_ProcessError(QSerialPort::SerialPortError)));
78,18 → 79,24
// See http://umforum.ultimaker.com/index.php?/topic/5886-um2-controller-resetreboot-when-opening-usb-port-on-linux/
serialPort->setDataTerminalReady(1);
 
if (ok) emit Serial_Connected();
else Serial_Disconnect();
if (ok) {
QString status = "Serial: Connected (%1 @ %2 D: %3 S: %4 P: %5 FC: %6)";
emit UpdateStatus(status.arg(port).arg(speed).arg(dataBits).arg(stopBits).arg(parity).arg(flowControl));
emit Serial_Connected();
} else
Serial_Disconnect();
}
}
}
 
void SerialHelper::Serial_Disconnect()
void SerialHelper::Serial_Disconnect(bool errored)
{
serialPort->disconnect();
serialPort->close();
delete serialPort;
connected = false;
if (!errored)
emit UpdateStatus("Serial: Disconnected");
emit Serial_Disconnected();
}
 
123,43 → 130,43
 
switch(error) {
case QSerialPort::DeviceNotFoundError:
emit UpdateStatus("Serial Error: Nonexistant device");
emit UpdateStatus("Serial: (Error) Device not found");
return;
case QSerialPort::PermissionError:
emit UpdateStatus("Serial Error: Device already opened or lacking permission");
emit UpdateStatus("Serial: (Error) Device already opened or lacking permission");
return;
case QSerialPort::OpenError:
emit UpdateStatus("Serial Error: Device already opened");
emit UpdateStatus("Serial: (Error) Device already opened");
return;
case QSerialPort::NotOpenError:
emit UpdateStatus("Serial Error: Device not opened");
emit UpdateStatus("Serial: (Error) Device not opened");
return;
case QSerialPort::ParityError:
emit UpdateStatus("Serial Error: Parity error detected");
emit UpdateStatus("Serial: (Error) Parity error detected");
break;
case QSerialPort::FramingError:
emit UpdateStatus("Serial Error: Framing error detected");
emit UpdateStatus("Serial: (Error) Framing error detected");
break;
case QSerialPort::BreakConditionError:
emit UpdateStatus("Serial Error: Break condition detected");
emit UpdateStatus("Serial: (Error) Break condition detected");
break;
case QSerialPort::WriteError:
emit UpdateStatus("Serial Error: Unable to write to device");
emit UpdateStatus("Serial: (Error) Unable to write to device");
break;
case QSerialPort::ReadError:
emit UpdateStatus("Serial Error: Unable to read from device");
emit UpdateStatus("Serial: (Error) Unable to read from device");
break;
case QSerialPort::ResourceError:
emit UpdateStatus("Serial Error: Device missing or disconnected");
emit UpdateStatus("Serial: (Error) Device missing or disconnected");
break;
case QSerialPort::UnsupportedOperationError:
emit UpdateStatus("Serial Error: Operation not supported or prohibited");
emit UpdateStatus("Serial: (Error) Operation not supported or prohibited");
break;
case QSerialPort::TimeoutError:
emit UpdateStatus("Serial Error: Timeout occurred");
emit UpdateStatus("Serial: (Error) Connection timeout");
break;
case QSerialPort::UnknownError:
emit UpdateStatus("Serial Error: Unknown error");
emit UpdateStatus("Serial: (Error) Unknown error");
break;
default:
break;
166,5 → 173,5
}
 
serialPort->clearError();
Serial_Disconnect();
Serial_Disconnect(true);
}
/Misc Projects/PcMarlinInterface/SerialHelper.h
21,7 → 21,7
void Serial_QueryParameters(void);
void Serial_Connect(QString port, QString speed, QString dataBits,
QString stopBits, QString parity, QString flowControl);
void Serial_Disconnect(void);
void Serial_Disconnect(bool errored = false);
void Serial_TransmitString(QString string);
void Serial_TransmitByteArray(QByteArray buffer);