Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Serial communication in VB

  1. Jan 18, 2007 #1
    Hello all,


    I am trying to communicate with a rs232 device using VB.

    however, testing my program by using hypterminal, I noticed that any time I try to output an ascii character 128 or higher, it shows up as a '?' instead of the desired character.

    I know hypterminal is able to display the character (its a u with a hat), but is the data getting lost somehow? are the correct bits being transmitted, or am I not setting up my communications correctly?


    Heres my code (btw, is there an easier way to send ascii character? (either in hex,dec, or bin):


    Code (Text):

    Dim ascii As Encoding = Encoding.ASCII
    Dim test As Byte()
    Dim test1 As String

    test1 = Chr(8) + Chr(9) + chr(8) + Chr(17) + Chr(150) ' ect.. all bytes for a certain packet
    test = ascii.GetBytes(test1)

    value.Write(test, 0, 10)
    ps. What is stick parity? I'm not familiar with this. The protocoling I'm using utilizes it by have the parity on the first byte set to 1, and the rest of the bytes in a packet set to 0. To mimick this, I've been using Mark and Space parity respectively, but am unsure whether or not this is the same. (i have been using no parity for tests with hyperterminal)


    Thanks,

    IOLL
     
  2. jcsd
  3. Jan 18, 2007 #2

    -Job-

    User Avatar
    Science Advisor

    The ASCII encoding has printable characters from 32 to 126 only. You should try a different encoding, maybe Encoding.UNICODE.
     
    Last edited: Jan 18, 2007
  4. Jan 19, 2007 #3
    Thank you !
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Serial communication in VB
  1. VB Problem (Replies: 0)

  2. VB code question (Replies: 4)

  3. Help with VB (Replies: 1)

Loading...