/************************************************************************************************** * * @fn RTI_WriteItem * * @brief This API is used to write RTI Configuration Interface parameters * to the Configuration Parameters table, and permitted attributes * to the State Attributes table. * * input parameters * * @param itemId - The Configuration Interface item identifier. * @param len - The length in bytes of the item identifier's data. * @param *pValue - Pointer to buffer where write data is stored. * * input parameters * * None. * * @return RTI_SUCCESS, RTI_ERROR_NOT_PERMITTED, RTI_ERROR_INVALID_INDEX, * RTI_ERROR_INVALID_PARAMETER, RTI_ERROR_UNKNOWN_PARAMETER, * RTI_ERROR_UNSUPPORTED_ATTRIBUTE, RTI_ERROR_OSAL_NV_OPER_FAILED, * RTI_ERROR_OSAL_NV_ITEM_UNINIT, RTI_ERROR_OSAL_NV_BAD_ITEM_LEN * **************************************************************************************************/ rStatus_t RTI_WriteItem( uint8 itemId, uint8 len, uint8 *pValue ) { npiMsgData_t pMsg; // prep Write Item request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_WRITE_ITEM; pMsg.len = 2+len; pMsg.pData[0] = itemId; pMsg.pData[1] = len; // copy the client's data to be sent msg_memcpy( &pMsg.pData[2], pValue, len ); // perform endianness change rtiAttribEConv( itemId, len, &pMsg.pData[2] ); // send Write Item request to NP RTIS synchronously NPI_SendSynchData( &pMsg ); // DEBUG if ( pMsg.pData[0] == RTI_ERROR_SYNCHRONOUS_NPI_TIMEOUT ) { // rtisFatalError( RTI_ERROR_SYNCHRONOUS_NPI_TIMEOUT ); } // DEBUG, test if RNP not lock in boot mode if ( pMsg.subSys == RPC_SYS_BOOT ) { return( 1 ); } // return the status, which is stored is the first byte of the payload return( (rStatus_t)pMsg.pData[0] ); }
/************************************************************************************************** * * @fn RTI_ReadItem * * @brief This API is used to read the RTI Configuration Interface item * from the Configuration Parameters table, the State Attributes * table, or the Constants table. * * input parameters * * @param itemId - The Configuration Interface item identifier. * @param len - The length in bytes of the item identifier's data. * * output parameters * * @param *pValue - Pointer to buffer where read data is placed. * * @return RTI_SUCCESS, RTI_ERROR_NOT_PERMITTED, RTI_ERROR_INVALID_INDEX, * RTI_ERROR_INVALID_PARAMETER, RTI_ERROR_UNKNOWN_PARAMETER, * RTI_ERROR_UNSUPPORTED_ATTRIBUTE, RTI_ERROR_OSAL_NV_OPER_FAILED, * RTI_ERROR_OSAL_NV_ITEM_UNINIT, RTI_ERROR_OSAL_NV_BAD_ITEM_LEN * **************************************************************************************************/ rStatus_t RTI_ReadItem( uint8 itemId, uint8 len, uint8 *pValue ) { npiMsgData_t pMsg; // prep Read Item request // Note: no need to send pValue over the NPI pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_READ_ITEM; pMsg.len = 2; pMsg.pData[0] = itemId; pMsg.pData[1] = len; // send Read Item request to NP RTIS synchronously NPI_SendSynchData( &pMsg ); // DEBUG if ( pMsg.pData[0] == RTI_ERROR_SYNCHRONOUS_NPI_TIMEOUT ) { // rtisFatalError( RTI_ERROR_SYNCHRONOUS_NPI_TIMEOUT ); } // copy the reply data to the client's buffer // Note: the first byte of the payload is reserved for the status msg_memcpy( pValue, &pMsg.pData[1], len ); // perform endianness change rtiAttribEConv( itemId, len, pValue ); // return the status, which is stored is the first byte of the payload return( (rStatus_t)pMsg.pData[0] ); }
//***************************************************************************** // // Write a configuration parameter to the RNP. // // \param ui8ProfileId the application profile to be used for this transaciton. // \param ui8ItemId the identifier of the item to be written. // \param ui8Length the number of bytes to write. // \param pui8Value a pointer to the bytes to be written. // // This function allocates a tRemoTIMsg on the stack and populates with the // fields provided. This message is then copied to the UART buffers and // transmitted via \e NPI_SendSynchData. The \e ui8ItemID is written with the // bytes of data pointed to by \e pui8Data. // // \return Returns \e RTI_SUCCESS or \e RTI_ERROR_NO_RESPONSE. // //***************************************************************************** uint_fast8_t RTI_WriteItemEx(uint_fast8_t ui8ProfileID, uint_fast8_t ui8ItemID, uint_fast8_t ui8Length, const uint8_t *pui8Value) { tRemoTIMsg sMsg; uint_fast8_t ui8Index; // // Initialize the tRemoTIMsg object header information. // Note that version 1.2.1 of the RemoTI stack does not use the profile ID. // A compile time switch is used to determine how the message should be // structured. // sMsg.ui8SubSystem = RPC_SYS_RCAF; #if (defined REMOTI_1_2_1) && (REMOTI_1_2_1 == true) (void) profileId; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_WRITE_ITEM; sMsg.ui8Length = ui8Length + 2; sMsg.pui8Data[0] = ucItemID; sMsg.pui8Data[1] = ui8Length; #else sMsg.ui8CommandID = RTIS_CMD_ID_RTI_WRITE_ITEM_EX; sMsg.ui8Length = ui8Length + 3; sMsg.pui8Data[0] = ui8ProfileID; sMsg.pui8Data[1] = ui8ItemID; sMsg.pui8Data[2] = ui8Length; #endif // // Copy payload data. // for(ui8Index = 0; ui8Index < ui8Length; ui8Index++) { sMsg.pui8Data[ui8Index+3] = pui8Value[ui8Index]; } // // Send the message and interpret the return message. // if(NPI_SendSynchData(&sMsg)) { // // Return Success. // return(RTI_SUCCESS); } // // Return an error to indicate the RNP did not respond before the timeout. // return(RTI_ERROR_NO_RESPONSE); }
//***************************************************************************** // // Wrapper which the application can use to read parameters from the RNP. // // \param ui8ProfileId the application profile associated with the item to // read. // \param ui8ItemId the identifier value for the item to read. // \param ui8Length the length in bytes to be read. // \param pui8Value user provided storage where the item will be stored. // // This function allocates a tRemoTIMsg on the stack and populates with the // fields provided. This message is then copied to the UART buffers and // transmitted as via \e NPI_SendSynchData. If successful the value read is // copied back into the \e pui8Value buffer provided by the caller. If not // successful \e RTI_ERROR_NO_RESPONSE is returned. // // \return Returns \e RTI_SUCCESS or \e RTI_ERROR_NO_RESPONSE. // //***************************************************************************** uint_fast8_t RTI_ReadItemEx(uint8_t ui8ProfileID, uint8_t ui8ItemID, uint8_t ui8Length, uint8_t *pui8Value) { tRemoTIMsg sMsg; uint32_t ui32Index; // // Initialize the remoTI message structure. Depending on the version of the // remoTI stack being used a compile time switch determines which fields are // present and how they are populated. Version 1.2.1 did not include the // ui8ProfileId element. // sMsg.ui8SubSystem = RPC_SYS_RCAF; #if (defined REMOTI_1_2_1) && (REMOTI_1_2_1 == true) (void) ucProfileID; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_READ_ITEM; sMsg.ui8Length = 2; sMsg.pui8Data[0] = ucItemID; sMsg.pui8Data[1] = ui8Length; #else sMsg.ui8CommandID = RTIS_CMD_ID_RTI_READ_ITEM_EX; sMsg.ui8Length = 3; sMsg.pui8Data[0] = ui8ProfileID; sMsg.pui8Data[1] = ui8ItemID; sMsg.pui8Data[2] = ui8Length; #endif // // Send the data. If successful copy the item read to the caller's buffer. if(NPI_SendSynchData(&sMsg)) { // // Copy the read item bytes to the caller's buffer. // for(ui32Index = 0; ui32Index < (sMsg.ui8Length - 1) ; ui32Index++) { pui8Value[ui32Index] = sMsg.pui8Data[ui32Index + 1]; } // // Return with success indicated. // return(RTI_SUCCESS); } // // Return with the no response error condition. // return(RTI_ERROR_NO_RESPONSE); }
/************************************************************************************************** * * @fn NPI_DisconnectReq * * @brief This API is used to ask NPI server to disconnect device. * * input parameters * * None. * * output parameters * * @param *pValue - Pointer to buffer where status is read. * * None. * * @return None. * **************************************************************************************************/ void NPI_DisconnectReq( uint8 *pStatus ) { npiMsgData_t pMsg; // Prepare disconnection request pMsg.subSys = RPC_SYS_SRV_CTRL; pMsg.cmdId = NPI_LNX_CMD_ID_DISCONNECT_DEVICE; pMsg.len = 0; NPI_SendSynchData( &pMsg ); // copy the reply data to the client's buffer // Note: the first byte of the payload is reserved for the status msg_memcpy( pStatus, &pMsg.pData[0], pMsg.len ); }
/************************************************************************************************** * * @fn NPI_ReadVersion * * @brief This API is used to read the NPI server version. * * input parameters * * None. * * output parameters * * None. * * @return None. * **************************************************************************************************/ void NPI_ReadVersionReq( uint8 *pValue ) { npiMsgData_t pMsg; // Prepare Read Version Request pMsg.subSys = RPC_SYS_SRV_CTRL; pMsg.cmdId = NPI_LNX_CMD_ID_VERSION_REQ; pMsg.len = 0; NPI_SendSynchData( &pMsg ); // copy the reply data to the client's buffer // Note: the first byte of the payload is reserved for the status msg_memcpy( pValue, &pMsg.pData[1], 3 ); }
/************************************************************************************************** * * @fn RTI_TestRxCounterGetReq * * @brief This function is used to obtain received packet counter value. * * input parameters * * @param resetFlag - whether or not to reset the counter after reading the value * * output parameters * * None. * * @return counter value * **************************************************************************************************/ RTILIB_API uint16 RTI_TestRxCounterGetReq(uint8 resetFlag) { npiMsgData_t pMsg; // serialize the request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_RX_COUNTER_GET_REQ; pMsg.len = 1; pMsg.pData[0] = resetFlag; // send serialized request to NP RTIS synchronously NPI_SendSynchData( &pMsg ); // return the status, which is stored is the first byte of the payload return (pMsg.pData[0] + ((uint16)pMsg.pData[1] << 8)); }
/************************************************************************************************** * * @fn NPI_ReadParamReq * * @brief This API is used to read NPI server parameters. * * input parameters * * @param paramId - The parameter item identifier. * @param len - The length in bytes of the item identifier's data. * * output parameters * * @param *pValue - Pointer to buffer where read data is placed. * * None. * * @return None. * **************************************************************************************************/ void NPI_ReadParamReq( uint8 paramId, uint8 len, uint8 *pValue ) { npiMsgData_t pMsg; // Prepare parameter request pMsg.subSys = RPC_SYS_SRV_CTRL; pMsg.cmdId = NPI_LNX_CMD_ID_GET_PARAM_REQ; pMsg.len = 2; pMsg.pData[0] = paramId; pMsg.pData[1] = len; NPI_SendSynchData( &pMsg ); // copy the reply data to the client's buffer // Note: the first byte of the payload is reserved for the status msg_memcpy( pValue, &pMsg.pData[1], len ); }
/************************************************************************************************** * * @fn NPI_SetWorkaroundReq * * @brief This API is used to ask NPI server to set workaround. * * input parameters * * None. * * output parameters * * @param item - Workaround ID * @param *pStatus - Pointer to buffer where status is read. * * None. * * @return None. * **************************************************************************************************/ void NPI_SetWorkaroundReq( uint8 workaroundID, uint8 *pStatus ) { npiMsgData_t pMsg; // Prepare workaround request pMsg.subSys = RPC_SYS_SRV_CTRL; // pMsg.cmdId = NPI_LNX_CMD_ID_WORKAROUND; pMsg.cmdId = 2; pMsg.len = 2; pMsg.pData[0] = workaroundID; pMsg.pData[1] = *pStatus; NPI_SendSynchData( &pMsg ); // copy the reply data to the client's buffer // Note: the first byte of the payload is reserved for the status msg_memcpy( pStatus, &pMsg.pData[0], pMsg.len ); }
/************************************************************************************************** * * @fn NPI_ConnectReq * * @brief This API is used to ask NPI server to connect to device. * * input parameters * * @param *pStatus - Pointer to device to connect to * @param length - length of device path * @param devPath - device path string * * output parameters * * @param *pStatus - Pointer to buffer where status is read. * * None. * * @return None. * **************************************************************************************************/ void NPI_ConnectReq( uint8 *pStatus, uint8 length, uint8 *devPath ) { npiMsgData_t pMsg; // Prepare connection request pMsg.subSys = RPC_SYS_SRV_CTRL; pMsg.cmdId = NPI_LNX_CMD_ID_CONNECT_DEVICE; pMsg.len = length + 2; pMsg.pData[0] = *pStatus; pMsg.pData[1] = length; memcpy(pMsg.pData + 2, devPath, length); NPI_SendSynchData( &pMsg ); // copy the reply data to the client's buffer // Note: the first byte of the payload is reserved for the status msg_memcpy( pStatus, &pMsg.pData[0], pMsg.len ); }