Hi,
First of all, I'm not quite experienced about C++/Qt. There is a thread about getting const char* from QLineEdit but it doesn't fit my project exactly. Anyway, if I wrote something that doesn't make sense. Please, forgive me.
I'm working on a serial port application using QextSerialPort. I have a device and I want it to be controlled by serial port Qt Gui Application in Win7. In my Gui, there is a setting dialog called "parameter settings" and in this parameter settings there are some QLineEdits and couple pushbuttons to read/write actions. I should send data to the device as ascii character array.
Here is my setting dialog screenshot:
parameters.png
Before I got started my project, I sent some commands from a sample gui which is working on only WinXP and probed the serial lines.
According to this values ( SC=0, P=9.5, I=88, D=58, A1=560, A2=30, A2S=5, A3=10), when I clicked the write button, observed data with specific time interval as shown below.
SC -> 010610040000E5
P -> 01061006005F84
I -> 01061008005889
D -> 0106100A003AA5
A1 -> 0106100C0230AB
A2&A2S -> 0106100E1E05B8
A3 -> 01061010000ACF
As you can see from bold characters, hexadecimal representation of decimal parameters are placed in array. Last two char of the array increment 1, when the parameters decrement 1 and vice versa.
Here is my sample code that sends the const char array to the device.
const char test_param_data[] = "010310040008E0";
if (!port->isOpen()) {
port->write(test_param_data, sizeof(test_param_data));
ui->lineEdit_9->setText("Test OK");
}
else
{
port->write(test_param_data, sizeof(test_param_data));
ui->lineEdit_9->setText("Test Done");
}
const char test_param_data[] = "010310040008E0";
if (!port->isOpen()) {
port->open(QIODevice::ReadWrite);
port->write(test_param_data, sizeof(test_param_data));
ui->lineEdit_9->setText("Test OK");
}
else
{
port->write(test_param_data, sizeof(test_param_data));
ui->lineEdit_9->setText("Test Done");
}
To copy to clipboard, switch view to plain text mode
I hope I make myself clear about my problem. Briefly, how can I get these parameters as in specific order and converted to const char?
Thanks in advance.
Anil.
Bookmarks