久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
C#寫的串口設置HC05_BCM417藍牙上位機源碼
[打印本頁]
作者:
laoxianccc
時間:
2018-6-14 20:54
標題:
C#寫的串口設置HC05_BCM417藍牙上位機源碼
運行界面:
0.png
(11.9 KB, 下載次數: 52)
下載附件
2018-6-14 22:27 上傳
0.png
(40.51 KB, 下載次數: 59)
下載附件
2018-6-14 22:21 上傳
全部資料51hei下載地址:
2、COM_HC05_BCM417_1.zip
(2.18 MB, 下載次數: 59)
2018-6-14 20:54 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
源碼預覽:
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.Diagnostics;
using System.Diagnostics.PerformanceData;
using System.Threading;
namespace COM_A
{
public partial class analysis : Form
{
Form1 myFrm=new Form1();
public string myStr1;
public int myFlag=0;
public analysis()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
myFrm.Show();
}
private void button2_Click(object sender, EventArgs e)
{
myFrm.sendData("AT\r\n");
myFlag = 1;
}
private void analysis_Load(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
//this.pictureBox1.Image = Image.FromFile(@"C:\Users\nxzh\Desktop\2.jpg");
this.pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\2.jpg");//bin文件中
this.pictureBox2.Image = Image.FromFile(Application.StartupPath + "\\2.jpg");//bin文件中
//開始執行后臺操作
//backgroundWorker1.RunWorkerAsync();
//多線程處理
Thread thread = new Thread(CrossThreadFlush);
thread.IsBackground = true;
thread.Start();
}
private void CrossThreadFlush()
{
while (true)
{
//將sleep和無限循環放在等待異步的外面
Thread.Sleep(10);
ThreadFunction();
}
}
private delegate void FlushClient();//代理
private void ThreadFunction()//多線程處理
{
//try
{
if ((this.txbBAUD.InvokeRequired) || (this.txbNameIn.InvokeRequired) || (this.txbNameOut.InvokeRequired) || (this.textBox4.InvokeRequired) || (this.textBox5.InvokeRequired) || (this.textBox6.InvokeRequired))//等待異步
{
FlushClient fc = new FlushClient(ThreadFunction);
try
{
this.Invoke(fc);//通過代理調用刷新方法
}
catch
{ }
}
else
{
//this.txbBAUD.Text = DateTime.Now.ToString();
analysisData(myFrm.myStr);
}
}
//catch
{ }
}
/*private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
while (true)
{
#region
/*this.Invoke((EventHandler)(delegate
{
try
{
if (myFrm.myStr == "OK\r\n")
{
this.pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\green.png");
}
else
{
this.pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\red.png");
}
if (myFrm.myStr == "OK:" + comboBox1.Text + "\r\n")
{
this.pictureBox2.Image = Image.FromFile(Application.StartupPath + "\\green.png");
}
else
{
this.pictureBox2.Image = Image.FromFile(Application.StartupPath + "\\red.png");
}
}
catch
{
}
}));//
//多線程使用時調用
#endregion
//analysisData(myFrm.myStr);
}
}*/
public void analysisData(string str)//解析函數
{
if ((str == "OK\r\n"))
{
if (myFlag == 1)
{
this.pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\green.png");
this.pictureBox5.Image = Image.FromFile(Application.StartupPath + "\\red.png");
this.pictureBox6.Image = Image.FromFile(Application.StartupPath + "\\red.png");
}
else if (myFlag == 2)
{
this.pictureBox5.Image = Image.FromFile(Application.StartupPath + "\\green.png");
this.pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\red.png");
this.pictureBox6.Image = Image.FromFile(Application.StartupPath + "\\red.png");
}
else if (myFlag == 3)
{
this.pictureBox6.Image = Image.FromFile(Application.StartupPath + "\\green.png");
this.pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\red.png");
this.pictureBox5.Image = Image.FromFile(Application.StartupPath + "\\red.png");
}
}
else
{
this.pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\red.png");
this.pictureBox5.Image = Image.FromFile(Application.StartupPath + "\\red.png");
this.pictureBox6.Image = Image.FromFile(Application.StartupPath + "\\red.png");
}
if (str == "OK:" + myStr1 + "\r\n")
{
this.pictureBox2.Image = Image.FromFile(Application.StartupPath + "\\green.png");
txbBAUD.Text = myStr1;
}
else
{
this.pictureBox2.Image = Image.FromFile(Application.StartupPath + "\\red.png");
txbBAUD.Text = "";
}
if (str == "OK:" + txbNameIn.Text.ToString() + "\r\n")
{
this.pictureBox3.Image = Image.FromFile(Application.StartupPath + "\\green.png");
txbNameOut.Text = txbNameIn.Text;
}
else
{
this.pictureBox3.Image = Image.FromFile(Application.StartupPath + "\\red.png");
txbNameOut.Text = "";
}
if (str == "OK:" + textBox4.Text.ToString() + "\r\n")
{
this.pictureBox4.Image = Image.FromFile(Application.StartupPath + "\\green.png");
textBox5.Text = textBox4.Text;
}
else
{
this.pictureBox4.Image = Image.FromFile(Application.StartupPath + "\\red.png");
textBox5.Text = "";
}
if ((str == "OK:M\r\n") || (myFrm.myStr == "OK:S\r\n"))
{
this.pictureBox7.Image = Image.FromFile(Application.StartupPath + "\\green.png");
textBox6.Text = comboBox2.Text;
}
else
{
this.pictureBox7.Image = Image.FromFile(Application.StartupPath + "\\red.png");
textBox6.Text = "";
}
}
private void analysis_FormClosing(object sender, FormClosingEventArgs e)
{
if (DialogResult.Yes == MessageBox.Show("程序正在使用中,確認退出?", "確認退出", MessageBoxButtons.YesNo))
{
//MessageBox.Show("立即退出!");
e.Cancel = false;
}
else
{
e.Cancel = true;
}
}
private void button3_Click(object sender, EventArgs e)
{
string myTempStr;
switch (cbxBAUD.SelectedIndex)
{
case 9:
myTempStr = "A";
break;
case 10:
myTempStr = "B";
break;
case 11:
myTempStr = "C";
break;
default:
myTempStr = (cbxBAUD.SelectedIndex + 1).ToString();
break;
}
//MessageBox.Show(comboBox1.SelectedIndex.ToString());
myFrm.sendData("AT+BAUD:" + myTempStr + "\r\n");
myStr1 = this.cbxBAUD.Text;
}
private void button4_Click(object sender, EventArgs e)
{
if (txbNameIn.Text.Length < 20)
{
myFrm.sendData("AT+NAME:" + txbNameIn.Text.ToString() + "\r\n");
}
else
{
MessageBox.Show("藍牙名稱超過20個字符","提示");
}
}
private void button5_Click(object sender, EventArgs e)
{
if (textBox4.Text.Length ==4)
{
myFrm.sendData("AT+PIN:" + textBox4.Text.ToString() + "\r\n");
}
else
{
MessageBox.Show("藍牙密碼不等于4個字符", "提示");
}
}
private void button6_Click(object sender, EventArgs e)
{
myFlag = 2;
myFrm.sendData("AT+PAIR\r\n");
}
private void button7_Click(object sender, EventArgs e)
{
myFrm.sendData("AT+DEFAULT\r\n");
myFlag = 3;
}
private void button8_Click(object sender, EventArgs e)
{
if (comboBox2.Text == "主模式")
{
myFrm.sendData("AT+ROLE=M\r\n");
}
else if (comboBox2.Text == "從模式")
{
myFrm.sendData("AT+ROLE=S\r\n");
}
}
}
}
復制代碼
作者:
mk_cs
時間:
2018-9-3 20:15
很詳細啊,學習學習
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
欧美成人免费电影
|
欧美性久久
|
九九热在线免费观看
|
一区二区精品
|
综合色站导航
|
国产日本精品视频
|
九九热视频这里只有精品
|
国产精品国产三级国产aⅴ中文
|
www.国产91
|
欧美日本一区
|
日韩欧美在线播放
|
精品一级
|
国产精品成人一区二区三区夜夜夜
|
国产不卡一区
|
不卡一区二区在线观看
|
精品视频一区二区三区在线观看
|
亚洲精品一区二区三区
|
欧美成人a∨高清免费观看 91伊人
|
日韩高清国产一区在线
|
一级毛片在线播放
|
第一福利社区1024
|
日韩欧美亚洲
|
91精品国产色综合久久不卡蜜臀
|
粉色午夜视频
|
伊人精品在线
|
亚洲一二三在线
|
欧美www在线
|
久久男人
|
99久久婷婷国产综合精品首页
|
国产午夜三级一区二区三
|
久草在线影
|
亚洲综合资源
|
亚洲国产中文在线
|
国产精品一区免费
|
在线观看日本网站
|
欧美日韩一区二区在线
|
国产探花
|
久草影视在线
|
成人视屏在线观看
|
欧美高清性xxxxhdvideosex
|
男女免费在线观看视频
|