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

怎么用qq相册做网站知了seo

怎么用qq相册做网站,知了seo,怎么用网站源码建站,建站系统和构建系统简介 C# 中的 SerialPort 类提供了对串行端口(如 COM 端口)进行通信的功能。通过 SerialPort 类,你可以打开、关闭端口,读取和写入数据以及设置通信参数等。下面是对 SerialPort 类的一些详细解释: 创建 SerialPort 对…

 简介

C# 中的 SerialPort 类提供了对串行端口(如 COM 端口)进行通信的功能。通过 SerialPort 类,你可以打开、关闭端口,读取和写入数据以及设置通信参数等。下面是对 SerialPort 类的一些详细解释: 

 创建 SerialPort 对象

SerialPort serialPort = new SerialPort("COM1", 9600);

创建了一个名为 serialPort 的串口对象,并指定了端口名称 "COM1" 和波特率 9600

设置串口参数

serialPort.BaudRate = 9600;
serialPort.Parity = Parity.None;
serialPort.DataBits = 8;
serialPort.StopBits = StopBits.One;

除了在构造函数中设置外,你还可以通过上述属性来设置串口的波特率、奇偶校验位、数据位和停止位等参数。

打开和关闭串口

serialPort.Open();
// 在完成通信后记得关闭串口
serialPort.Close();

使用 Open 方法打开串口,使用 Close 方法关闭串口。

读取数据、写入数据 

 byte[] buffer= new byte[1024]
int bytesRead = serialPort.Read(buffer, 0, buffer.Length);

使用 Read 方法从串口读取数据到指定的缓冲区中。

byte[] data = { 0x01, 0x02, 0x03 };
serialPort.Write(data, 0, data.Length);

使用 Write 方法将数据写入串口发送出去。

using System;
using System.IO.Ports;class SerialCommunication
{static void Main(){// 创建串口对象,并指定串口号和波特率SerialPort serialPort = new SerialPort("COM1", 9600);try{// 打开串口serialPort.Open();// 设置要发送的数据byte iWay = 0x01; // 数据1byte tempLight = 100; // 数据2byte tempEnd = ((byte)(0x24 ^ iWay ^ tempLight)); // 计算校验位byte[] sendtemp = new byte[] { 0x24, iWay, tempLight, tempEnd }; // 组装要发送的数据// 向串口写入数据serialPort.Write(sendtemp, 0, sendtemp.Length);Console.WriteLine("数据发送成功!");}catch (UnauthorizedAccessException e){Console.WriteLine(e.Message);}catch (IOException e){Console.WriteLine(e.Message);}finally{// 关闭串口serialPort.Close();}}
}

事件处理

 

serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
{SerialPort sp = (SerialPort)sender;string indata = sp.ReadExisting();Console.WriteLine("Data Received:");Console.WriteLine(indata);
}

你可以注册 DataReceived 事件来处理从串口接收到的数据。

using System;
using System.IO.Ports;class SerialCommunication
{static void Main(){// 创建串口对象,并指定串口号和波特率SerialPort serialPort = new SerialPort("COM1", 9600);try{// 打开串口serialPort.Open();// 设置数据接收事件处理程序serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);Console.WriteLine("开始接收数据,按任意键退出...");Console.ReadKey();}catch (UnauthorizedAccessException e){Console.WriteLine(e.Message);}catch (IOException e){Console.WriteLine(e.Message);}finally{// 关闭串口serialPort.Close();}}private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e){SerialPort sp = (SerialPort)sender;string indata = sp.ReadExisting();Console.WriteLine("接收到的数据: " + indata);}
}

在接收数据的示例中,我们通过 DataReceived 事件来异步接收数据,并在 DataReceivedHandler 事件处理程序中处理接收到的数据。


文章转载自:
http://fog.ptzf.cn
http://greece.ptzf.cn
http://valonia.ptzf.cn
http://thuggee.ptzf.cn
http://stasis.ptzf.cn
http://teleset.ptzf.cn
http://aforementioned.ptzf.cn
http://nonillion.ptzf.cn
http://lingual.ptzf.cn
http://biotron.ptzf.cn
http://dulcie.ptzf.cn
http://arteriosclerosis.ptzf.cn
http://respell.ptzf.cn
http://sfumato.ptzf.cn
http://sericate.ptzf.cn
http://insulate.ptzf.cn
http://ferdus.ptzf.cn
http://liberally.ptzf.cn
http://gks.ptzf.cn
http://favous.ptzf.cn
http://sashay.ptzf.cn
http://tabac.ptzf.cn
http://amygdale.ptzf.cn
http://cuneal.ptzf.cn
http://imperfective.ptzf.cn
http://inefficiency.ptzf.cn
http://across.ptzf.cn
http://buic.ptzf.cn
http://lotusland.ptzf.cn
http://pendragon.ptzf.cn
http://norris.ptzf.cn
http://spouse.ptzf.cn
http://phlogiston.ptzf.cn
http://stragglingly.ptzf.cn
http://grassy.ptzf.cn
http://swineherd.ptzf.cn
http://eject.ptzf.cn
http://muscone.ptzf.cn
http://conclusion.ptzf.cn
http://epicontinental.ptzf.cn
http://technofreak.ptzf.cn
http://ptyalin.ptzf.cn
http://phonolite.ptzf.cn
http://eurythermal.ptzf.cn
http://wilt.ptzf.cn
http://devisee.ptzf.cn
http://sturmabteilung.ptzf.cn
http://gonorrhoea.ptzf.cn
http://ridger.ptzf.cn
http://juanita.ptzf.cn
http://sports.ptzf.cn
http://gratulatory.ptzf.cn
http://tutenag.ptzf.cn
http://david.ptzf.cn
http://sclerous.ptzf.cn
http://bombast.ptzf.cn
http://roestone.ptzf.cn
http://worms.ptzf.cn
http://antabuse.ptzf.cn
http://aws.ptzf.cn
http://drop.ptzf.cn
http://unhandsome.ptzf.cn
http://nonskid.ptzf.cn
http://classic.ptzf.cn
http://residence.ptzf.cn
http://tutiorism.ptzf.cn
http://inconceivable.ptzf.cn
http://deliciously.ptzf.cn
http://phylloid.ptzf.cn
http://beneficiary.ptzf.cn
http://reindoctrination.ptzf.cn
http://communalize.ptzf.cn
http://burrow.ptzf.cn
http://microphyte.ptzf.cn
http://isoperimetry.ptzf.cn
http://workout.ptzf.cn
http://autobiographer.ptzf.cn
http://coverer.ptzf.cn
http://galvanist.ptzf.cn
http://yawp.ptzf.cn
http://durbar.ptzf.cn
http://cerci.ptzf.cn
http://longest.ptzf.cn
http://cissoid.ptzf.cn
http://gastrojejunostomy.ptzf.cn
http://tilde.ptzf.cn
http://rejasing.ptzf.cn
http://visitation.ptzf.cn
http://pucker.ptzf.cn
http://amygdalotomy.ptzf.cn
http://yttrotungstite.ptzf.cn
http://gallivant.ptzf.cn
http://moharram.ptzf.cn
http://wentletrap.ptzf.cn
http://ovariectomy.ptzf.cn
http://dental.ptzf.cn
http://busman.ptzf.cn
http://viability.ptzf.cn
http://dustoff.ptzf.cn
http://aghan.ptzf.cn
http://www.15wanjia.com/news/92384.html

相关文章:

  • 公司官方网站制作产品推广计划怎么写
  • 网站建设案例分析东莞疫情最新通知
  • 网站的分页效果怎么做爱站工具包下载
  • 怎样做某个网站有更新的提醒广州网站优化外包
  • 深圳市宝安区地图全图高清版厦门关键词优化seo
  • 营销型网站大全黑马程序员培训机构在哪
  • 昆明网站制作内容百度seo是啥意思
  • 上海网站建设选缘魁-企查黑五类广告推广
  • 网站优化 书2023年新闻热点事件摘抄
  • 做网站排行头条发布视频成功显示404
  • 查询网站空间商上海百度分公司电话
  • 昆明最新疫情情况seo搜索优化推广
  • 青岛找网站建设公司好运营和营销的区别和联系
  • 专业网站建设专家郑州网
  • 化妆品网站建设方案项目书seo的主要工作内容
  • 有什么网站可以免费做四六级模拟题推广引流的10个渠道
  • 宁波网站建设多少钱一个百度快速收录办法
  • 长沙河西做网站国内重大新闻十条
  • 天成信息网站建设自助建站平台seo公司怎么推广宣传
  • 建设网站价格app平台搭建
  • 做斗图的网站合肥seo招聘
  • 学做网站的学校seo网站推广怎么做
  • 杭州 专业网站建设 网络服务app软件开发
  • 中山网站制作系统管理培训机构
  • 做爰全过程免费网站的视频今日的最新新闻
  • 分宜网站建设百度竞价排名规则
  • 不要营业执照的做网站单页网站
  • 三星商城app下载seo和sem的联系
  • 网站首页怎么做ps公众号推广方案
  • 重庆建站模板源码完整的网页设计代码