0

hi i want to receive data from FPGA by Ethernet with qt. i can write data to fpga but unfortunately i cant receive data. after writing x"c000" to fpga it should send data but my code doesn't woked. i write this code for receive data but i cant please help me.

         QByteArray ba2;
         ba2.resize(2);
         ba2[0] = 0x00;
         ba2[1] = 0xc0;
         Client ob;
         ob.connectToHost();
         ob.writeData(ba2);



    QByteArray Client:: readback(QByteArray data)
   {
        qDebug() << socket->readAll();

         return data;
   }

void Client::connectToHost()
{
socket->connectToHost("192.168.100.17", 1134);

 }


 void Client::close()
 {
socket->close();

  }

 Client::Client(QObject *parent) : QObject(parent)
  {
socket = new QTcpSocket();
connect(socket, SIGNAL(readyRead()), this, SLOT(readback(QByteArray data)));

      }
mehdi
  • 11
  • 1

1 Answers1

0

Try it asynch:

auto t = make_unique<QTcpSocket>();
QObject::connect(t.data(),&QTcpSocket::connected,[&t](){
QDataStream writer(t.data());
writer << static_cast<quint16>(0xc000);
});
QObject::connect(t.data(),&QTcpSocket::readyRead,[&t](){
qDebug() << t->readAll();
});
IlBeldus
  • 1,040
  • 6
  • 14