Hello!
I have to create a software that communicates with a serial port sending, instead of any chars, a structure. A software that sends bytes I already have, so no problem. The problem is that the function that sends data to the serial port uses the qint64 QIODevice::write ( const QByteArray & byteArray ) in a similar way to this:
{ //.h
#include <Serial/abstractserial.h>
AbstractSerial *port1;
}
{
port1 = new AbstractSerial();
}
{
if(!port1->isOpen())
{
emit sendSBMessage("Port closed");
return false;
}
else
{
port1->write(com + "\r\0");
return true;
}
}
{ //.h
#include <Serial/abstractserial.h>
AbstractSerial *port1;
}
{
port1 = new AbstractSerial();
}
bool command::Write(QByteArray com)
{
if(!port1->isOpen())
{
emit sendSBMessage("Port closed");
return false;
}
else
{
port1->write(com + "\r\0");
return true;
}
}
To copy to clipboard, switch view to plain text mode
Now what I have to do is to create a function that instead of sending that QByteArray, it rather sends a structure. But the problem is that the function used by AbstractSerial port1 is the QIODevice::write, and this function is not ready for sending structures as it seems.
So how do I do this? I have no idea.
Thanks,
Momergil
Bookmarks