-1

i want make samsung flasher simillar to odin flasher for flash rom (package of system data) with qt widget.

i need c++ command on port for flashing data to device and how to connect program to device for this operation.

2 Answers2

0

You can use library at qtserial library. Here is the sample snippet to get uart working.

QextSerialPort port;
port.setPortName("portName");
port.setBaudRate(BAUD115200);
port.setFlowControl(FLOW_OFF);
port.setParity(PAR_NONE);
port.setDataBits(DATA_8);
port.setStopBits(STOP_1);
port.open(QIODevice::ReadWrite);

For reading data from UART.

char ch;
port.getChar(&ch))
yadhu
  • 1,253
  • 14
  • 25
  • I hope answer will be useful to you. – yadhu Jul 25 '18 at 16:10
  • thnx for answer. important problem is how send samsung system data to device with this library function. for example i want flash boot.img on samsung device, how can do this operation with this library? – jocker fantom Jul 25 '18 at 16:12
0

Here you have an almost complete code, to connect and send data, with a serial connection:

.h file:

private slots:

    void connectSerial();
    void sendData();
    void closeSerial();
...

.cpp file:

#include <QSerialPort>
#include <QSerialPortInfo>

static QSerialPort * serialPort;
...

Connect to Serial:

void MainWindow::connectSerial()
{
    serialPort = new QSerialPort;
    serialPort->setPortName("com1");
    serialPort->open(QIODevice::ReadWrite);
    serialPort->setBaudRate(QSerialPort::Baud9600);
    serialPort->setDataBits(QSerialPort::Data8);
    serialPort->setParity(QSerialPort::NoParity);
    serialPort->setStopBits(QSerialPort::OneStop);
    serialPort->setFlowControl(QSerialPort::NoFlowControl);
    QObject::connect(serialPort, SIGNAL(readyRead()), this, SLOT(readSerial()));
}
...

Read data send from the device:

void MainWindow::readSerial()
{
    ....
}

Send QString data (12345), to Serial:

void MainWindow::sendData()
{
    QByteArray payload_buffer;
    QString Data = "12345";
    payload_buffer = payload_buffer.append(Data.toLatin1());
    if(serialPort->isWritable()){
        serialPort->write(payload_buffer,(payload_buffer.size()));
    }
}
...

Remember to close the connecting!:

void MainWindow::closeSerial()
{
    serialPort->close();
}
...

Tomse
  • 179
  • 5