Results 1 to 7 of 7

Thread: Hints to design threaded serial-reader/writer interface ?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2014
    Posts
    15
    Thanks
    3

    Default Hints to design threaded serial-reader/writer interface ?

    Already created a GUI-program that reads & writes (mostly writes) through serial port with an event loop. I managed more or less that the GUI be responsive but logically the right way is to use threads. So my intention is to move the reading & writing of serial port on a separate thread.

    What I have until now:

    Qt Code:
    1. class SerialIO : public QThread
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. SerialIO(QObject *parent = 0);
    7. ~SerialIO();
    8. void run();
    9. void addData(const QByteArray); //to out_buffer
    10. const QByteArray getData(); //from in_buffer
    11.  
    12. signals:
    13. //not sure...
    14. void readyToSend();
    15. void readyToRecv();
    16.  
    17. public slots:
    18. void send();
    19. void recv();
    20.  
    21. private:
    22. QSerialPort *serial;
    23. QBuffer out_buffer;
    24. QBuffer in_buffer;
    25.  
    26.  
    27. };
    To copy to clipboard, switch view to plain text mode 

    As the main task is to write a file through the serial port, my idea is to inject the file line by line, filling the buffer and the thread class will send it at his own pace. What I receive are ACK's basically.
    Last edited by oldFox64; 24th April 2014 at 08:09.

Similar Threads

  1. Replies: 2
    Last Post: 22nd September 2014, 04:25
  2. Seeking Suggestions for Multi-Threaded Application Design
    By swamyonline in forum Qt Programming
    Replies: 7
    Last Post: 1st May 2014, 16:19
  3. Replies: 12
    Last Post: 19th July 2012, 21:22
  4. Qt GUI interface like Adobe Acrobat Reader
    By indianinside in forum Qt Programming
    Replies: 14
    Last Post: 28th June 2012, 18:32
  5. Problem with design interface
    By tux-world in forum Newbie
    Replies: 5
    Last Post: 10th March 2010, 14:19

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.