
FSUIPC FSX SERIAL SERIAL
What this code does is to open the serial port and start a new thread If messageFromSerial = "GEAR1" & vbCr ThenĮlseIf messageFromSerial = "GEAR0" & vbCr Then TxtDATA_FROM_SERIAL.Text = messageFromSerial If txtDATA_FROM_SERIAL.InvokeRequired Then Sub processReadings( ByVal readingText As 'open the port, read the stream, send the stream to the thread SerialPort( My.Settings.ComPort, My.Settings.BaudRate) EventArgs) Handles bntConnect_to_serial.Click Sub bntConnect_to_serial_Click( ByVal sender As System.

Now let's double click our connect button and write the following code Using this code we declare our serial port and the thread that we are going to use, put this code in the main class of your program. The new thread will allow the user to have control of the form and allow him or her to stop the process. We are going to make our program to create a new thread for this purpose. Our program works by reading the serial port and when our program finds a difference in the readings it will transmit the appropriate command to the API. It's a simple operation and we will use the button sub to handle the process. MsgBox( "Please type your connection settings") Sub btnSAVESETTINGS_Click( ByVal sender As System.

Run your application and check that everything is ok EventArgs) Handlesįor simple operations we can always use the load method of our form but I prefer to split the code because I'm planning to extend the code later and easier to handle and understand. And create a new sub to handle the loading into the form. Get the user settings Now let's write up a bit of code to get and save the settings.ĭouble click on your form in order to get the form load code. Note that we can change the settings later in our code. You can set the user settings using the project properties as we did above when we referenced the API. NET framework allow us to do with the Application settings. Now I like to have the program remember my com port and my baud rate so I don't have to type them all the time.
