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:

Qt Code:
  1. { //.h
  2. #include <Serial/abstractserial.h>
  3. AbstractSerial *port1;
  4. }
  5.  
  6. {
  7. port1 = new AbstractSerial();
  8. }
  9.  
  10. bool command::Write(QByteArray com)
  11. {
  12. if(!port1->isOpen())
  13. {
  14. emit sendSBMessage("Port closed");
  15. return false;
  16. }
  17. else
  18. {
  19. port1->write(com + "\r\0");
  20. return true;
  21. }
  22. }
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