1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
int main(int argc, char *argv[])
{
int a, rest = 1;
char b[] = "ZynqMP";
cout << "A quelle étape voulez vous vous rendre ? 0 pour toutes les faire.\n";
cin >> a;
QCoreApplication app(argc, argv);
QSerialPort serial("/dev/ttyUSB0");
serial.setBaudRate(115200);
serial.setDataBits(QSerialPort::DataBits::Data8);
serial.setParity(QSerialPort::Parity::NoParity);
serial.setStopBits(QSerialPort::StopBits::OneStop);
serial.setFlowControl(QSerialPort::FlowControl::NoFlowControl);
if (serial.open(QIODevice::ReadWrite))
{
while (serial.waitForReadyRead() && rest != 0)
{
QByteArray data = serial.readAll();;
rest = qstrcmp(data.data(), b);
qDebug() << data.toStdString().c_str();
serial.write("123\n");
QByteArray readLine;
if (a == 0 || a == 2)
{
serial.write("setenv ipaddr 192.168.0.222\n");
serial.write("setenv serverip 192.168.0.36\n");
serial.write("saveenv\n");
serial.write("tftpboot 0x10000000 boot.scr\n");
serial.write("printenv ipaddr\n");
}
}
else
{
qDebug() << QString("Error %1").arg(serial.errorString());
}
QSerialPortInfo description("/dev/ttyUSB0");
serial.setPortName("ttyUSB0");
return 0;
} |
Partager