Results 1 to 9 of 9

Thread: QextSerialPort strange initialisation problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    23

    Default QextSerialPort strange initialisation problem

    Hi,

    I'm not sure if this is the correct forum, I.e. Im not sure if its specifically related to the QextSerialPort class or not.

    At the moment I am using two USB to Serial adapters connected together to create a connection between COM4 and COM7.

    I have set up my program to use COM4 and a terminal program to use COM7.

    My program only seems to communicate without errors when I first send some data between COM4 and COM7 using just two terminal programs.

    If I don't do this first and I try to send data using my program, for example trying to send "hello" the terminal program simply receives the following: 00 80 80 80 00 00 80 00 80 80 80, in hex.

    Or if I send "goodbye" I receive "80 00 80 80 80 80 00 00 00 00 80 00 80 80 00" in hex,

    But if I set up two terminal programs between COM4 and COM7 and send some characters between them, which are received fine, then I go back to my program and a terminal program on COM7, then everything works fine from then on, until I restart my computer or something.

    Qt Code:
    1. void Loader::send()
    2. {
    3. QextSerialPort * port = new QextSerialPort("COM4", QextSerialPort::EventDriven);
    4. port->setBaudRate(BAUD9600);
    5. port->setFlowControl(FLOW_OFF);
    6. port->setParity(PAR_NONE);
    7. port->setDataBits(DATA_8);
    8. port->setStopBits(STOP_1);
    9. port->open(QIODevice::ReadWrite );//| QIODevice::Unbuffered); //The Unbuffered option did not help.
    10. port->flush(); // I thought this might help but it didn't.
    11. port->write("goodbye");
    12. port->close();
    13. }
    To copy to clipboard, switch view to plain text mode 

    So it seems I need to initialize something, and by creating communication between two terminal programs I am inadvertently doing this initialization... I'm just not sure what exactly this initialization is and how to implement it in my code...

    Hope you can understand what I am trying to say, any help would be really welcome
    Last edited by Ferric; 24th January 2010 at 22:17.

  2. #2
    Join Date
    Jan 2009
    Location
    Russia
    Posts
    309
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2
    Thanked 43 Times in 42 Posts

    Default Re: QextSerialPort strange initialisation problem

    Try an alternative: QSerialDevice
    (see examples of it in the directory /examples)

    Download click here: http://fireforge.net/snapshots.php?group_id=199

    Also on the transfer of symbols see example here:http://www.qtcentre.org/threads/2749...ce-unavailable

    Download example test: http://www.qtcentre.org/attachment.p...5&d=1264337987

  3. #3
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    23

    Default Re: QextSerialPort strange initialisation problem

    Thanks, I might try implementing QSerialDevice tomorrow.

    However I would still like to get to the bottom of the current problem, Its pretty odd and there must be a reason.. any thoughts appreciated..

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 284 Times in 279 Posts

    Default Re: QextSerialPort strange initialisation problem

    Which version of QExtSerial are You using ?

  5. #5
    Join Date
    Jan 2009
    Location
    Midlands UK
    Posts
    62
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 9 Times in 6 Posts

    Default Re: QextSerialPort strange initialisation problem

    Hi,

    Have you tried opening the port before setting the parameters ? - I seem to recall others with the same problem and it was due to the s/w not loading the actual port with the parameters if it was closed, just storing a local copy.

    Regards
    SteveH

  6. The following user says thank you to SteveH for this useful post:

    Ferric (25th January 2010)

  7. #6
    Join Date
    Oct 2009
    Posts
    364
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 37 Times in 36 Posts

    Default Re: QextSerialPort strange initialisation problem

    Quote Originally Posted by SteveH View Post
    Hi,

    Have you tried opening the port before setting the parameters ? - I seem to recall others with the same problem and it was due to the s/w not loading the actual port with the parameters if it was closed, just storing a local copy.

    Regards
    SteveH
    Double that.

    I remember having some trouble in the beginning regarding intialization and opening. Currently everything works great by doing the following:

    Qt Code:
    1. PortSettings pset;
    2. //set pset here as required
    3. ...
    4. QextSerialPort *port = new QextSerialPort(CommPort, pset, QextSerialPort::EventDriven);
    5. retVal = port->open(QIODevice::ReadWrite);
    6. etc.
    To copy to clipboard, switch view to plain text mode 

    hope this helps

  8. The following user says thank you to schnitzel for this useful post:

    Ferric (25th January 2010)

  9. #7
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    23

    Thumbs up Re: QextSerialPort strange initialisation problem

    Which version of QExtSerial are You using ?
    I am using qextserialport-1.2win-alpha.

    Have you tried opening the port before setting the parameters ?
    I just tried this and it works! Thanks heaps

  10. #8
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 284 Times in 279 Posts

    Default Re: QextSerialPort strange initialisation problem

    As You see this is alfa revision 3 years old and is dead.
    Use this version. It is active developed.

  11. #9
    Join Date
    Jun 2010
    Posts
    32
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    8

    Default Re: QextSerialPort strange initialisation problem

    It works for me now, with following code:
    Qt Code:
    1. //comPort is com8, baudSel=9600
    2.  
    3. port = new QextSerialPort(comPort, QextSerialPort::EventDriven);
    4. port->open(QIODevice::ReadWrite);
    5.  
    6.  
    7. port->setBaudRate(baudSel);
    8. port->setDataBits(DATA_8);
    9. port->setParity(PAR_NONE);
    10. port->setStopBits(STOP_1);
    11. port->setFlowControl(FLOW_OFF);
    12. port->setTimeout(500);
    13. port->setRts(true);
    14. port->setDtr(true);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Problem with qextserialport for Qt 4.5.2 for windows
    By viniciuscst in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2009, 21:01
  2. Problem with qextserialport on posix
    By bnilsson in forum Qt Programming
    Replies: 0
    Last Post: 13th June 2009, 16:12
  3. problem compiling QExtSerialPort
    By MarkoSan in forum Qt Programming
    Replies: 1
    Last Post: 8th December 2008, 13:03
  4. Problem with QExtSerialPort and a usb modem
    By Althor in forum Qt Programming
    Replies: 4
    Last Post: 31st October 2008, 12:02
  5. Can't create an object : initialisation problem ?
    By Nyphel in forum Qt Programming
    Replies: 5
    Last Post: 12th March 2007, 09:07

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.