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

在哪个网站可以做图文合并企业网站分析报告

在哪个网站可以做图文合并,企业网站分析报告,连云港建设局网站助理,手机网站焦点图仅作自己学习使用 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.hkea.cn/news/795663/

相关文章:

  • 怎么选择无锡网站建设虚拟主机搭建网站
  • 做原油期货关注什么网站搜索引擎优化是做什么
  • 微信小程序怎么制作游戏安卓优化清理大师
  • 胶南做网站初学者做电商怎么入手
  • 网站为什么要维护佛山网络营销推广
  • 国企网站建设报告怎么建造自己的网站
  • 免费做司考真题的网站余姚网站如何进行优化
  • 如何网站开发1688网站
  • 丽水专业网站建设价格青岛网站优化
  • 网站开发专业培训学校百度推广登录官网入口
  • 贵阳做网站公司网站热度查询
  • 做课件最好的素材网站考拉seo
  • 网站建设玖首选金手指seo网站优化收藏
  • 台州卓远做网站好不好广州seo教程
  • dz网站数据备份bt磁力猪
  • github 可以做网站吗360seo
  • 杭州 企业门户网站建设爱链
  • dj那个网站做的好长沙公司网络营销推广
  • 设计师培训招生视频黑帽seo联系方式
  • 做网上贸易哪个网站好西宁网站seo
  • 电子烟网站建设杯子软文营销300字
  • 广州企业网站制作怎么做营销推广
  • 网站建设服务器在香港郑州网站建设专业乐云seo
  • 河北建设工程交易信息网海口关键词优化报价
  • 全国网站建设公司有多少家微信朋友圈广告投放收费标准
  • 免费做网站公司黑帽seo排名技术
  • apk连接wordpress上海seo
  • 企业建网站租用服务器好还是买一个好石家庄网站关键词推广
  • wordpress文件解析外贸网站优化
  • 建设工程竣工备案网站百度保障中心人工电话