NOTE: I will be using a DHT11 temperature sensor to produce data on the Arduino end. Since this is a tutorial on reading data from the serial port using Python, not Arduino, I recommend visiting a DHT11 tutorial to learn how to print temperature data from the sensor to the serial port (see here, or here).
-->
This topic describes how to use
My.Computer.Ports to receive strings from the computer's serial ports in Visual Basic.
To receive strings from the serial port
ExampleCapture Serial Port Data To File
This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Connectivity and Networking. For more information, see Code Snippets.
Compiling the Code
This example assumes the computer is using
COM1 .
Serial Port Data Capture SoftwareRobust Programming
This example assumes the computer is using
COM1 . For more flexibility, the code should allow the user to select the desired serial port from a list of available ports. For more information, see How to: Show Available Serial Ports.
![]()
This example uses a
Try..Catch..Finally block to make sure that the application closes the port and to catch any timeout exceptions. For more information, see Try..Catch..Finally Statement.
See alsoSerial Port Comm Data Capture
Posted by2 years ago
Archived
Hello,
I am creating a bit of code that grabs data from a COM connected GPS receiver, and am having issues reading the data with my code. Using SerialPort Class I have specified and opened the COM Port that I wish to use, but encounter a time out error before I can capture any data. If I connect to the COM using something like TeraTerm Virtual Terminal, I immediately see the data flow from the device. Below is an example of the data stream captured by a TeraTerm window and the code I was attempting to at least grab one line and print it to the console. Free christian midi files backing tracks. The data is a continuous and repetitive stream, so eventually I want to grab it as it comes in and grab only what I need. (For example the $GPGLL line in the data contains GPS coordinates and UTC time) I am a new user to C#, so there are many things I still have to learn and understand, so any explanation or help regarding what I need to do would be very appreciated!
Many Thanks
8 comments
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |