Recieving Serial Data

computer guy

Member
Joined
Feb 12, 2008
Messages
18
Programming Experience
Beginner
Hi everyone,

I am sending some data from a microcontroller.
I am working on a VB.net program to read in the data.

The data consists of 4 bytes.
They are sent one after the other,

I am using the VB serial object that is in the toolbar.

How can I get the 4 bytes and turn them back into real numbers, then join them together into a string?

Thank you :)
 
Does SerialPort class have any events and methods that sounds tempting to you?
 
Start by checking the documentation for the SerialPort class, it has a very interesting DataReceived event, also check its methods and see if there is one you can use.
 
BCD stores each digit in 4 bits, the smallest data type in VB is Byte (8 bits), so you need some bit operations to extract high and low info from the byte, example:
VB.NET:
Dim b As Byte = 147 '= binary 10010011, 1001=9, 0011=3
Dim high As Byte = b >> 4 'high=9
Dim low As Byte = b And &HF 'low=3
 
Back
Top