资源简介
C#写的获取GPS信息,通过串口获取经度,纬度,海拔,还可以通过文本框实时显示GPS收到的信息。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;
namespace GPS
{
public partial class Form1 : Form
{
SerialPort serialcom = new SerialPort();
Thread thread_busy; //占线服务线程
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender EventArgs e)
{
String str1 = comboBox1.Text;
try
{
if (str1 == null)
{
MessageBox.Show(“请先选择串口!“ “Error“);
return;
}
serialcom.PortName = str1;
serialcom.BaudRate = 9600;
serialcom.DataBits = 8;
serialcom.StopBits = StopBits.One;
serialcom.Parity = Parity.None;
if (serialcom.IsOpen == true)
{
serialcom.Close();
}
serialcom.Open();
MessageBox.Show(“串口打开成功!“ str1);
button1.Enabled = false;
comboBox1.Enabled = false;
}
catch (Exception er)
{
MessageBox.Show(“Error:“ + er.Message “Error“);
return;
}
}
private void button2_Click(object sender EventArgs e)
{
button1.Enabled = true;
comboBox1.Enabled = true;
serialcom.Close();
}
private void Form1_Load(object sender EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
serialcom.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
textBox2.Text = “未定位“;
}
private void serialPort1_DataReceived(object sender SerialDataReceivedEventArgs e)
{
byte[] byteRead = new byte[serialcom.BytesToRead];
serialcom.Read(byteRead 0 byteRead.Length);
string strRcv = null;
for (int i = 0; i < byteRead.Length; i++)
{
strRcv += ((char)Convert.ToInt32(byteRead[i]));
}
textBox1.Text += strRcv;
this.textBox1.Focus();
this.textBox1.Select(this.textBox1.TextLength0);
this.textBox1.ScrollToCaret();
}
private void button3_Click(object sender EventArgs e)
{
textBox1.Clear();
}
private void busy()
{
while (true)
{
Invoke(new EventHandler(timer1_Tick));
}
}
private void timer1_Tick(object sender EventArgs
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 14336 2014-05-19 10:31 GPS信息采集\GPS\bin\Debug\GPS.exe
文件 30208 2014-05-19 10:31 GPS信息采集\GPS\bin\Debug\GPS.pdb
文件 11600 2014-05-19 12:41 GPS信息采集\GPS\bin\Debug\GPS.vshost.exe
文件 490 2010-03-17 22:39 GPS信息采集\GPS\bin\Debug\GPS.vshost.exe.manifest
文件 6447 2014-05-19 10:31 GPS信息采集\GPS\Form1.cs
文件 10859 2014-05-19 10:31 GPS信息采集\GPS\Form1.Designer.cs
文件 6011 2014-05-19 10:31 GPS信息采集\GPS\Form1.resx
文件 3665 2014-05-17 20:45 GPS信息采集\GPS\GPS.csproj
文件 5359 2014-05-18 21:33 GPS信息采集\GPS\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6283 2014-05-19 10:31 GPS信息采集\GPS\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 738 2014-05-19 12:41 GPS信息采集\GPS\obj\x86\Debug\GPS.csproj.FileListAbsolute.txt
文件 975 2014-05-19 10:31 GPS信息采集\GPS\obj\x86\Debug\GPS.csproj.GenerateResource.Cache
文件 9040 2014-05-18 21:34 GPS信息采集\GPS\obj\x86\Debug\GPS.csprojResolveAssemblyReference.cache
文件 14336 2014-05-19 10:31 GPS信息采集\GPS\obj\x86\Debug\GPS.exe
文件 180 2014-05-19 10:31 GPS信息采集\GPS\obj\x86\Debug\GPS.Form1.resources
文件 30208 2014-05-19 10:31 GPS信息采集\GPS\obj\x86\Debug\GPS.pdb
文件 180 2014-05-17 20:45 GPS信息采集\GPS\obj\x86\Debug\GPS.Properties.Resources.resources
文件 484 2014-05-17 20:28 GPS信息采集\GPS\Program.cs
文件 1338 2014-05-17 20:28 GPS信息采集\GPS\Properties\AssemblyInfo.cs
文件 2858 2014-05-17 20:28 GPS信息采集\GPS\Properties\Resources.Designer.cs
文件 5612 2014-05-17 20:28 GPS信息采集\GPS\Properties\Resources.resx
文件 1090 2014-05-17 20:28 GPS信息采集\GPS\Properties\Settings.Designer.cs
文件 249 2014-05-17 20:28 GPS信息采集\GPS\Properties\Settings.settings
文件 851 2014-05-17 20:28 GPS信息采集\GPS信息采集.sln
..A..H. 19456 2014-05-19 13:22 GPS信息采集\GPS信息采集.suo
目录 0 2014-05-17 20:28 GPS信息采集\GPS\obj\x86\Debug\TempPE
目录 0 2014-05-19 10:31 GPS信息采集\GPS\obj\x86\Debug
目录 0 2014-05-17 20:46 GPS信息采集\GPS\bin\Debug
目录 0 2014-05-17 20:28 GPS信息采集\GPS\obj\x86
目录 0 2014-05-17 20:28 GPS信息采集\GPS\bin
............此处省略7个文件信息
- 上一篇:c#编写串口通讯代码 多线程实现
- 下一篇:汉口长江每月流量数据
相关资源
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
评论
共有 条评论