首页 »DotNet » 虚基类:用C#读取GPS数据的基类 适用于wince操作系统 »正文
虚基类:用C#读取GPS数据的基类 适用于wince操作系统
来源: 发布时间:星期五, 2009年1月9日 浏览:29次 评论:0
using ; using .Runtime.InteropServices; using .Text; BaseStationPDA { GPS { public PortNum; public BaudRate; public ByteSize; public Parity; // 0-4=no,odd,even,mark,space public StopBits; // 0,1,2 = 1, 1.5, 2 public ReadTimeout; //comm port win32 file handle private hComm = -1; public bool Opened = false; //win32 api constants private const u GENERIC_READ = 0x80000000; private const u GENERIC_WRITE = 0x40000000; private const OPEN_EXISTING = 3; private const INVALID_HANDLE_VALUE = -1; [StructLayout( LayoutKind.Sequential )] public struct DCB { //taken from c struct in platform sdk public DCBlength; // ( DCB ) public BaudRate; // 指定当前波特率 current baud rate // these are the c struct bit fields, bit twiddle flag to public fBinary; // 指定是否允许 2进制模式,在windows95中必须主TRUE binary mode, no EOF check public fParity; // 指定是否允许奇偶校验 enable parity checking public fOutxCtsFlow; // 指定CTS是否用于检测发送控制,当为TRUE是CTS为OFF,发送将被挂起. CTS output flow control public fOutxDsrFlow; // 指定CTS是否用于检测发送控制 DSR output flow control public fDtrControl; // DTR_CONTROL_DISABLE值将DTR置为OFF, DTR_CONTROL_ENABLE值将DTR置为ON, DTR_CONTROL_HANDSHAKE允许DTR"握手" DTR flow control type public fDsrSensitivity; // 当该值为TRUE时DSR为OFF时接收字节被忽略 DSR sensitivity public fTXContinueOnXoff; // 指定当接收缓冲区已满,并且驱动已经发送出XoffChar时发送是否停止.TRUE时,在接收缓冲区接收到缓冲区已满字节XoffLim且驱动已经发送出XoffChar中止接收字节的后,发送继续进行. FALSE时,在接收缓冲区接收到代表缓冲区已空字节XonChar且驱动已经发送出恢复发送XonChar的后,发送继续进行.XOFF continues Tx public fOutX; // TRUE时,接收到XoffChar的后便停止发送接收到XonChar的后将重新开始 XON/XOFF out flow control public fInX; // TRUE时,接收缓冲区接收到代表缓冲区满XoffLim的后,XoffChar发送出去接收缓冲区接收到代表缓冲区空XonLim的后,XonChar发送出去 XON/XOFF in flow control public fErrorChar; // 该值为TRUE且fParity为TRUE时,用ErrorChar 成员指定代替奇偶校验接收 enable error replacement public fNull; // eTRUE时,接收时去掉空(0值)字节 enable null stripping public fRtsControl; // RTS flow control /*RTS_CONTROL_DISABLE时,RTS置为OFF RTS_CONTROL_ENABLE时, RTS置为ON RTS_CONTROL_HANDSHAKE时, 当接收缓冲区小于半满时RTS为ON 当接收缓冲区超过 4分的 3满时RTS为OFF RTS_CONTROL_TOGGLE时, 当接收缓冲区仍有剩余字节时RTS为ON ,否则缺省为OFF*/ public fAbortOnError; // TRUE时,有发生时中止读和写操作 abort _disibledevent=false; ( ss_port.Opened ) ss_port.Close( ); } #endregion
相关文章
读者评论
发表评论
|
|