FedmIscExternalIO.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |                       FedmIscExternalIO.cpp                                           |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright © 2009-2010   FEIG ELECTRONIC GmbH, All Rights Reserved.
00008                                                 Lange Strasse 4
00009                                                 D-35781 Weilburg
00010                                                 Federal Republic of Germany
00011                                                 phone    : +49 6471 31090
00012                                                 fax      : +49 6471 310999
00013                                                 e-mail   : obid-support@feig.de
00014                                                 Internet : http://www.feig.de
00015                                         
00016 Author                  :       Manuel Sahm
00017 Begin                   :       18.02.2010
00018 
00019 Version                 :       03.02.04 / 25.08.2010 / M. Hultsch
00020 
00021 Operation Systems       :       independent
00022 
00023 Function                        :       this class supports the peripheral device called External IO
00024 
00025 
00026 Trademarks:
00027 -----------
00028 OBID®, OBID i-scan® and OBID myAXXESS® are registered Trademarks of FEIG ELECTRONIC GmbH
00029 Other Trademarks: see FEDM.h
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 // class FedmIscExternalIO
00046 //####################################################################
00047 
00049 // Constructor
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 // Destructor
00059 FedmIscExternalIO::~FedmIscExternalIO()
00060 {
00061 }
00062 
00063 
00064 /***************************************************************************
00065   Begin                 :       18.02.2010 / M. Sahm
00066   
00067   Version               :       03.01.01 / 18.02.2010 / M. Sahm
00068 
00069   Function                      :       Set Outputs 
00070 
00071   Parameters            :       FEISC_GPC_OUTPUT structure for Output 1, 2 and 3
00072 
00073   Return value          :       0:              FEDM_OK
00074                                                 <0:             Error Code
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         // Check if at least on pointer is valid
00087         if((pOutput1 == NULL) && (pOutput2 == NULL) && (pOutput3 == NULL))
00088         {
00089                 FEDM_RETURN(FEDM_ERROR_NULL_POINTER);
00090         }
00091 
00092         m_iSendDataLen = 0;
00093 
00094         // Build the "internal" protocol
00095         m_ucSendData[0] = 0x01; // Mode Byte
00096         m_ucSendData[1] = 0x00; // OUT-N
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         // Build Protocol : SetOutput (0x72)
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         // Send Protocol within Piggyback frame
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) // Reader: External Device communication error
00142         {
00143                 FEDM_RETURN(iBack);
00144         }
00145 
00146         // Get Response out of Answer from Protocol 0x72 (SetOutput)
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         // Anaylze the Response Data
00154         FEDM_RETURN(FEDM_OK);
00155 }
00156 
00157 #endif // #if !defined(_FEDM_NO_PD_SUPPORT)


maggie_rfid_drivers
Author(s): Raul Perula-Martinez
autogenerated on Mon Sep 14 2015 03:05:30