Troubleshooting ASCII Character Transmission in VB for RS232 Communication

In summary, the speaker is having trouble communicating with a RS232 device using VB. They have noticed that characters with a value of 128 or higher are showing up as '?' instead of the desired character. They are unsure if the data is getting lost or if their communication setup is incorrect. They have included their code and are wondering if there is an easier way to send ASCII characters. Additionally, they are unfamiliar with stick parity and are unsure if they are using the correct parity for their protocol. The suggested solution is to try a different encoding, such as UNICODE.
  • #1
ionlylooklazy
30
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
  • #2
The ASCII encoding has printable characters from 32 to 126 only. You should try a different encoding, maybe Encoding.UNICODE.
 
Last edited:
  • #3
Thank you !
 

1. What is serial communication in VB?

Serial communication in VB refers to the process of sending and receiving data between two devices using a serial port. This is a common method of communication for devices such as printers, scanners, and other external hardware.

2. How do I establish a serial connection in VB?

To establish a serial connection in VB, you will need to use the SerialPort class. This class allows you to open a connection to a serial port and send and receive data. You will also need to specify the appropriate communication settings, such as the baud rate and data bits.

3. Can I use serial communication in VB for wireless devices?

No, serial communication in VB is typically used for wired devices. To communicate with wireless devices, you will need to use a different method, such as Bluetooth or Wi-Fi.

4. What is the difference between synchronous and asynchronous serial communication in VB?

Synchronous serial communication involves sending data in a continuous stream, with the sender and receiver synchronized to a common clock. Asynchronous serial communication, on the other hand, involves sending data in individual packets, with the sender and receiver using start and stop bits to synchronize the transmission.

5. How can I troubleshoot serial communication errors in VB?

If you are experiencing errors with your serial communication in VB, there are a few steps you can take to troubleshoot the issue. First, check that the correct communication settings are being used for both the sender and receiver. You can also use a serial port monitoring tool to see if data is being sent and received properly. If all else fails, try using a different serial port or testing with a different device to see if the issue is with the hardware.

Similar threads

  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
4
Views
5K
  • Programming and Computer Science
Replies
5
Views
5K
  • Programming and Computer Science
Replies
4
Views
15K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Electrical Engineering
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
25K
Back
Top