当前位置: 首页 > news >正文

织梦怎么做门户网站seo咨询价格找推推蛙

织梦怎么做门户网站,seo咨询价格找推推蛙,什么是广告艺术设计,什么是网络营销渠道?仅作自己学习使用 1 准备部份 串口通讯需要两个调试软件commix和Virtual Serial Port Driver,分别用于监视串口和创造虚拟串口。网口通讯需要一个网口调试助手,网络上有很多资源,我在这里采用的是微软商店中的TCP/UDP网络调试助手&#xff0…

仅作自己学习使用


1 准备部份

串口通讯需要两个调试软件commix和Virtual Serial Port Driver,分别用于监视串口和创造虚拟串口。网口通讯需要一个网口调试助手,网络上有很多资源,我在这里采用的是微软商店中的TCP/UDP网络调试助手,其中也有和commix一样功能的串口调试模块。

第一个软件是这样的:
commix 1.4
资源在这里:免费下载:Commix
也可以前往官网下载:Bwsensing— Attitude is everything
在这里插入图片描述
点击Download即可


第二个软件是这样的:
Virtual Serial Port Driver Pro
官方下载链接:Virtual Serial Port Driver


第三个软件是这样的:
TCP UDP网络调试工具
可以看到其实这个软件也有串口通讯调试的功能。
官方下载链接:TCP UDP网络调试助手

2 串口通讯

2.1 Xaml代码

界面做得很丑,能用就行,关键是原理:
在这里插入图片描述

<Window x:Class="WPF_ZhaoXi_0205.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_ZhaoXi_0205"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Grid><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><TextBox x:Name="textBox_receive" Grid.Row="0" Grid.Column="0" FontSize="15" Margin="10" Text="接收窗口"/><TextBox x:Name="textBox_send" Grid.Row="0" Grid.Column="1" FontSize="15" Margin="10" Text="发送窗口"/><Button x:Name="button_open" Grid.Row="1" Grid.Column="0" Content="打开串口" Margin="10" Click="button_open_Click"/><Button x:Name="button_recisive" Grid.Row="1" Grid.Column="1" Content="接收数据" Margin="10" Click="button_recisive_Click"/><Button x:Name="button_send" Grid.Row="2" Grid.Column="0" Content="发送数据" Margin="10" Click="button_send_Click"/></Grid>
</Window>

2.2 cs代码

using System.IO.Ports;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace WPF_ZhaoXi_0205
{/// <summary>/// Interaction logic for MainWindow.xaml/// </summary>public partial class MainWindow : Window{// 声明一个串口对象SerialPort sp = null;public MainWindow(){InitializeComponent();// 实例化串口对象//sp = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);sp = new SerialPort();// 设置通讯的属性sp.PortName = "COM2";       // 串口名称sp.BaudRate = 9600;         // 波特率sp.Parity = Parity.None;    // 校验位sp.DataBits = 8;            // 数据位  sp.StopBits = StopBits.One; // 停止位 // 第二种接收数据的方式,被动接收,如称重,扫码枪等 sp.DataReceived += Sp_DataReceived;}/// <summary>/// 第二种数据接收的方式/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void Sp_DataReceived(object sender, SerialDataReceivedEventArgs e){byte[] bt1 = new byte[sp.BytesToRead];sp.Read(bt1, 0, bt1.Length);// 这里在异步线程处理了UI控件,而UI控件必须在主线程处理,因此要报错//textBox_recsive.Text = Encoding.ASCII.GetString(bt1);// 因此把这个语句放在UI线程(主线程进行)this.Dispatcher.Invoke(() =>{ textBox_receive.Text = Encoding.ASCII.GetString(bt1); });}/// <summary>/// 打开串口/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button_open_Click(object sender, RoutedEventArgs e){// 打开动作try{// 串口的一端只能同时被一个用户打开,否则报错,所以看是否串口已经被占用sp.Open();MessageBox.Show(sp.PortName+"串口已打开", "提示");}catch (Exception ex){MessageBox.Show(ex.Message,"提示");}}/// <summary>/// 发送数据/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button_send_Click(object sender, RoutedEventArgs e){// 发送动作(与打开动作操作同一个串口对象)// sp.Write();string str_send = textBox_send.Text;byte[] bt1 = Encoding.ASCII.GetBytes(str_send);byte[] bt2 = new byte[] { 0x01, 0x02, 0x03 };sp.Write(bt1, 0, bt1.Length);  // 在bytes中从位置0开始发送bytes.Length个字节}/// <summary>/// 接收数据(第一种接收方式,主动请求接收方式)/// 我要你再给/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button_recisive_Click(object sender, RoutedEventArgs e){// 长度是串口能够读到的最大的字节数量byte[] bt1 = new byte[sp.BytesToRead];sp.Read(bt1, 0, bt1.Length); // 从当前串口中的位置0处开始读取bt1.Length个字节到bt1中textBox_receive.Text = Encoding.ASCII.GetString(bt1);}}
}

3 网口通讯

3.1 Xaml代码

<Window x:Class="WPF_ZhaoXi_0205.window1"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WPF_ZhaoXi_0205"mc:Ignorable="d"Title="window1" Height="450" Width="800"><Grid><Grid.RowDefinitions><RowDefinition/><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><TextBox x:Name="textBox_receive" Grid.Row="0" Grid.Column="0" FontSize="15" Margin="10" Text="接收窗口"/><TextBox x:Name="textBox_send" Grid.Row="0" Grid.Column="1" FontSize="15" Margin="10" Text="发送窗口"/><Button x:Name="button_connect" Grid.Row="1" Grid.Column="0" Content="链接服务器" Margin="10" Click="button_connect_Click"/><Button x:Name="button_receive" Grid.Row="1" Grid.Column="1" Content="接收数据" Margin="10" Click="button_receive_Click"/><Button x:Name="button_send" Grid.Row="2" Grid.Column="0" Content="发送数据" Margin="10" Click="button_send_Click" /></Grid>
</Window>

3.2 cs代码

using System.IO;
using System.IO.Ports;
using System.Net.Sockets;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace WPF_ZhaoXi_0205
{/// <summary>/// Interaction logic for MainWindow.xaml/// </summary>public partial class window1 : Window{// 声明一个对象Socket socket = null;public window1(){InitializeComponent();socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);}/// <summary>/// 链接数据库/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button_connect_Click(object sender, RoutedEventArgs e){try{socket.Connect("127.0.0.1", 6666);Task.Run(() =>{// 异步线程while (true){byte[] datb = new byte[50];socket.Receive(datb);this.Dispatcher.Invoke(() => {textBox_receive.Text = Encoding.UTF8.GetString(datb);});    }});MessageBox.Show("服务器已链接", "提示");}catch (Exception ex){MessageBox.Show(ex.Message, "提示");}}/// <summary>/// 发送数据/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button_send_Click(object sender, RoutedEventArgs e){// byte[] data = new byte[] { 0x32 };byte[] data = Encoding.UTF8.GetBytes("[abc] hello 牛犇!123");socket.Send(data);// 接收数据(主动响应)//byte[] datb = new byte[50];//socket.Receive(datb);//textBox_receive.Text = Encoding.UTF8.GetString(datb);}/// <summary>/// 接收数据/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button_receive_Click(object sender, RoutedEventArgs e){byte[] datb = new byte[50];socket.Receive(datb);textBox_receive.Text = Encoding.UTF8.GetString(datb);}}
}
http://www.hrbkazy.com/news/15279.html

相关文章:

  • 苏州木渎做网站公司百度seo怎么样优化
  • wordpress数据库里有垃圾企业网站seo案例分析
  • 个人网站托管详细描述如何进行搜索引擎的优化
  • 海口哪里做网站公司百度投放广告平台
  • 免费做动态图片的网站佛山百度快速排名优化
  • 邯郸市中小学健康管理平台登录泸州网站seo
  • wordpress 导入导出重庆seo网站收录优化
  • 河南郑州汽车网网站建设公众号软文素材
  • 交友app开发多少钱seo算法培训
  • 做私人网站2022年7到8月份的十大新闻
  • 游戏网站策划爱站工具查询
  • 北京个人网站制作百度怎么打广告在首页
  • 凡科网站怎么做授权查询技术培训
  • 免费注册一个网站营销策略手段有哪些
  • 新闻网站系统网络推广推广
  • 马尾区建设局网站杭州seo
  • 网站排名配色免费换友情链接
  • 网站规划模板百度文库网页版
  • 网站建设与管理教学方案十五种常见的销售策略
  • 做网站留言板需要什么条件搜索引擎优化的目标
  • 做某网站的设计与实现电商网站建设报价
  • 建站之星官网建设网络客服
  • 泰州cms建站模板新媒体营销
  • 网站建设报告内容模板网站建设开发
  • 石大远程网页设计及网站建设答案常用的seo工具推荐
  • 免费做 爱视频网站线上线下推广方案
  • wordpress 图片显示插件成都网站优化seo
  • 申请域名流程后怎样做网站网站关键词排名优化
  • 十大拿货网站东莞网站建设推广公司
  • 网站建设技术招聘北京百度竞价