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. Visual Basic
  4. Sending ascii extended characters via serial port [modified]

Sending ascii extended characters via serial port [modified]

Scheduled Pinned Locked Moved Visual Basic
comtutorialquestionworkspace
10 Posts 4 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.
  • K Offline
    K Offline
    keninfo
    wrote on last edited by
    #1

    Hello, I am making an application which can control a pabx (telephone switch). I connect my pc and the pabx via com port. For the connection setup i have to send some characterlines to the pabx. Sending normal ascii characters works fine. I use: SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example). Is there someone who can give me some information. I guess i have to change the character set? But how? Regards, Bas

    modified on Saturday, April 5, 2008 6:12 AM

    R D L 3 Replies Last reply
    0
    • K keninfo

      Hello, I am making an application which can control a pabx (telephone switch). I connect my pc and the pabx via com port. For the connection setup i have to send some characterlines to the pabx. Sending normal ascii characters works fine. I use: SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example). Is there someone who can give me some information. I guess i have to change the character set? But how? Regards, Bas

      modified on Saturday, April 5, 2008 6:12 AM

      R Offline
      R Offline
      Rajesh Anuhya
      wrote on last edited by
      #2

      Send Ascii value insted if Hexcode example i want to sent " charachter SerialPort.WriteLine(Chr(34))

      Rajesh B --> A Poor Workman Blames His Tools <--

      K 1 Reply Last reply
      0
      • R Rajesh Anuhya

        Send Ascii value insted if Hexcode example i want to sent " charachter SerialPort.WriteLine(Chr(34))

        Rajesh B --> A Poor Workman Blames His Tools <--

        K Offline
        K Offline
        keninfo
        wrote on last edited by
        #3

        Hello Rajesh, Thanks for your answer. I tried but when i send the character instead of Hex then i stil have to use an other character set, because hex97 = character 151. Standard ascii set starts at 0 and ends at 127. Extended ascii character set starts at 128 and ends at 255. As i have to send hex97 or character 151 i guess i have to change the character set but i do not know how and to which character set. Regards, Bas

        R 1 Reply Last reply
        0
        • K keninfo

          Hello Rajesh, Thanks for your answer. I tried but when i send the character instead of Hex then i stil have to use an other character set, because hex97 = character 151. Standard ascii set starts at 0 and ends at 127. Extended ascii character set starts at 128 and ends at 255. As i have to send hex97 or character 151 i guess i have to change the character set but i do not know how and to which character set. Regards, Bas

          R Offline
          R Offline
          Rajesh Anuhya
          wrote on last edited by
          #4

          try with ChrW() insted of Chr() reply me...

          Rajesh B --> A Poor Workman Blames His Tools <--

          K 1 Reply Last reply
          0
          • R Rajesh Anuhya

            try with ChrW() insted of Chr() reply me...

            Rajesh B --> A Poor Workman Blames His Tools <--

            K Offline
            K Offline
            keninfo
            wrote on last edited by
            #5

            I tried, but it doensnt work :(

            R 1 Reply Last reply
            0
            • K keninfo

              I tried, but it doensnt work :(

              R Offline
              R Offline
              Rajesh Anuhya
              wrote on last edited by
              #6

              first check u r encoding of serial port set below encoding for UTF-8 support SerialPort1.Encoding = System.Text.Encoding.GetEncoding(1252) after try this code Dim mybyte As Byte = 150 serialport.write(mybyte ) i think it will work

              Rajesh B --> A Poor Workman Blames His Tools <--

              K 1 Reply Last reply
              0
              • R Rajesh Anuhya

                first check u r encoding of serial port set below encoding for UTF-8 support SerialPort1.Encoding = System.Text.Encoding.GetEncoding(1252) after try this code Dim mybyte As Byte = 150 serialport.write(mybyte ) i think it will work

                Rajesh B --> A Poor Workman Blames His Tools <--

                K Offline
                K Offline
                keninfo
                wrote on last edited by
                #7

                Hello Rajesh, Thanks a lot, this works fine. I have been working for at least two weeks on this problem and now within two hours you solved my problem. Regards, Bas

                R 1 Reply Last reply
                0
                • K keninfo

                  Hello Rajesh, Thanks a lot, this works fine. I have been working for at least two weeks on this problem and now within two hours you solved my problem. Regards, Bas

                  R Offline
                  R Offline
                  Rajesh Anuhya
                  wrote on last edited by
                  #8

                  Welcome :cool:

                  Rajesh B --> A Poor Workman Blames His Tools <--

                  1 Reply Last reply
                  0
                  • K keninfo

                    Hello, I am making an application which can control a pabx (telephone switch). I connect my pc and the pabx via com port. For the connection setup i have to send some characterlines to the pabx. Sending normal ascii characters works fine. I use: SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example). Is there someone who can give me some information. I guess i have to change the character set? But how? Regards, Bas

                    modified on Saturday, April 5, 2008 6:12 AM

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    keninfo wrote:

                    SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example).

                    So what's wrong with writing Chr(&h97)??

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008

                    1 Reply Last reply
                    0
                    • K keninfo

                      Hello, I am making an application which can control a pabx (telephone switch). I connect my pc and the pabx via com port. For the connection setup i have to send some characterlines to the pabx. Sending normal ascii characters works fine. I use: SerialPort.WriteLine(Chr(&H10) & Chr(&H2) & Chr(&H20) & Chr(&H2) & Chr(&H0) & Chr(&H10) & Chr(&H3)) However, i have to send also hex97 (for example). Is there someone who can give me some information. I guess i have to change the character set? But how? Regards, Bas

                      modified on Saturday, April 5, 2008 6:12 AM

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #10

                      Hi, if you need to send special byte values over SerialPort, forget about text, strings and encodings, and use SerialPort.Write, which works with byte arrays, no encoding, no translation. What you get is what you ordered. :)

                      Luc Pattyn [Forum Guidelines] [My Articles]


                      This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


                      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