Troubleshooting ASCII Character Transmission in VB for RS232 Communication

Click For Summary
SUMMARY

This discussion addresses issues with transmitting ASCII characters over RS232 communication using Visual Basic (VB). The user experiences problems with characters 128 and higher displaying as '?' when tested with HyperTerminal. The solution proposed involves switching from Encoding.ASCII to Encoding.UNICODE to properly handle extended ASCII characters. Additionally, the user seeks clarification on stick parity and its implementation in their communication protocol.

PREREQUISITES
  • Understanding of RS232 communication protocols
  • Familiarity with Visual Basic programming
  • Knowledge of character encoding, specifically ASCII and UNICODE
  • Basic concepts of parity in data transmission
NEXT STEPS
  • Research how to implement Encoding.UNICODE in VB for RS232 communication
  • Learn about different parity types, including stick parity, and their applications
  • Explore alternative methods for sending ASCII characters in hex, decimal, or binary formats
  • Investigate troubleshooting techniques for RS232 communication issues
USEFUL FOR

This discussion is beneficial for software developers working with serial communication, particularly those using Visual Basic and dealing with character encoding issues in RS232 protocols.

ionlylooklazy
Messages
30
Reaction score
0
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:
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
 
Technology news on Phys.org
The ASCII encoding has printable characters from 32 to 126 only. You should try a different encoding, maybe Encoding.UNICODE.
 
Last edited:
Thank you !
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
Replies
4
Views
5K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 4 ·
Replies
4
Views
16K
  • · Replies 7 ·
Replies
7
Views
25K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K