Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem with ReadExisting in serial communication...i am sending data in hexa decimal but i am reciving it in asci.....

Problem with ReadExisting in serial communication...i am sending data in hexa decimal but i am reciving it in asci.....

Scheduled Pinned Locked Moved C#
helptutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pallaka
    wrote on last edited by
    #1

    Problem with ReadExisting in serial communication...i am sending data in hexa decimal but i am reciving it in asci..... How to get the proper data....how to convert data from asci to Hex. as i need to display the data in the Text box in the Hex format.

    L 1 Reply Last reply
    0
    • P pallaka

      Problem with ReadExisting in serial communication...i am sending data in hexa decimal but i am reciving it in asci..... How to get the proper data....how to convert data from asci to Hex. as i need to display the data in the Text box in the Hex format.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Encoding.ASCII.GetString(byte[] bytes) or Encoding.ASCII.GetBytes(string input)

      P 1 Reply Last reply
      0
      • L Lost User

        Encoding.ASCII.GetString(byte[] bytes) or Encoding.ASCII.GetBytes(string input)

        P Offline
        P Offline
        pallaka
        wrote on last edited by
        #3

        I need to convert text to asci and asci to hex

        OriginalGriffO 1 Reply Last reply
        0
        • P pallaka

          I need to convert text to asci and asci to hex

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Try string.format("{0:X2}", asciByte); which converts asciByte to a two digit Hex string.

          No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          P 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Try string.format("{0:X2}", asciByte); which converts asciByte to a two digit Hex string.

            No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

            P Offline
            P Offline
            pallaka
            wrote on last edited by
            #5

            No It didnt work....... Lets take an example string data "3F 50" after conversion i should get "? P" but i am not getting any thing

            OriginalGriffO 1 Reply Last reply
            0
            • P pallaka

              No It didnt work....... Lets take an example string data "3F 50" after conversion i should get "? P" but i am not getting any thing

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              Look at

              Parse(str, System.Globalization.NumberStyles.HexNumber)

              You will have to use it a few times and skip the spaces, but it will convert hex "3F" to byte '?'

              No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups