Index: APIHeader/MarshallerFrame.h =================================================================== --- APIHeader/MarshallerFrame.h (revision 5795) +++ APIHeader/MarshallerFrame.h (working copy) @@ -48,6 +48,7 @@ #define MARSHALLER_DRV_METHODID_ENUMCHANNELS 0x00000006 /*!< Driver Object: xDriverEnumChannels */ #define MARSHALLER_DRV_METHODID_OPENCHANNEL 0x00000008 /*!< Driver Object: xDriverOpenChannel */ #define MARSHALLER_DRV_METHODID_OPENSYSDEV 0x00000009 /*!< Driver Object: xDriverSysDeviceOpen */ +#define MARSHALLER_DRV_METHODID_RESTARTDEVICE 0x00000010 /*!< Driver Object: xDriverRestartDevice */ #define MARSHALLER_SYSDEV_METHODID_CLOSE 0x00000001 /*!< Sysdevice Object: xSysdeviceClose */ #define MARSHALLER_SYSDEV_METHODID_INFO 0x00000002 /*!< Sysdevice Object: xSysdeviceInfo */ @@ -244,6 +245,23 @@ } DRV_ENUMCHANNELS_REQ_T, *PDRV_ENUMCHANNELS_REQ_T; +/*****************************************************************************/ +/*! Driver - xDriverRestartDevice request */ +/*****************************************************************************/ +typedef struct DRV_RESTARTDEVICE_REQ_DATA_Ttag +{ + char abBoardName[CIFx_MAX_INFO_NAME_LENTH]; + +} DRV_RESTARTDEVICE_REQ_DATA_T, *PDRV_RESTARTDEVICE_REQ_DATA_T; + +typedef struct DRV_RESTARTDEVICE_REQ_Ttag +{ + MARSHALLER_DATA_FRAME_HEADER_T tHeader; + DRV_RESTARTDEVICE_REQ_DATA_T tData; + +} DRV_RESTARTDEVICE_REQ_T, *PDRV_RESTARTDEVICE_REQ_T; + + /***************************************************************************** ____ _ _ / ___| _ _ ___ __| | ___ __ __ (_) ___ ___ Index: cifxapi.c =================================================================== --- cifxapi.c (revision 5795) +++ cifxapi.c (working copy) @@ -384,31 +384,54 @@ ******************************************************************************/ int32_t APIENTRY xDriverRestartDevice(CIFXHANDLE hDriver, char* szBoardName, void* pvData) { - int32_t lRet = CIFX_NO_ERROR; - int fCloseDriver = 0; + int32_t lRet = CIFX_NO_ERROR; + CIFX_TRANSPORT_DEVICE_INST_T tnetXTransportDevice = {0}; + CIFX_DRV_FUNCTION_TABLE_T* ptCifXFctTable = NULL; - UNREFERENCED_PARAMETER( pvData); + if ((g_ptCifXDrvInfo == NULL) || (g_ptCifXDrvInfo->fInitialized == 0)) + { + return CIFX_DRV_NOT_INITIALIZED; + } else if (g_ptCifXDrvInfo != (CIFX_DRIVER_INFO_T*)hDriver) + { + return CIFX_INVALID_HANDLE; + } - if(NULL == hDriver) + /* first search for the requested device */ + if (NXT_NO_ERROR != netXTransportGetDeviceHandle( szBoardName, &tnetXTransportDevice.hNetXTransportDeviceHandle)) { - lRet = xDriverOpen(&hDriver); - fCloseDriver = 1; + lRet = CIFX_INVALID_BOARD; + /* if the device exists, get the function pointer table of the translations-layer, the device is 'talking' (rcXPacket (0x100) or Marshaller (0x200)) */ + } else if (NXT_NO_ERROR != netXTransportGetTLFctTableByDevice( tnetXTransportDevice.hNetXTransportDeviceHandle, &tnetXTransportDevice.tTLFctTable)) + { + lRet = CIFX_INVALID_BOARD; + } else if (NULL == tnetXTransportDevice.tTLFctTable.pvTranslationLayerFunctionTable) + { + lRet = CIFX_INVALID_BOARD; + } else + { + tnetXTransportDevice.ptCifXFctTable = tnetXTransportDevice.tTLFctTable.pvTranslationLayerFunctionTable; + ptCifXFctTable = tnetXTransportDevice.tTLFctTable.pvTranslationLayerFunctionTable; + lRet = CIFX_NO_ERROR; } - if(CIFX_NO_ERROR == lRet) + if (lRet == CIFX_NO_ERROR) { - CIFXHANDLE hSysdevice = NULL; + lRet = CIFX_FUNCTION_NOT_AVAILABLE; - /* Open Sysdevice -> connect device, verify device is available */ - if(CIFX_NO_ERROR == (lRet = xSysdeviceOpen( hDriver, szBoardName, &hSysdevice))) + /* Before transmitting any data check if the connection is already available (if so, netXTransportAttachDevice() */ + /* will lock the connection resources until we call netXTransportDetachDevice() or an error occurs). */ + if (0 == netXTransportAttachDevice( tnetXTransportDevice.hNetXTransportDeviceHandle)) + return CIFX_INVALID_HANDLE; + + if (ptCifXFctTable->pfnxDriverRestartDevice) { - /* Reset device. Use interface specific reset timeout */ - lRet = xSysdeviceReset( hSysdevice, 10000); - xSysdeviceClose( hSysdevice); + if (CIFX_NO_ERROR == (lRet = ptCifXFctTable->pfnxDriverRestartDevice( (CIFXHANDLE)&tnetXTransportDevice, szBoardName, NULL))) + { + } } + /* Notify netXTransport-Layer that all connection related resources are now free */ + netXTransportDetachDevice( tnetXTransportDevice.hNetXTransportDeviceHandle); } - if(fCloseDriver) - xDriverClose( hDriver); return lRet; } Index: cifXAPI.h =================================================================== --- cifXAPI.h (revision 5795) +++ cifXAPI.h (working copy) @@ -140,6 +140,7 @@ PFN_XDRIVERENUMBOARDS pfnxDriverEnumBoards; PFN_XDRIVERENUMCHANNELS pfnxDriverEnumChannels; PFN_XDRIVERMEMORYPOINTER pfnxDriverMemoryPointer; + PFN_XDRIVERRESTARTDEVICE pfnxDriverRestartDevice; PFN_XSYSDEVICEOPEN pfnxSysdeviceOpen; PFN_XSYSDEVICECLOSE pfnxSysdeviceClose; PFN_XSYSDEVICERESET pfnxSysdeviceReset; Index: TL_Marshaller.c =================================================================== --- TL_Marshaller.c (revision 5795) +++ TL_Marshaller.c (working copy) @@ -193,12 +193,31 @@ ******************************************************************************/ int32_t APIENTRY DriverRestartDevice(CIFXHANDLE hDriver, char* szBoardName, void* pvData) { - int32_t lRet = CIFX_NO_ERROR; + int32_t lRet = CIFX_INVALID_HANDLE; + CIFX_TRANSPORT_DEVICE_INST_T* ptnetXTransportDev = (CIFX_TRANSPORT_DEVICE_INST_T*)hDriver; + uint8_t* pbRecvData = NULL; + DRV_RESTARTDEVICE_REQ_T tRestartDevREQ = {{{{0}}}}; + MARSHALLER_ENDPOINT_DATA_T* ptDLData = netXTransportGetTLDeviceData( ptnetXTransportDev->hNetXTransportDeviceHandle); - UNREFERENCED_PARAMETER(hDriver); - UNREFERENCED_PARAMETER(szBoardName); - UNREFERENCED_PARAMETER(pvData); + OS_Strncpy(tRestartDevREQ.tData.abBoardName, sizeof(tRestartDevREQ.tData.abBoardName), + ptDLData->tBoardInfo.tBoardInfo.abBoardName, sizeof(ptDLData->tBoardInfo.tBoardInfo.abBoardName)); + GenerateHeader((PMARSHALLER_DATA_FRAME_HEADER_T) &tRestartDevREQ, + ptDLData->tDriverInfo.ulDriverHandle, + MARSHALLER_DRV_METHODID_RESTARTDEVICE, + 1, + sizeof(DRV_RESTARTDEVICE_REQ_DATA_T), + ptDLData->tDriverInfo.fSequenceNrSupport, + ptDLData->tDriverInfo.usSequenceNr); + + lRet = TransferPacket( ptDLData->hTransport, (PMARSHALLER_DATA_FRAME_HEADER_T)&tRestartDevREQ, (PMARSHALLER_DATA_FRAME_HEADER_T*)&pbRecvData, TRANSPORT_TO_TRANSFER); + + if(CIFX_NO_ERROR == lRet) + { + PMARSHALLER_DATA_FRAME_HEADER_T ptCnf = (PMARSHALLER_DATA_FRAME_HEADER_T)pbRecvData; + lRet = VerifyTransferResult(&tRestartDevREQ.tHeader, ptCnf); + OS_Memfree(pbRecvData); + } return lRet; } @@ -3135,6 +3154,7 @@ ptCifXConfig->pfnxDriverEnumBoards = DriverEnumBoards; ptCifXConfig->pfnxDriverEnumChannels = DriverEnumChannels; ptCifXConfig->pfnxDriverMemoryPointer = DriverMemoryPointer; + ptCifXConfig->pfnxDriverRestartDevice = DriverRestartDevice; ptCifXConfig->pfnxSysdeviceOpen = SysdeviceOpen; ptCifXConfig->pfnxSysdeviceClose = SysdeviceClose; ptCifXConfig->pfnxSysdeviceReset = SysdeviceReset; Index: TL_rcXPacket.c =================================================================== --- TL_rcXPacket.c (revision 5795) +++ TL_rcXPacket.c (working copy) @@ -2687,6 +2687,7 @@ ptrcXConfig->pfnxDriverEnumBoards = rcXDriverEnumBoards; ptrcXConfig->pfnxDriverEnumChannels = rcXDriverEnumChannels; ptrcXConfig->pfnxDriverMemoryPointer = rcXDriverMemoryPointer; + ptrcXConfig->pfnxDriverRestartDevice = rcXDriverRestartDevice; /* systme device functions */ ptrcXConfig->pfnxSysdeviceOpen = rcXSysdeviceOpen;