資源簡介
串口操作類(justinio),原始下載版
代碼片段和文件信息
using?System;
using?System.Runtime.InteropServices;
namespace?JustinIO?{
class?CommPort?{
public?string?PortNum;?
public?int?BaudRate;
public?byte?ByteSize;
public?byte?Parity;?//?0-4=nooddevenmarkspace?
public?byte?StopBits;?//?012?=?1?1.5?2?
public?int?ReadTimeout;
//comm?port?win32?file?handle
private?int?hComm?=?-1;
public?bool?Opened?=?false;
?
//win32?api?constants
??private?const?uint?GENERIC_READ?=?0x80000000;
??private?const?uint?GENERIC_WRITE?=?0x40000000;
??private?const?int?OPEN_EXISTING?=?3;
??private?const?int?INVALID_HANDLE_VALUE?=?-1;
[StructLayout(LayoutKind.Sequential)]
public?struct?DCB?{
//taken?from?c?struct?in?platform?sdk?
public?int?DCBlength;???????????//?sizeof(DCB)?
public?int?BaudRate;????????????//?指定當前波特率?current?baud?rate
//?these?are?the?c?struct?bit?fields?bit?twiddle?flag?to?set
public?int?fBinary;??????????//?指定是否允許二進制模式在windows95中必須主TRUE?binary?mode?no?EOF?check?
public?int?fParity;??????????//?指定是否允許奇偶校驗?enable?parity?checking?
public?int?fOutxCtsFlow;??????//?指定CTS是否用于檢測發送控制,當為TRUE是CTS為OFF,發送將被掛起。?CTS?output?flow?control?
public?int?fOutxDsrFlow;??????//?指定CTS是否用于檢測發送控制?DSR?output?flow?control?
public?int?fDtrControl;???????//?DTR_CONTROL_DISABLE值將DTR置為OFF?DTR_CONTROL_ENABLE值將DTR置為ON?DTR_CONTROL_HANDSHAKE允許DTR“握手“?DTR?flow?control?type?
public?int?fDsrSensitivity;???//?當該值為TRUE時DSR為OFF時接收的字節被忽略?DSR?sensitivity?
public?int?fTXContinueOnXoff;?//?指定當接收緩沖區已滿并且驅動程序已經發送出XoffChar字符時發送是否停止。TRUE時,在接收緩沖區接收到緩沖區已滿的字節XoffLim且驅動程序已經發送出XoffChar字符中止接收字節之后,發送繼續進行。 FALSE時,在接收緩沖區接收到代表緩沖區已空的字節XonChar且驅動程序已經發送出恢復發送的XonChar之后,發送繼續進行。XOFF?continues?Tx?
public?int?fOutX;??????????//?TRUE時,接收到XoffChar之后便停止發送接收到XonChar之后將重新開始?XON/XOFF?out?flow?control?
public?int?fInX;???????????//?TRUE時,接收緩沖區接收到代表緩沖區滿的XoffLim之后,XoffChar發送出去接收緩沖區接收到代表緩沖區空的XonLim之后,XonChar發送出去?XON/XOFF?in?flow?control?
public?int?fErrorChar;?????//?該值為TRUE且fParity為TRUE時,用ErrorChar?成員指定的字符代替奇偶校驗錯誤的接收字符?enable?error?replacement?
public?int?fNull;??????????//?eTRUE時,接收時去掉空(0值)字節?enable?null?stripping?
public?int?fRtsControl;?????//?RTS?flow?control?
/*RTS_CONTROL_DISABLE時RTS置為OFF
RTS_CONTROL_ENABLE時?RTS置為ON
RTS_CONTROL_HANDSHAKE時
當接收緩沖區小于半滿時RTS為ON
當接收緩沖區超過四分之三滿時RTS為OFF
RTS_CONTROL_TOGGLE時
當接收緩沖區仍有剩余字節時RTS為ON?否則缺省為OFF*/
public?int?fAbortonerror;???//?TRUE時有錯誤發生時中止讀和寫操作?abort?on?error?
public?int?fDummy2;????????//?未使用?reserved?
public?uint?flags;
public?ushort?wReserved;??????????//?未使用必須為0?not?currently?used?
public?ushort?XonLim;?????????????//?指定在XON字符發送這前接收緩沖區中可允許的最小字節數?transmit?XON?threshold?
public?ushort?XoffLim;????????????//?指定在XOFF字符發送這前接收緩沖區中可允許的最小字節數?transmit?XOFF?threshold?
public?byte?ByteSize;???????????//?指定端口當前使用的數據位 number?of?bits/byte?4-8?
public?byte?Parity;????????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????10671??2007-08-06?17:44??JustinIO.cs
?????文件?????????93??2008-07-22?19:28??說明.txt
-----------?---------??----------?-----??----
????????????????10764????????????????????2
- 上一篇:數據結構實驗-魔王語言-源碼加實驗報告
- 下一篇:RSES 2.2——粗糙集處理軟件
評論
共有 條評論