📄 cwp51.htm
字号:
<!-- saved from url=(0007)http:// -->
<HTML><HEAD><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><TITLE>WJ.MPR.Reader.MPRMsg</TITLE><LINK REL=STYLESHEET HREF="../CommentReport.css" TYPE="text/css"></HEAD><BODY topmargin=0 rightmargin=0 leftmargin=0 style="background-image: url(../titletile.jpg); background-repeat:repeat-x; background-position: 0 0;" ><DIV CLASS="PageHeading">WJ.MPR.Reader.MPRMsg Class</DIV><DIV CLASS="Description">
The Message class bundles a host-to-reader request and the reader-to-host responses
for a single command exchange.
- The Request Frame is stored as an MPRFrame, txFrame.
- The Response Frames are stored as an MPRFrameList, rxFrames.
- Stores various forms of Status Information
- MPR API status or errors
- Serial Communications errors
- Message Timeouts
- Does the work of waiting for a single "Complete" Request Frame to arrive.
- The .Receive method is where the thread blocks while waiting for the serial port
thread to wake it up via one of three methods:
1) .AddRxFrame()
2) .CommError()
3) .Timeout()
<P></DIV><IMG src="../GradLeft.jpg" width=7 height=378 alt="" border="0" style="position:absolute; left:10; top:18;z-Index:2"><IMG src="../GradTop.jpg" width=352 height=7 alt="" border="0" align="top" style="position:absolute; left:10; top:18; z-index:1"><DIV CLASS="Remarks"><SPAN CLASS="RemarkHdrX">Access: </SPAN>Public</DIV><DIV CLASS="Remarks"><SPAN CLASS="RemarkHdrX">Base Classes: </SPAN>Object</DIV><TABLE CLASS="InfoTable" cellpadding=0 cellspacing=0><TR height=20><TD width=20> </TD><TD valign=top align=left width=9 bgcolor="#cccc66"><IMG SRC="../graycorner.jpg" align=top></TD><TD CLASS="TableLightLabel" WIDTH=206>Members</TD><TD CLASS="TableLightLabel" >Description</TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP117.HTM" TARGET="CNTFRAME">txFrame</A></TD><TD CLASS="TableLightDesc"> </TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP118.HTM" TARGET="CNTFRAME">TxFrame</A></TD><TD CLASS="TableLightDesc">
The Request Frame.
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP120.HTM" TARGET="CNTFRAME">rxFrames</A></TD><TD CLASS="TableLightDesc"> </TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP121.HTM" TARGET="CNTFRAME">RxFrames</A></TD><TD CLASS="TableLightDesc">
A list of Response Frames.
A single response could be composed of multiple "InProgress" Frames,
but always a single "Complete" Frame.
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP123.HTM" TARGET="CNTFRAME">error</A></TD><TD CLASS="TableLightDesc"> </TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP125.HTM" TARGET="CNTFRAME">Error</A></TD><TD CLASS="TableLightDesc">
Any ErrorCode associated with this MPRMsg.
If none, then ErrorCode.NoError.
ErrorCodes are returned when the Status Byte
of a response Frame = StatusCode.Error (0xFF).
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP127.HTM" TARGET="CNTFRAME">stat</A></TD><TD CLASS="TableLightDesc"> </TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP129.HTM" TARGET="CNTFRAME">Status</A></TD><TD CLASS="TableLightDesc">
The Response Status of this MPRMsg:
NoStatus, MsgRcvd, OK, or the source of an error condition.
<see cref="RspStatus"/>
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP131.HTM" TARGET="CNTFRAME">databytes</A></TD><TD CLASS="TableLightDesc"> </TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP132.HTM" TARGET="CNTFRAME">DataBytes</A></TD><TD CLASS="TableLightDesc">
The accumulated bytes of all Response Frames.
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP134.HTM" TARGET="CNTFRAME">MsgRcvd</A></TD><TD CLASS="TableLightDesc">
A synchronization variable for signalling the end of
response frame reception, either due to an error,
a timeout, or the correct number of bytes received.
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP135.HTM" TARGET="CNTFRAME">msgcnt</A></TD><TD CLASS="TableLightDesc"> </TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP136.HTM" TARGET="CNTFRAME">msgID</A></TD><TD CLASS="TableLightDesc"> </TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP137.HTM" TARGET="CNTFRAME">MsgID</A></TD><TD CLASS="TableLightDesc">
A static running total of all MPRMsgs sent since the first
MPRMsg was instantiated.
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP139.HTM" TARGET="CNTFRAME">MPRMsg</A></TD><TD CLASS="TableLightDesc">
Construct a new MPRMsg with the given command and parameters.
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP140.HTM" TARGET="CNTFRAME">AddRxFrame</A></TD><TD CLASS="TableLightDesc">
Called by MPRComm when a response frame has been received.
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP141.HTM" TARGET="CNTFRAME">commErrorString</A></TD><TD CLASS="TableLightDesc">
A string describing any communication errors that may have occured.
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP142.HTM" TARGET="CNTFRAME">CommError</A></TD><TD CLASS="TableLightDesc">
called by MPRComm when a comm error occurs
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP143.HTM" TARGET="CNTFRAME">Timeout</A></TD><TD CLASS="TableLightDesc">
called by MPRComm when a message times out
<P></TD><TD width=20> </TD></TR><TR height=20><TD width=20> </TD><TD CLASS="TableLightDesc"> </TD><TD CLASS="TableLightDesc"><A HREF="CWP144.HTM" TARGET="CNTFRAME">Receive</A></TD><TD CLASS="TableLightDesc">
Response Frame Receiver.
Waits on an AutoResetEvent until the end of a response frame reception.
- This can be either successfull completion of a frame.
- A Timeout while waiting for a response that never arrives.
- A communications error.
If not an error,
Process each received frame:
if CRC errors return RspStatus.ErrorComm
if StatusCode.Complete
Add rxFrame.Data to databytes
return RspStatus.OK
if StatusCode.Error
record error
return RspStatus.ErrorRsp
if StatusCode.InProgress
Add rxFrame.Data to databytes
and keep looking for more frames.
<P></TD><TD width=20> </TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -