Results 1 to 2 of 2

Thread: How to use Write function of Qextserialport to send structure..??

  1. #1
    Join Date
    Mar 2011
    Posts
    15
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default How to use Write function of Qextserialport to send structure..??

    Hii,

    am facing problem in sending msg packet to another device using write function of Qextserialport.

    Now my question is, can I send structure (struct msg_packet) through write function of qextserialport?? If yes how?

    I have framed msg packet like this:

    struct Packet{

    unsigned short Msghdr = 0x0022;
    unsigned short Data1 = 0x0055;
    unsigned short Data2 = 0x0034;
    unsigned short Data3 = 0x0023;
    unsigned short Data4 = 0x0a55;
    };

    how to sent this using Write function??? Or I have to make use of QByteArray or QString???


    Help me......
    Last edited by pupqt; 13th April 2011 at 11:13.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to use Write function of Qextserialport to send structure..??

    Now my question is, can I send structure (struct msg_packet) through write function of qextserialport?? If yes how?
    Yes.
    By serializing it in to a QByteArray, and giving that QByteArray as parameter to the write() method.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QSettings write and read function
    By ivareske in forum Qt Programming
    Replies: 3
    Last Post: 24th February 2011, 15:14
  2. Replies: 2
    Last Post: 2nd November 2010, 05:15
  3. Q_PROPERTY WRITE function, also a slot?
    By Eos Pengwern in forum Newbie
    Replies: 2
    Last Post: 12th December 2009, 21:29
  4. Replies: 5
    Last Post: 27th November 2009, 14:37
  5. how to write a template function in a form..
    By nass in forum General Programming
    Replies: 7
    Last Post: 18th December 2006, 19:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.