Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #if !defined(_FEDM_NO_PD_SUPPORT)
00033
00034 #include "FedmIscExternalIO.h"
00035 #include "../FEDM_ISCReader.h"
00036 #include "feisc.h"
00037
00038 #if _MSC_VER >= 1400
00039 #pragma warning(disable : 4996)
00040 #endif
00041
00042
00043
00044
00045
00046
00047
00049
00051 FedmIscExternalIO::FedmIscExternalIO(FEDM_ISCReader* pReader, unsigned char ucBusAdr)
00052 : FedmIscPeripheralDevice(pReader, ucBusAdr, FEDM_ISC_PD_PORT_TYPE_RS4XX, FEDM_ISC_PD_TYPE_EXTERNAL_IO)
00053 {
00054 }
00055
00057
00059 FedmIscExternalIO::~FedmIscExternalIO()
00060 {
00061 }
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 int FedmIscExternalIO::SetOutput( FEISC_GPC_OUTPUT* pOutput1,
00077 FEISC_GPC_OUTPUT* pOutput2,
00078 FEISC_GPC_OUTPUT* pOutput3)
00079 {
00080 int iBack = 0;
00081 unsigned char* pData = NULL;
00082 unsigned char ucRecBusAddr = 0x00;
00083 unsigned char ucCmd = 0x00;
00084
00085
00086
00087 if((pOutput1 == NULL) && (pOutput2 == NULL) && (pOutput3 == NULL))
00088 {
00089 FEDM_RETURN(FEDM_ERROR_NULL_POINTER);
00090 }
00091
00092 m_iSendDataLen = 0;
00093
00094
00095 m_ucSendData[0] = 0x01;
00096 m_ucSendData[1] = 0x00;
00097 m_iSendDataLen += 2;
00098 pData = &m_ucSendData[2];
00099 if(pOutput1 != NULL && pOutput1->ucNumber > 0)
00100 {
00101 m_ucSendData[1] += 1;
00102 *pData++ = (pOutput1->ucNumber & 0x0F) | ((pOutput1->ucType << 5) & 0xE0);
00103 *pData++ = (pOutput1->ucMode & 0x03) | ((pOutput1->ucFrequency << 2) & 0x0C);
00104 *pData++ = (pOutput1->uiHoldTime >> 8) & 0xFF;
00105 *pData++ = pOutput1->uiHoldTime & 0xFF;
00106 m_iSendDataLen += 4;
00107 }
00108 if(pOutput2 != NULL && pOutput2->ucNumber > 0)
00109 {
00110 m_ucSendData[1] += 1;
00111 *pData++ = (pOutput2->ucNumber & 0x0F) | ((pOutput2->ucType << 5) & 0xE0);
00112 *pData++ = (pOutput2->ucMode & 0x03) | ((pOutput2->ucFrequency << 2) & 0x0C);
00113 *pData++ = (pOutput2->uiHoldTime >> 8) & 0xFF;
00114 *pData++ = pOutput2->uiHoldTime & 0xFF;
00115 m_iSendDataLen += 4;
00116 }
00117 if(pOutput3 != NULL && pOutput3->ucNumber > 0)
00118 {
00119 m_ucSendData[1] += 1;
00120 *pData++ = (pOutput3->ucNumber & 0x0F) | ((pOutput3->ucType << 5) & 0xE0);
00121 *pData++ = (pOutput3->ucMode & 0x03) | ((pOutput3->ucFrequency << 2) & 0x0C);
00122 *pData++ = (pOutput3->uiHoldTime >> 8) & 0xFF;
00123 *pData++ = pOutput3->uiHoldTime & 0xFF;
00124 m_iSendDataLen += 4;
00125 }
00126
00127
00128
00129 m_iSendProtLen = FEISC_BuildSendProtocol(m_iReaderHnd, m_ucBusAdr, FEISC_SET_OUTPUT_EX, m_ucSendData , m_iSendDataLen, m_ucSendProt, 0);
00130 if(m_iSendProtLen <= 0)
00131 {
00132 FEDM_RETURN(m_iSendProtLen);
00133 }
00134
00135
00136 iBack = FEISC_0x9F_Piggyback_Command(m_pReader->GetReaderHnd(),m_pReader->GetBusAddress(), 0x00, FEDM_ISC_TYPE_ANT_GPC, FEDM_ISC_PD_PORT_TYPE_RS4XX, m_ucSendProt, m_iSendProtLen, m_ucRspProt, &m_iRspProtLen);
00137 if(iBack < 0)
00138 {
00139 FEDM_RETURN(iBack);
00140 }
00141 else if(iBack == 0x20)
00142 {
00143 FEDM_RETURN(iBack);
00144 }
00145
00146
00147 iBack = FEISC_SplitRecProtocol(m_iReaderHnd, m_ucRspProt, m_iRspProtLen, &ucRecBusAddr, &ucCmd, m_ucRspData, &m_iRspDataLen, 0);
00148 if(iBack != 0)
00149 {
00150 FEDM_RETURN(iBack);
00151 }
00152
00153
00154 FEDM_RETURN(FEDM_OK);
00155 }
00156
00157 #endif // #if !defined(_FEDM_NO_PD_SUPPORT)