- 1、本文档共29页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
serialClass(国外英文资料)
serialClass(国外英文资料)
Manipulation, serial ports, including read and write operation, the class can be set up a serial port parameters, sets the receive function, open the serial port, close a serial port resources, after the completion of the operation, be sure to close a serial port, receive serial data, receive data error events, for current all serial ports, the byte type convert hexadecimal string, etc. This serial class has been debugged and can be used:
The view sourceprint? 001 using System;
002 using System. Collections. Generic;
003 using System. The Text;
004 using System. IO. Ports;
005 using System. Globalization;
006 the namespace SerialClass
007 {
008 public class SerialClass
009 {
010 SerialPort _serialPort = null;
011 / / define the delegate
012 public delegate void SerialPortDataReceiveEventArgs (object sender, SerialDataReceivedEventArgs e, byte [] bits);
013 / / define receive data events
014 public event serialportdatargs DataReceived;
015 / / define receive error events
016 / / public event SerialErrorReceivedEventHandler Error;
The 017 / / receive event is valid for false
018 public bool ReceiveEventFlag = false;
019 # region gets the serial name
020 private string protName;
021 public string PortName
022 {
023 get {return _serialPort. }
024 set
025 {
026 _serialPort. PortName = value;
The protName = value;
028}
029}
030 # endregion
031 # region gets bitrates
032 private int baudRate;
033 public int BaudRate
034 {
035 get {return _serialPort. }
Set of 036
037 {
038 _serialport.baudrate = value.
039 baudRate = value;
040}
041}
042 # endregion
The default constructor for region 043
044 / / summary
045 / / / the default constructor, operating COM1, the rate of 9600, no Parity, 8 bytes, COM1 stop bit is 1, 9600, Parity. None, 8, StopBits. One
046 / / summary
047 public SerialClass ()
048 {
049 _serialPort = new SerialPort ();
050}
051 # endregion
052 # region constructors
053 / / summary
054 / / constructor,
055 / / / summary
056 / / param
文档评论(0)