Results 1 to 4 of 4

Thread: serial communication problem

  1. #1
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default serial communication problem

    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..
    Attached Files Attached Files

  2. #2
    Join Date
    Oct 2007
    Location
    Cracow
    Posts
    56
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: serial communication problem

    in function
    Qt Code:
    1. void QespTest::transmitMsg()
    2. {
    3. QString j=rand()%1000;
    4. int i= port->write( j.toAscii(), j.length() );
    5. qDebug( "trasmitted : %s", i );
    6. }
    To copy to clipboard, switch view to plain text mode 
    when you use QString j=rand()%1000; you call
    Qt Code:
    1. QString::QString ( const QChar * unicode, int size )
    To copy to clipboard, switch view to plain text mode 
    constructor which call
    Qt Code:
    1. QChar ( int code )
    To copy to clipboard, switch view to plain text mode 
    and its the reason why you get ASCII values, not integer
    use it to get integer
    Qt Code:
    1. int a = qrand() % 1000;
    2. QString j( QString::number( a ) );
    To copy to clipboard, switch view to plain text mode 
    Last edited by mazurekwrc; 30th May 2008 at 14:33.

  3. #3
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: serial communication problem

    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.
    Last edited by Tavit; 31st May 2008 at 10:51.

  4. #4
    Join Date
    Mar 2008
    Posts
    52
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: serial communication problem

    Hi mazurekwrc,
    Thanks for your Help.I cleared my problem myself.I can retrieve data from serial port stored into database.


    Thanks,

    Regards,
    Tavit.

Similar Threads

  1. Serial Port communication
    By mgurbuz in forum Qt Programming
    Replies: 12
    Last Post: 22nd January 2011, 02:38
  2. serial communication programming
    By jagadish in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2007, 07:47
  3. C++ Library for serial communication
    By dec0ding in forum General Programming
    Replies: 7
    Last Post: 8th July 2007, 18:18
  4. How to transfer file through serial communication
    By shamik in forum Qt Programming
    Replies: 29
    Last Post: 29th May 2007, 10:22
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.