[Qt-interest] serial communication
Srdjan Todorovic
todorovic.s at googlemail.com
Tue Mar 30 10:59:35 CEST 2010
Hi,
On 30/03/2010, Yuvraj <yuvraj.ragupathi at indieontech.com> wrote:
> Here i am opening the serial communication device file and writing some
> data, in other hand i am not getting the data due to enter key( "/r/n")
>
> my code is
>
> file_descriptor = open("/dev/ttyS0",O_RDWR);
> if(file_descriptor > 0)
> {
> timer = new QTimer;
> timer1 =new QTimer;
>
> QObject::connect(timer,SIGNAL(timeout()),this,SLOT(browser_append()));
>
> QObject::connect(timer1,SIGNAL(timeout()),this,SLOT(on_send_clicked()));
> timer->start(1);
> timer1->start(10);
You definitely wanted 1ms and 10ms?
Not sure if this applies to your setup:
"If Qt is unable to deliver the requested number of timer clicks, it
will silently discard some."
Is there a chance that your event loop is being overloaded by a timer
event storm?
(I think I might have seen something like that in Qt-embedded-3.x)
> void window::on_send_clicked()
> {
> int file_id;
> char send_data[150]= "Hi Hello\r\n";
> if(file_descriptor > 0)
> {
> file_id= write(file_descriptor,send_data,15);
Or are you saying that ::write() on a serial port does not like the
\r\n control characters?
Do you need to set the serial port's settings?
Why are you writing 15 bytes when your string is 11 bytes including
the string terminator?
What happens if send_data[12] == '0x08'; (backspace) ?
Does the other side accept that random data and interpret any control chars?
Is on_send_clicked() method even being called each time?
Srdjan
More information about the Qt-interest-old
mailing list