Troubleshooting ASCII Character Transmission in VB for RS232 Communication

AI Thread Summary
The discussion centers on challenges faced when communicating with an RS232 device using Visual Basic (VB). The user encounters an issue where ASCII characters with values of 128 or higher are displayed as '?' in HyperTerminal, despite the software's capability to show these characters correctly. This raises questions about whether the data is being transmitted correctly or if there are issues with the communication setup. The user shares code snippets for sending ASCII characters and inquires about easier methods for sending characters in different formats, such as hex or binary. Additionally, the user seeks clarification on "stick parity," noting that their protocol requires specific parity settings for the first byte and subsequent bytes. A suggestion is made to use a different encoding, such as Encoding.UNICODE, to address the character display issue.
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 !
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Back
Top