
示例:
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string tmpstr = ""
for (int i = 0i <serialPort1.BytesToReadi++)
{
tmpstr += Convert.ToString(serialPort1.ReadByte(), 16)+ " "
}
tmpstr= tmpstr.ToUpper()
safeAddtrText(tmpstr)
}
//由于本人比较懒,委托就从网上直接Copy了。
public delegate void _SafeAddtrTextCall(string text)
private void safeAddtrText(string text)
{
if (this.InvokeRequired)
{
_SafeAddtrTextCall call =
delegate(string s)
{
txtBoxRecive.Text += s
}
this.Invoke(call, text)
}
else
{
txtBoxRecive.Text += text
}
}
架设服务器平台,很简单;这里介绍一个 GPSBD卫星定位监控系统Simple版本的定位系统
他们系统是JAVA开发,首先服务器需要搭建JAVA环境,Mysql数据库,以及Reids缓存服务;
然后启动程序文件,一步一步 *** 作即可;经过测试系统基本上市面上的各类GPS北斗定位设备都是支持的
在自己服务器搭建好GPS平台以后,就可以将设备的IP 端口配置到自己服务器对应的IP端口上,这样设备数据就会发往服务器,然后通过这套GPS定位系统就可以查看位置了
/////////////////////////////////////////////////////////////
设计题目
:
基于51单片机的串口通信
//
功能
:
//
说明
:
晶振用12m,
///////////////////////////////////////////////////////////
#include
//
12m
晶振
#define
uchar
unsigned
char
#define
uint
unsigned
int
///////////////////////////////////////////////////////////
//
name
:
串口发送函数
//
in
:
//
out
:
//
function
:
//
explain
:
///////////////////////////////////////////////////////////
void
send(uchar
x)
{
sbuf=x
//
将数据放到缓冲区,发送
while(!ti)
//
等待发送完成
ti=0
//
清标志位
}
///////////////////////////////////////////////////////////
//
name
:
初始化函数
//
in
:
//
out
:
//
function
:
//
explain
:
///////////////////////////////////////////////////////////
void
init(void)
{
tmod=0x20
//
t1工作在方式2,自动重载
th1=0xe6
tl1=0xe6
//
设置波特率为1200
sm0=0
sm1=1
//
串口方式1
tr1=1
//
打开定时器1
}
///////////////////////////////////////////////////////////
//
name
:
主函数
//
in
:
//
out
:
//
function
:
//
explain
:
///////////////////////////////////////////////////////////
void
main(void)
{
uchar
i
init()
//
初始化
while(1)
{
for(i=0
i<10
i++)
{
send(i)
}
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)