| Writing a VB Application The following description show how to write a simple Visual Basic Application to communicate with a device connected to the USB to TTL cable. Adding the MSComm Component To communicate with a Com Port the MSComm Component must be first added to your project. Select Components from the Project Menu. Scroll down the list of controls until you find "Microsoft Comm Control 6.0" and click on the tick box to select.
Click OK. This adds a telephone icon to your component toolbox. You can add a MSComm Component to your Form just like adding a Button or Text Box. Each MSComm component can communicate with one port. Initialising the Component
The
MSComm Component can be set up either using the properties box (at
design-time) or in software (at run-time). We will assume that our
USB to TTL Cable is mapped to Com 2 and that our embedded firmware is
communicating at 9600baud. We will set up the MSCom Component in
Software (this allows to chose the com port from a menu or settings dialog
in the future rather than hardcode this value now). The
initialisation of the Form is a good place to put the code.
Code 1: Initialising the MSCom Component Openning the Port
Opening the Port can be done with the following code, the
Port is openned with the 'Open Port' Button is pressed.
Code 2: Opening the Com Port
|

