Results 1 to 2 of 2

Thread: QextSerialPort - Segmentation Fault

  1. #1
    Join Date
    Jun 2006
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QextSerialPort - Segmentation Fault

    G'Day,

    I have simple program to write to and read from a serial port. The port is opened as "serialPort->open( QIODevice::ReadWrite);" and I am able to send data. (viewed on another PC and serial breakout box).

    My problem is trying to read the serial port for any data that comes in. I am using a timer to regularly check the port but the I get a seg fault when checking the "bytesAvailable" (see code). As soon as the code hits that line it seg faults.

    Any thoughts would be greatly appreciated.

    Qt Code:
    1. void Mainscreen::checkPort()
    2. {
    3. qWarning( "checking port..." );
    4. if (serialPort->bytesAvailable() > 0 );
    5. {
    6. qWarning( "emitting signal..." );
    7. emit( dataready() );
    8. }
    9. qWarning( "checked port..." );
    10. }
    To copy to clipboard, switch view to plain text mode 

    Thanks, B1.


    Edit:
    I ran it through Vlagrind and I get an "Use of uninitialised value of size 4" at the same line.
    Last edited by b1; 26th November 2006 at 03:45.

  2. #2
    Join Date
    Jun 2006
    Posts
    64
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QextSerialPort - Segmentation Fault

    Problem Solved!

    I had "QextSerialPort *serialPort;" in the header file and then "QextSerialPort *serialPort = new QextSerialPort( portname1 );" in the source file.

    I changed the latter to "serialPort = new QextSerialPort( portname1 );" and it now no longer seg faults.

    Now to fix the rest of the code...

    B1.

Similar Threads

  1. Strange segmentation fault
    By Lykurg in forum Qt Programming
    Replies: 3
    Last Post: 4th January 2009, 19:50
  2. Segmentation fault in QListViewItem
    By ederbs in forum Qt Programming
    Replies: 2
    Last Post: 26th November 2006, 01:19
  3. (Another) segmentation fault
    By Lebowski in forum Qt Programming
    Replies: 27
    Last Post: 6th April 2006, 06:33
  4. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 16:30
  5. [qmake_image_collection.cpp] Segmentation fault
    By CrazyLegz in forum KDE Forum
    Replies: 1
    Last Post: 4th February 2006, 11:43

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.