Results 1 to 20 of 47

Thread: serial port programming in qt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: serial port programming in qt

    high_flyer:

    Oops. it still not working. This is my code:

    ConnectWidget::ConnectWidget( QWidget *parent, const char *name )
    : QWidget( parent, name),m_note(NULL)
    {
    setBackgroundColor( white );
    setMinimumSize(640,480 );

    m_note= new QextSerialPort("/dev/ttyS0");
    if(m_note)
    {
    m_note->setBaudRate(BAUD115200);
    m_note->setParity(PAR_NONE);
    m_note->setDataBits(DATA_8);
    m_note->setStopBits(STOP_1);
    m_note->open(IO_ReadOnly);
    }
    printf("\n serial port openned \n");
    }

    Is this what you suggested?

  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: serial port programming in qt

    what error? segmentation falut?
    Are there any other methods do the Widget class?
    Try setting debug messages along the code or run in a debugger and see where the applciation crashes.
    And please use code tags.
    ==========================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.

  3. #3
    Join Date
    Dec 2006
    Posts
    123
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: serial port programming in qt

    Sir,

    I modified the code. Now i have onely three lines in my code:

    Qt Code:
    1. class ConnectWidget : public QWidget
    2. {
    3. public:
    4. ConnectWidget( QWidget *parent=0, const char *name=0 );
    5. private:
    6. QextSerialPort *m_note;
    7. };
    8. ConnectWidget::ConnectWidget( QWidget *parent, const char *name )
    9. : QWidget( parent, name),m_note(NULL)
    10. {
    11. setMinimumSize(640,480 );
    12. m_note= new QextSerialPort("/dev/ttyS0");
    13. printf("\n serialport openned \n");
    14. }
    To copy to clipboard, switch view to plain text mode 

    I have not added the settings of the serial port.As i found that starting from this line the error pops up. the following is the error message:

    suse:/home/qtprograms/roughserial # ./roughserial -qws
    Connected to VFB server: 640 x 480 x 32
    Segmentation fault
    suse:/home/qtprograms/roughserial #

Similar Threads

  1. Serial Port communication
    By mgurbuz in forum Qt Programming
    Replies: 12
    Last Post: 22nd January 2011, 02:38
  2. First attempt to display serial port data on GUI
    By ShaChris23 in forum Newbie
    Replies: 12
    Last Post: 4th May 2007, 09:14
  3. Replies: 12
    Last Post: 23rd March 2007, 09:23
  4. Serial Port access in Qt
    By Doug Broadwell in forum Newbie
    Replies: 2
    Last Post: 18th October 2006, 21:03
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Qt is a trademark of The Qt Company.