Results 1 to 6 of 6

Thread: send hex or ascii or int value through serial port

  1. #1
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default send hex or ascii or int value through serial port

    I have been able to write serial port. I need to get integer value from line edit, then send the value through serial port.
    Qt Code:
    1. unsigned char c = ui->lineEdit->text().toInt();
    To copy to clipboard, switch view to plain text mode 

    How can i send all 255 ascii values through serial port?
    Last edited by omegaKnot; 27th May 2011 at 09:51. Reason: spelling corrections

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: send hex or ascii or int value through serial port

    How can i send all 255 ascii values through serial port?
    you said also:
    I have been able to write serial port.
    So I don't understand the question.
    If you can write to the serial port, where is the problem?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: send hex or ascii or int value through serial port

    i can send values like 1,2,5, A,},R. They all are single character. Now i need to send decimal 65 or hex 41. Im thinking of sending it as its ASCII 'A'. How do i do it?

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: send hex or ascii or int value through serial port

    i can send values like 1,2,5, A,},R. They all are single character.
    Exactly.
    That is ALL you can do.
    How these bytes are interpreted, is the job of the receiving end.
    You are not sending the bytes "as ASCII" you interpret them as ASCII when you receive the bytes.
    The same stream can be interpreted by the receiving end as ASCII binary or hex or what ever else.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: send hex or ascii or int value through serial port

    Then how am i gonna send value 41. Actually this value gets calculated in sender side. Should i send 'A' then?

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: send hex or ascii or int value through serial port

    Then how am i gonna send value 41
    Simply by sending a byte with the decimal value of 41.
    On the receiving side this can be displayed as an 'A', or used to calculate the meaning of life by adding 1 to it and displaying the decimal outcome.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. send binary file over serial port with QSerialDevice
    By ilpaso in forum Qt Programming
    Replies: 30
    Last Post: 13th December 2010, 13:08
  2. serial port communiction
    By jagadish in forum Qt Programming
    Replies: 1
    Last Post: 7th July 2007, 12:52
  3. Serial Port
    By b1 in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2007, 03:05
  4. Serial Port access in Qt
    By Doug Broadwell in forum Newbie
    Replies: 1
    Last Post: 30th November 2006, 10:45
  5. Serial Port access in Qt
    By Doug Broadwell in forum Newbie
    Replies: 2
    Last Post: 18th October 2006, 22:03

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.