77// Main Window Constructor
88MainWindow::MainWindow (QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
99{
10- qDebug (" \n App start.\n " );
10+ debug_print (" \n App start.\n " );
1111
12- qDebug (" Setup process start." );
12+ debug_print (" Setup process start." );
1313
14- qDebug (" Initializing App Window..." );
14+ debug_print (" Initializing App Window..." );
1515 ui->setupUi (this );
1616
17- qDebug (" Setting initial UI elements values..." );
17+ debug_print (" Setting initial UI elements values..." );
1818
1919 // ComboBox_EOL initialization
2020 ui->comboBox_EOL ->addItems (comboBox_EOL_values);
@@ -38,7 +38,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
3838 ui->textBrowser_serial_1 ->hide ();
3939 ui->lineEdit_toSend ->setFocus ();
4040
41- qDebug (" Connecting events signals..." );
41+ debug_print (" Connecting events signals..." );
4242
4343 // UI elements user interactions signals event setup
4444 connect (ui->pushButton_open , SIGNAL (released ()), this , SLOT (ButtonOpenPressed ()));
@@ -96,7 +96,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
9696 this , [=](){SerialPortErrorHandler ();});
9797
9898 // Setup and start timer for Serial Ports checks
99- qDebug (" Initializing Serial Ports check timer..." );
99+ debug_print (" Initializing Serial Ports check timer..." );
100100 SerialPortsChecks_timer_init ();
101101
102102 // Add an event filter to catch keyboard signals with an eventFilter() handler
@@ -105,7 +105,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
105105 // Inicial send history index to -1
106106 send_history_i = -1 ;
107107
108- qDebug (" Setup process end.\n " );
108+ debug_print (" Setup process end.\n " );
109109}
110110
111111// Main Window Destructor
@@ -126,7 +126,7 @@ MainWindow::~MainWindow()
126126 if ((serial_port->isWritable ()) || (serial_port->isReadable ()))
127127 {
128128 serial_port->close ();
129- qDebug (" Port successfully close." );
129+ debug_print (" Port successfully close." );
130130 }
131131
132132 delete serial_port;
@@ -136,7 +136,7 @@ MainWindow::~MainWindow()
136136 // Release UI
137137 delete ui;
138138
139- qDebug (" \n App end." );
139+ debug_print (" \n App end." );
140140}
141141
142142/* *************************************************************************************************/
@@ -194,14 +194,14 @@ void MainWindow::SerialPortsCheck(void)
194194// Button Open pressed event handler
195195void MainWindow::ButtonOpenPressed (void )
196196{
197- qDebug (" Open Button pressed." );
197+ debug_print (" Open Button pressed." );
198198 OpenPort ();
199199}
200200
201201// Button Close pressed event handler
202202void MainWindow::ButtonClosePressed (void )
203203{
204- qDebug (" Close Button pressed." );
204+ debug_print (" Close Button pressed." );
205205 ClosePort ();
206206}
207207
@@ -211,20 +211,20 @@ void MainWindow::OpenPort(void)
211211 QString selected_port = ui->comboBox_SerialPort ->currentText ();
212212 if ((selected_port.isNull ()) || (selected_port.isEmpty ()))
213213 {
214- qDebug (" Port is null or empty" );
214+ debug_print (" Port is null or empty" );
215215 return ;
216216 }
217217
218218 QString selected_bauds = ui->comboBox_bauds ->currentText ();
219219 if ((selected_bauds.isNull ()) || (selected_bauds.isEmpty ()))
220220 {
221- qDebug (" Bauds is null or empty" );
221+ debug_print (" Bauds is null or empty" );
222222 return ;
223223 }
224224
225225 QByteArray qba_port = selected_port.toUtf8 ();
226226 QByteArray qba_selected_bauds = selected_bauds.toUtf8 ();
227- qDebug (" Trying to open port %s at %s bauds." , qba_port.data (), qba_selected_bauds.data ());
227+ debug_print (" Trying to open port %s at %s bauds." , qba_port.data (), qba_selected_bauds.data ());
228228 serial_port->setPortName (selected_port);
229229 if (serial_port->open (QIODevice::ReadWrite))
230230 {
@@ -249,7 +249,7 @@ void MainWindow::OpenPort(void)
249249
250250 ui->lineEdit_toSend ->setFocus ();
251251
252- qDebug (" Port successfully open." );
252+ debug_print (" Port successfully open." );
253253 }
254254}
255255
@@ -260,7 +260,7 @@ void MainWindow::ClosePort(void)
260260 if ((serial_port->isWritable ()) || (serial_port->isReadable ()))
261261 {
262262 serial_port->close ();
263- qDebug (" Port successfully close." );
263+ debug_print (" Port successfully close." );
264264
265265 ui->label_status ->setStyleSheet (" QLabel { color : black; }" );
266266 ui->label_status ->setText (" Status: Disconnected." );
@@ -281,12 +281,12 @@ void MainWindow::ClosePort(void)
281281// ComboBox Bauds change event handler
282282void MainWindow::CBoxBaudsChanged (void )
283283{
284- qDebug (" Bauds changed." );
284+ debug_print (" Bauds changed." );
285285
286286 // Close the port if it is already open
287287 if ((serial_port->isWritable ()) || (serial_port->isReadable ()))
288288 {
289- qDebug (" Reconnecting to port using new baudrate." );
289+ debug_print (" Reconnecting to port using new baudrate." );
290290 ClosePort ();
291291 OpenPort ();
292292 }
@@ -295,7 +295,7 @@ void MainWindow::CBoxBaudsChanged(void)
295295// ComboBox EOL change event handler
296296void MainWindow::CBoxEOLChanged (void )
297297{
298- qDebug (" Send EOL changed." );
298+ debug_print (" Send EOL changed." );
299299
300300 ui->lineEdit_toSend ->setFocus ();
301301}
@@ -307,7 +307,7 @@ void MainWindow::CBoxEOLChanged(void)
307307// Button clear event handler
308308void MainWindow::ButtonClearPressed (void )
309309{
310- qDebug (" Clear Button pressed." );
310+ debug_print (" Clear Button pressed." );
311311 ui->textBrowser_serial_0 ->clear ();
312312 ui->textBrowser_serial_1 ->clear ();
313313 ui->lineEdit_toSend ->setFocus ();
@@ -350,7 +350,7 @@ void MainWindow::PrintReceivedData(QTextBrowser* textBrowser0, QTextBrowser *tex
350350 // Get the received data and split it by lines
351351 QByteArray serial_data = serial_port->readAll ();
352352 QList<QByteArray> lines = serial_data.split (' \n ' );
353- // qDebug ("Received data: %s", serial_data.toHex().data());
353+ // debug_print ("Received data: %s", serial_data.toHex().data());
354354
355355 // Get data last character
356356 char data_last_char = serial_data[serial_data.size ()-1 ];
@@ -677,7 +677,7 @@ QString MainWindow::GetActualSystemTime(void)
677677// Button Send pressed event handler
678678void MainWindow::ButtonSendPressed (void )
679679{
680- qDebug (" Send Button pressed." );
680+ debug_print (" Send Button pressed." );
681681 SerialSend ();
682682 ui->lineEdit_toSend ->clear ();
683683 ui->lineEdit_toSend ->setFocus ();
@@ -690,7 +690,7 @@ void MainWindow::SerialSend(void)
690690 QString qstr_to_send = ui->lineEdit_toSend ->text ();
691691 if ((qstr_to_send.isNull ()) || (qstr_to_send.isEmpty ()))
692692 {
693- qDebug (" Data to send box is null or empty" );
693+ debug_print (" Data to send box is null or empty" );
694694 return ;
695695 }
696696
@@ -772,7 +772,7 @@ void MainWindow::SerialPortErrorHandler(void)
772772 if (serial_port->error () != QSerialPort::NoError)
773773 {
774774 QByteArray qba_error = serial_port->errorString ().toUtf8 ();
775- qDebug (" Error - %s\n " , qba_error.data ());
775+ debug_print (" Error - %s\n " , qba_error.data ());
776776
777777 ui->label_status ->setStyleSheet (" QLabel { color : red; }" );
778778 ui->label_status ->setText (" Status: " + serial_port->errorString ());
0 commit comments