/******************************************************************************* * * * Copyright 2010 Rheinmetall Canada Inc. * * * * No part of this document may be reproduced, stored in * * a retrieval system, or transmitted, in any form or by any means, * * electronic, mechanical, photocopying, recording, or otherwise, * * without the prior written permission of Rheinmetall Canada Inc. * * * *******************************************************************************/ /* Description: This is a template file for standard C code file. */ /* ************************************************************************** */ /* ¤Revision: 000 20100616 JFM, Original version. ### YYYYMMDD Initial, Bug Identification Change description. */ /* ************************************************************************** */ /* Includes */ #include "define.h" #include "Util.h" #include #include #include "PrintfServer.h" //#include "Watchdog.h" /* ************************************************************************** */ /* Local variables */ #ifdef ENABLE_DEBUG_LOG char acDebugLog[DEBUG_LOG_SIZE][100]; int iLogIndex = 0; int iWrapCntr = 0; #endif //void _mon_putc(char c); //override from stdio to redirect stdout //----------------------------------------------------------------------------- //void _mon_putc(char c) //{ // TelnetPutPrintf(c); //} //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- short SwapEndianShort(short p_sData) { return (((p_sData & 0xFF00) >> 8) | ((p_sData & 0x00FF) << 8)); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- int SwapEndianInt(int p_iData) { return (((p_iData & 0xFF000000) >> 24) | ((p_iData & 0x00FF0000) >> 8) | ((p_iData & 0x0000FF00) << 8) | ((p_iData & 0x000000FF) << 24)); } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- #ifdef ENABLE_DEBUG_LOG char* GetDebugLogPtr(void) { char *pcPtr; if(iLogIndex == DEBUG_LOG_SIZE) { iLogIndex = 0; iWrapCntr++; } memset(&acDebugLog[iLogIndex][0],0,sizeof(acDebugLog[iLogIndex])); pcPtr = &acDebugLog[iLogIndex][0]; iLogIndex++; return pcPtr; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- void ClearDebugLog(void) { int i; for(i = 0; i < DEBUG_LOG_SIZE; i++) { memset(&acDebugLog[i][0],0,sizeof(acDebugLog[i])); } iLogIndex = 0; iWrapCntr = 0; } #endif //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- int ConvertIntToStrLeadingZero(char* p_pcString, unsigned int p_iChar, int digit) { char temp[8]; int i=0; sprintf(temp, "%X", p_iChar); //itoa(p_cChar,temp,radix); if(p_iChar < 0xF) { for (i=0; i=0; i--) { if (i==p_iSize-1) { uiValue = p_pcString[i] - 0x30; } else { for (j=i; j<=p_iSize-2; j++) uiFactor *= 16; uiValue += (p_pcString[i] - 0x30) * uiFactor; } } } else if (p_iRadix == 10) { for (i=0; i