Results 1 to 12 of 12

Thread: qext-serial-port write problem.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    41
    Thanks
    12

    Default qext-serial-port write problem.

    hello every one.. i have a small problem here. I am communicating with a hardware on rs232 serial terminal.. I am able to send a start of frame and receive back a acknowledge-ment from the hardware device. i am sending a fixed string i.e 0xAC,0xCA,0x1F as the start of the frame which the hardware device sud check for and give a ackn. which is working fine . this is what i am doing i am writing the string AC CA 1F to the port this is done successfully.i get a acknowledgment from the hardware also.
    Qt Code:
    1. static const char mydata[] = { 0xAC,0xCA,0x1F};
    2. QByteArray data = QByteArray::fromRawData(mydata, sizeof(mydata));
    3. char i = port->write(mydata,sizeof(mydata));
    To copy to clipboard, switch view to plain text mode 

    Now the problem is when i try to send some configured hexa format data which i have
    in QByteArray hexadecimaldata; i am splitting the each byte in it and putting them into firstByte and secondByte. cause i have to send the configured data byte by byte and the data is never more then 2 bytes.

    Qt Code:
    1. firstByte = "0x"+hexadecimaldata.left(2);
    2. secondByte = "0x"+hexadecimaldata.mid(1, 2);
    3. char i = port->write(firstByte);
    4. char i = port->write(secondByte);
    To copy to clipboard, switch view to plain text mode 

    the configured hexadecimaldata is not wrting to the port..

    Pls tell me if i am going wrong some wer. ?

    thank you
    Last edited by rex; 1st March 2011 at 14:25.

Similar Threads

  1. Replies: 4
    Last Post: 10th July 2010, 17:34
  2. Serial Port Reading problem
    By sfabel in forum Qt Programming
    Replies: 12
    Last Post: 18th February 2010, 14:59
  3. Replies: 1
    Last Post: 16th June 2009, 09:09
  4. How to write bytes read from serial port to a QFile
    By shamik in forum Qt Programming
    Replies: 19
    Last Post: 25th June 2007, 14:12
  5. Serial Port
    By b1 in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2007, 02:05

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.