PDA

View Full Version : serial communication problem



Tavit
30th May 2008, 14:51
Hi friends,
I have one problem with the serial communication while sending the random generated values from one comp to another comp through RS 232 ,The receiving comp received ASCII values instead of Random generated values.While sending the text message, the receiving comp received exact data. I have attached the code pls tell me how to send and receive the Randomly generated data from comp one to comp two.

Thank you..

mazurekwrc
30th May 2008, 15:20
in function


void QespTest::transmitMsg()
{
QString j=rand()%1000;
int i= port->write( j.toAscii(), j.length() );
qDebug( "trasmitted : %s", i );
}

when you use QString j=rand()%1000; you call


QString::QString ( const QChar * unicode, int size )

constructor which call


QChar ( int code )

and its the reason why you get ASCII values, not integer
use it to get integer


int a = qrand() % 1000;
QString j( QString::number( a ) );

Tavit
31st May 2008, 11:31
Hi mazurekwrc thanks for the reply the program works as i desired. Hey i have a new problem now i wanted to save the data to DB what i receive on serial port data .I am using SQLite but i don't know how to save the values into the DB from Serial port (RS 232)data. I tried a few things but no success, Can you please guide me with this problem.


Thank You
Regards,
Tavit.

Tavit
31st May 2008, 13:56
Hi mazurekwrc,
Thanks for your Help.I cleared my problem myself.I can retrieve data from serial port stored into database.


Thanks,

Regards,
Tavit.