Serial Communications with Visual Basic
RS-232 Protocol
DB-9 Connector
To listen to a Garmin Geko 201 GPS
First we must make a connector. For a DB-25 pin-2
Transmit on the PC side will connect to the
DATA-IN of the GPS. Pin-3 Receive on the PC
side will connect to the DATA-OUT on the Garmin.
Pin-7 will the connect to the ground(-Neg) on the
GPS. You MUST connect the ground for the cable
to work, the GPS uses it to pull the Data-In wire to
-LOW. For a DB-9 Connector,(most PC's use this
style) you must reverse pin-2 and pin-3 (pin-2 goes
toDATA-OUT on the GPS and pin-3 goes to
DATA-IN on the GPS) and pin-7 is to be
connected to the -Neg. While you are operating on
your GPS, you may decide to fabricate a power
supply as well. The specs for the Garmin Geko 201
are 3.15v +-.15volts DO NOT go over 3.3 volts or you
will toast your Geko. If the power drops below 3 volts
the batteries are used.
Make sure your Garmin Geko 201 is set to TEXT OUT
@ 9600 Baud
Option Explicit
Dim serialBufferDump As Variant
Dim dummy As Boolean
Sub form1_load()
Form1.MSComm1.PortOpen = False
End Sub
Private Sub Command1_Click()
serialBufferDump = ""
Form1.MSComm1.PortOpen = True
dummy = getUARTbuffer(0, 40)
Form1.Text1.Text = serialBufferDump
Form1.MSComm1.PortOpen = False
End Sub
Public Function getUARTbuffer(timeIT As Boolean, DurationLENGTH As Integer) As Boolean
If timeIT = True Then
DurationLENGTH = DurationLENGTH + Timer
Do
DoEvents
serialBufferDump = serialBufferDump & Form1.MSComm1.Input
Loop Until DurationLENGTH < Timer
End If
If timeIT = False Then
Do
DoEvents
Loop Until Form1.MSComm1.InBufferCount >= DurationLENGTH
serialBufferDump = Form1.MSComm1.Input
End If
getUARTbuffer = True
End Function
Remember, you must add the MSCOMM6 component for this code
to work. (click on project, click on components, select Microsoft
COMM Control 6.0 click add and your done! If you dont follow the
code just google mscomm or serial interface in VB for more answers.
Click DOT for full source code.