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.
Code:
void Loader::send()
{
QextSerialPort * port = new QextSerialPort("COM4", QextSerialPort::EventDriven);
port->setBaudRate(BAUD9600);
port->setFlowControl(FLOW_OFF);
port->setParity(PAR_NONE);
port->setDataBits(DATA_8);
port->setStopBits(STOP_1);
port
->open
(QIODevice::ReadWrite );
//| QIODevice::Unbuffered); //The Unbuffered option did not help. port->flush(); // I thought this might help but it didn't.
port->write("goodbye");
port->close();
}
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
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
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..
Re: QextSerialPort strange initialisation problem
Which version of QExtSerial are You using ?
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
Re: QextSerialPort strange initialisation problem
Quote:
Originally Posted by
SteveH
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:
Code:
PortSettings pset;
//set pset here as required
...
QextSerialPort *port = new QextSerialPort(CommPort, pset, QextSerialPort::EventDriven);
etc.
hope this helps
Re: QextSerialPort strange initialisation problem
Quote:
Which version of QExtSerial are You using ?
I am using qextserialport-1.2win-alpha.
Quote:
Have you tried opening the port before setting the parameters ?
I just tried this and it works! Thanks heaps
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.
Re: QextSerialPort strange initialisation problem
It works for me now, with following code:
Code:
//comPort is com8, baudSel=9600
port = new QextSerialPort(comPort, QextSerialPort::EventDriven);
port->setBaudRate(baudSel);
port->setDataBits(DATA_8);
port->setParity(PAR_NONE);
port->setStopBits(STOP_1);
port->setFlowControl(FLOW_OFF);
port->setTimeout(500);
port->setRts(true);
port->setDtr(true);