Пример #1
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CreateTestFile(char *Filename, int SizeInKs, boolean LeaveOpen)
{
    int FileHandle;
    int i;

    FileHandle = OS_creat(Filename, OS_READ_WRITE);
    if (FileHandle >= OS_SUCCESS)
    {
        if (FillBuffer[0] == 0)
        {
            CFE_PSP_MemSet(FillBuffer, 0xA5, sizeof(FillBuffer));
        }

        for (i = 0; i < SizeInKs; i++)
        {
            OS_write(FileHandle, FillBuffer, sizeof(FillBuffer));
        }

        if (LeaveOpen)
        {
            OpenFileHandle = FileHandle;
        }
        else
        {
            OS_close(FileHandle);
        }
    }
    else
    {
        UTF_put_text("\nERROR CREATING TEST FILE %s\n", Filename);
    }

    return;

} /* End of CreateTestFile() */
Пример #2
0
/* --------------------------------------------------------------------------------------
Name: OS_ShellOutputToFile

Purpose: Takes a shell command in and writes the output of that command to the specified file

Returns: OS_SUCCESS if success
         OS_FS_ERR_INVALID_FD if the file descriptor passed in is invalid
         OS_FS_ERROR if Error
---------------------------------------------------------------------------------------*/
int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd)
{
    char LocalCmd [OS_MAX_CMD_LEN];
    int32 Result;
    int32 ReturnCode = OS_FS_SUCCESS;
    int32 fdCmd;
    char * shellName;

    /*
    ** Check parameters
    */
    if (Cmd == NULL)
    {
        return(OS_FS_ERR_INVALID_POINTER);
    }

    /* Make sure the file descriptor is legit before using it */
    if (OS_fd < 0 || OS_fd >= OS_MAX_NUM_OPEN_FILES || OS_FDTable[OS_fd].IsValid == FALSE)
    {
        ReturnCode = OS_FS_ERR_INVALID_FD;
    }
    else
    {
        /* Create a file to write the command to (or write over the old one) */
        fdCmd = OS_creat(OS_SHELL_CMD_INPUT_FILE_NAME,OS_READ_WRITE);

        if (fdCmd < OS_FS_SUCCESS)
        {
            Result = OS_FS_ERROR;
        }

        else
        {
            /* copy the command to the file, and then seek back to the beginning of the file */

            strncpy(LocalCmd,Cmd, OS_MAX_CMD_LEN);
            OS_write(fdCmd,Cmd, strlen(LocalCmd));
            OS_lseek(fdCmd,0,OS_SEEK_SET);

            /* Create a shell task the will run the command in the file, push output to OS_fd */
            Result = shellGenericInit("INTERPRETER=Cmd",0,NULL, &shellName, FALSE, FALSE, OS_FDTable[fdCmd].OSfd,	OS_FDTable[OS_fd].OSfd, OS_FDTable[OS_fd].OSfd);

            /* Wait for the command to terminate */
           do{
              taskDelay(sysClkRateGet());
            }while (taskNameToId(shellName) != ERROR);

            /* Close the file descriptor */
            OS_close(fdCmd);

        } /* else */

        if (Result != OK)
        {
             ReturnCode =  OS_FS_ERROR;
        }

    }
    return ReturnCode;
}/* end OS_ShellOutputToFile */
Пример #3
0
/******************************************************************************
** Function: DumpTableToFile
**
*/
static boolean DumpTableToFile(const char* FileName, const char* FileDescr, DumpTableFuncPtr DumpTableFunc)
{

   CFE_FS_Header_t  CfeStdFileHeader;
   int32            FileHandle;
   int32            FileStatus;
   boolean          RetStatus = FALSE;

   /* Create a new dump file, overwriting anything that may have existed previously */
   FileHandle = OS_creat(FileName, OS_WRITE_ONLY);

   if (FileHandle >= OS_FS_SUCCESS)
   {
      /* Initialize the standard cFE File Header for the Dump File */
      CfeStdFileHeader.SubType = 0x74786574;
      strcpy(&CfeStdFileHeader.Description[0], FileDescr);

      /* Output the Standard cFE File Header to the Dump File */
      FileStatus = CFE_FS_WriteHeader(FileHandle, &CfeStdFileHeader);

      if (FileStatus == sizeof(CFE_FS_Header_t))
      {
         (DumpTableFunc)(FileHandle);
         RetStatus = TRUE;

      } /* End if successfully wrote file header */
      else
      {
          CFE_EVS_SendEvent(TBLMGR_WRITE_CFE_HDR_ERR_EID,
                            CFE_EVS_ERROR,
                            "Error writing cFE File Header to '%s', Status=0x%08X",
                            FileName, FileStatus);

      }
   } /* End if file create */
   else
   {

        CFE_EVS_SendEvent(TBLMGR_CREATE_MSG_DUMP_ERR_EID,
                          CFE_EVS_ERROR,
                          "Error creating CDS dump file '%s', Status=0x%08X",
                          FileName, FileHandle);

    }

   OS_close(FileHandle);

   return RetStatus;

} /* End of DumpTableToFile() */
Пример #4
0
void Create_Input_File0(void)
{
/*	FILE *to; */
	int8 values[4] = {5,10,15,20};
	char tableName[30];
	CFE_FS_Header_t    StdFileHeader;
    CFE_TBL_File_Hdr_t TblFileHeader;
    int32              FileDescriptor;
    int32              Status;
    int32              EndianCheck = 0x01020304;

/*	to = fopen("/tt_table_values0.dat",  "wb");
	if (to == 0)
	{
		UTF_error("Error opening file /tt_table_initial_values.dat to write\n");
		UTF_exit();
	}

	fwrite(values, sizeof(int8), 4, to);	
	
	fclose(to); */

	strcpy (tableName, "TT.FourNumbers");

	/* Clear Header of any garbage before copying content */
    CFE_PSP_MemSet(&StdFileHeader, 0, sizeof(CFE_FS_Header_t));
    CFE_PSP_MemSet(&TblFileHeader, 0, sizeof(CFE_TBL_File_Hdr_t));

	/* Create a new dump file, overwriting anything that may have existed previously */
    FileDescriptor = OS_creat("/ram/tt_table_values0.dat", OS_WRITE_ONLY);

    if (FileDescriptor >= OS_FS_SUCCESS)
    {
        /* Initialize the standard cFE File Header for the Dump File */
       	StdFileHeader.SubType = CFE_FS_TBL_IMG_SUBTYPE;
       	strcpy(&StdFileHeader.Description[0], "Table Load File");

       	/* Output the Standard cFE File Header to the Dump File */
       	Status = CFE_FS_WriteHeader(FileDescriptor, &StdFileHeader);

        if (Status == sizeof(CFE_FS_Header_t))
       	{
           	/* Initialize the Table Image Header for the Dump File */
           	CFE_PSP_MemCpy(TblFileHeader.TableName, tableName, CFE_TBL_MAX_FULL_NAME_LEN);
           	TblFileHeader.Offset = 0;
            TblFileHeader.NumBytes = 4;
    	    TblFileHeader.Reserved = 0;
            
           	/* Determine if this is a little endian processor */
           	if ((*(char *)&EndianCheck) == 0x04)
           	{
	        	CFE_TBL_ByteSwapTblHeader(&TblFileHeader);
    	    }

            /* Output the Table Image Header to the Dump File */
           	Status = OS_write(FileDescriptor, &TblFileHeader, sizeof(CFE_TBL_File_Hdr_t));

           	/* Make sure the header was output completely */
           	if (Status == sizeof(CFE_TBL_File_Hdr_t))
           	{
	        	/* Output the requested data to the dump file */
    	        /* Output the active table image data to the dump file */
        	    Status = OS_write(FileDescriptor, values, 4);
            }
        }
        	    
        /* We are done writing the load file.  Close it. */
        OS_close(FileDescriptor);
    }
}
Пример #5
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void DS_FileCreateDest(uint32 FileIndex)
{
    DS_DestFileEntry_t *DestFile = &DS_AppData.DestFileTblPtr->File[FileIndex];
    DS_AppFileStatus_t *FileStatus = &DS_AppData.FileStatus[FileIndex];
    int32 Result;

    /*
    ** Create filename from "path + base + sequence count + extension"...
    */
    DS_FileCreateName(FileIndex);

    if (FileStatus->FileName[0] != DS_STRING_TERMINATOR)
    {
        /*
        ** Success - create a new destination file...
        */
        Result = OS_creat(FileStatus->FileName, OS_READ_WRITE);

        if (Result < 0)
        {
            /*
            ** Error - send event, disable destination and reset filename...
            */
            DS_AppData.FileWriteErrCounter++;

            CFE_EVS_SendEvent(DS_CREATE_FILE_ERR_EID, CFE_EVS_ERROR,
                             "FILE CREATE error: result = %d, dest = %d, name = '%s'",
                              Result, FileIndex, FileStatus->FileName);

            CFE_PSP_MemSet(FileStatus->FileName, 0, DS_TOTAL_FNAME_BUFSIZE);

            /*
            ** Something needs to get fixed before we try again...
            */
            FileStatus->FileState = DS_DISABLED;
        }
        else
        {
            /*
            ** Success - store the file handle...
            */
            DS_AppData.FileWriteCounter++;

            FileStatus->FileHandle = Result;

            /*
            ** Initialize and write config specific file header...
            */
            DS_FileWriteHeader(FileIndex);

            /*
            ** Update sequence count if have one and write successful...
            */
            if ((FileStatus->FileHandle != DS_CLOSED_FILE_HANDLE) &&
                (DestFile->FileNameType == DS_BY_COUNT))
            {
                FileStatus->FileCount++;
                if (FileStatus->FileCount > DS_MAX_SEQUENCE_COUNT)
                {
                    FileStatus->FileCount = 0;
                }

                /*
                ** Update Critical Data Store (CDS)...
                */
                DS_TableUpdateCDS();
            }
        }
    }

    return;

} /* End of DS_FileCreateDest() */
Пример #6
0
/* --------------------------------------------------------------------------------------
    Name: OS_ShellOutputToFile
    
    Purpose: Takes a shell command in and writes the output of that command to the specified file
    
    Returns: OS_FS_ERROR if the command was not executed properly
             OS_FS_ERR_INVALID_FD if the file descriptor passed in is invalid
             OS_SUCCESS if success
 ---------------------------------------------------------------------------------------*/
int32 OS_ShellOutputToFile(char* Cmd, int32 OS_fd)
{
    int32              cmdFd;
    int32              tmpFd;
    rtems_status_code  rtemsRc;;
    int32              ReturnCode = OS_SUCCESS;
    int32              fileStatus;
    int32              bytesRead;
    int32              bytesWritten;
    char               readBuffer[256];
    char               outputFileName[OS_MAX_PATH_LEN + OS_SHELL_TMP_FILE_EXT_LEN];
    char               localCmd[OS_MAX_CMD_LEN]; 

    /* Make sure the file descriptor is legit before using it */
    if (OS_fd < 0 || OS_fd >= OS_MAX_NUM_OPEN_FILES || OS_FDTable[OS_fd].IsValid == FALSE)
    {
        ReturnCode = OS_FS_ERR_INVALID_FD;
    }
    else
    {
        /* 
        ** Create a file to write the command to (or write over the old one) 
        */
        cmdFd = OS_creat(OS_SHELL_CMD_INPUT_FILE_NAME,OS_READ_WRITE);
        if (cmdFd < OS_FS_SUCCESS)
        {
            ReturnCode = OS_FS_ERROR;
        }
        else
        {
            /*
            ** Write the command to the buffer
            */
            strncpy(localCmd,Cmd,OS_MAX_CMD_LEN);
            strncat(localCmd,"\n",1);

            /*
            ** This function passes in an open file descriptor to write the shell
            **  command output. The RTEMS shell script API expects a filename, not
            **  a file descriptor. So in addition to the temporary file for the shell input,
            **  we need to create a temporary file for the command output, then it has
            **  to be copied to the open file.  
            */
            strncpy(outputFileName,OS_SHELL_CMD_INPUT_FILE_NAME,OS_MAX_PATH_LEN);           
            strncat(outputFileName,OS_SHELL_TMP_FILE_EXT,OS_SHELL_TMP_FILE_EXT_LEN);

            /* 
            ** copy the shell command buffer to the file 
            */
            fileStatus = OS_write(cmdFd, localCmd, strlen(localCmd));
            if ( fileStatus == strlen(localCmd) )
            {
               /*
               ** Close the file
               */
               OS_close(cmdFd);	

               /*
               ** Spawn a task to execute the shell command
               */
               rtemsRc =  rtems_shell_script ( 
                         "RSHL", 
                         OS_SHELL_CMD_TASK_STACK_SIZE, 
                         OS_SHELL_CMD_TASK_PRIORITY, 
                         OS_SHELL_CMD_INPUT_FILE_NAME,
                         outputFileName,
                         FALSE,       /* Do not append output to file */
                         TRUE,        /* Wait for shell task to complete */
                         FALSE        /* Echo output */ 
                        );
                
               /*
               ** Now we have the temporary file with the output 
               */
               if((tmpFd = OS_open(outputFileName, OS_READ_ONLY,0)) == OS_FS_ERROR)
               {
                  printf("OSAL:Could not open %s for reading\n",outputFileName);
                  ReturnCode = OS_FS_ERROR; 
               }
               else
               { 
                  while((bytesRead = OS_read(tmpFd, readBuffer, 256)) > 0)
                  {
                     bytesWritten = OS_write(OS_fd, readBuffer, bytesRead);
                  }
                  OS_close(tmpFd);
                  /*
                  ** Remove the temporary output file
                  */
                  fileStatus = OS_remove(outputFileName); 
               } 
            }
            else
            {
                 ReturnCode = OS_FS_ERROR;
            }
        } 
        /*
        ** Remove the temporary shell input file
        */
        fileStatus = OS_remove(OS_SHELL_CMD_INPUT_FILE_NAME); 
    }
 
    return ReturnCode;

}/* end OS_ShellOutputToFile */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CFE_ES_PerfStopDataCmd(CFE_SB_MsgPtr_t Msg){

    CFE_ES_PerfStopCmd_t  *CmdPtr = (CFE_ES_PerfStopCmd_t *)Msg;
    uint16 ExpectedLength = sizeof(CFE_ES_PerfStopCmd_t);
    int32 Stat;
    
    /*
    ** Verify command packet length.
    */
    if (CFE_ES_VerifyCmdLength(Msg, ExpectedLength))
    {

      /* Ensure there is no file write in progress before proceeding */
      if(CFE_ES_PerfLogDumpStatus.DataToWrite == 0)
      {
          Perf->MetaData.State = CFE_ES_PERF_IDLE;

          if(CmdPtr->DataFileName[0]=='\0')
          {
              strncpy(&CFE_ES_PerfLogDumpStatus.DataFileName[0],
                      CFE_ES_DEFAULT_PERF_DUMP_FILENAME,OS_MAX_PATH_LEN);
          }
          else
          {
              CmdPtr->DataFileName[OS_MAX_PATH_LEN - 1] = '\0';
              strncpy(&CFE_ES_PerfLogDumpStatus.DataFileName[0], &CmdPtr->DataFileName[0],OS_MAX_PATH_LEN);
          }/* end if */
          
          
          
          /* Create the file to dump to */
          CFE_ES_PerfLogDumpStatus.DataFileDescriptor = OS_creat(&CFE_ES_PerfLogDumpStatus.DataFileName[0], OS_WRITE_ONLY);
          
          
          if(CFE_ES_PerfLogDumpStatus.DataFileDescriptor < 0)
          {
              CFE_ES_TaskData.ErrCounter++;
              CFE_EVS_SendEvent(CFE_ES_PERF_LOG_ERR_EID,CFE_EVS_ERROR,
                                "Error creating file %s, RC = 0x%08X",
                                &CFE_ES_PerfLogDumpStatus.DataFileName[0], CFE_ES_PerfLogDumpStatus.DataFileDescriptor);
          }
          else
          {
          
              /* Spawn a task to write the performance data to a file */
              Stat = CFE_ES_CreateChildTask(&CFE_ES_PerfLogDumpStatus.ChildID,
                                            CFE_ES_PERF_CHILD_NAME,
                                            CFE_ES_PerfLogDump,
                                            CFE_ES_PERF_CHILD_STACK_PTR,
                                            CFE_ES_PERF_CHILD_STACK_SIZE,
                                            CFE_ES_PERF_CHILD_PRIORITY,
                                            CFE_ES_PERF_CHILD_FLAGS);

              if(Stat == CFE_SUCCESS)
              {
                  /* Note: the file gets closed in the child task */
                  CFE_ES_TaskData.CmdCounter++;
                  CFE_EVS_SendEvent(CFE_ES_PERF_STOPCMD_EID,CFE_EVS_DEBUG,
                                    "Perf Stop Cmd Rcvd,%s will write %d entries.%dmS dly every %d entries",
                                    CFE_ES_PERF_CHILD_NAME,Perf->MetaData.DataCount,
                                    CFE_ES_PERF_CHILD_MS_DELAY,CFE_ES_PERF_ENTRIES_BTWN_DLYS);
              }
              else
              {
                  /* close the fd */
                  OS_close( CFE_ES_PerfLogDumpStatus.DataFileDescriptor);
                  CFE_ES_TaskData.ErrCounter++;
                  CFE_EVS_SendEvent(CFE_ES_PERF_STOPCMD_ERR1_EID, CFE_EVS_ERROR,
                                    "Stop performance data cmd,Error creating child task RC=0x%08X",Stat);
              }/* end if */

          }/* end if fd < 0 */
          
      }/* if data to write == 0 */
      else
      {

          CFE_ES_TaskData.ErrCounter++;
          CFE_EVS_SendEvent(CFE_ES_PERF_STOPCMD_ERR2_EID, CFE_EVS_ERROR,
                   "Stop performance data cmd ignored,perf data write in progress");
      }/* end if */

    }/* end VerifyCmdLength */

} /* End of CFE_ES_PerfStopDataCmd() */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
int32 CFE_ES_ShellOutputCommand(char * CmdString, char *Filename)
{
    int32 Result;
    int32 ReturnCode = CFE_SUCCESS;
    int32 fd;
    int32 FileSize;
    int32 CurrFilePtr;
    uint32 i;
    
    /* the extra 1 added for the \0 char */
    char CheckCmd [CFE_ES_CHECKSIZE + 1];
    char Cmd [CFE_ES_MAX_SHELL_CMD];
    char OutputFilename [OS_MAX_PATH_LEN];

    /* Use default filename if not provided */
    if (Filename[0] == '\0')
    {
        strncpy(OutputFilename, CFE_ES_DEFAULT_SHELL_FILENAME, OS_MAX_PATH_LEN);
    }
    else
    {
        strncpy(OutputFilename, Filename, OS_MAX_PATH_LEN);
    }

    /* Make sure string is null terminated */
    OutputFilename[OS_MAX_PATH_LEN - 1] = '\0';

    /* Remove previous version of output file */
    OS_remove(OutputFilename); 

    fd = OS_creat(OutputFilename, OS_READ_WRITE);

    if (fd < OS_FS_SUCCESS)
    {
        Result = OS_FS_ERROR;
    }

    else
    {
        strncpy(CheckCmd,CmdString,CFE_ES_CHECKSIZE);
    
        CheckCmd[CFE_ES_CHECKSIZE]  = '\0';
    
        strncpy(Cmd,CmdString, CFE_ES_MAX_SHELL_CMD);
    
        /* We need to check if this command is directed at ES, or at the 
        operating system */
    
        if (strncmp(CheckCmd,"ES_",CFE_ES_CHECKSIZE) == 0)
        {
            /* This list can be expanded to include other ES functionality */
            if ( strncmp(Cmd,CFE_ES_LIST_APPS_CMD,strlen(CFE_ES_LIST_APPS_CMD) )== 0)
            {
                Result = CFE_ES_ListApplications(fd);
            }
            else if ( strncmp(Cmd,CFE_ES_LIST_TASKS_CMD,strlen(CFE_ES_LIST_TASKS_CMD) )== 0)
            {
                Result = CFE_ES_ListTasks(fd);
            }
            else if ( strncmp(Cmd,CFE_ES_LIST_RESOURCES_CMD,strlen(CFE_ES_LIST_RESOURCES_CMD) )== 0)
            {
                Result = CFE_ES_ListResources(fd);
            }

            /* default if there is not an ES command that matches */
            else
            {
                Result = CFE_ES_ERR_SHELL_CMD;
                CFE_ES_WriteToSysLog("There is no ES Shell command that matches %s \n",Cmd);
            }            

        }
        /* if the command is not directed at ES, pass it through to the 
        * underlying OS */
        else
        {
            Result = OS_ShellOutputToFile(Cmd,fd);
        }

        /* seek to the end of the file to get it's size */
        FileSize = OS_lseek(fd,0,OS_SEEK_END);

        if (FileSize == OS_FS_ERROR)
        {
            OS_close(fd);
            CFE_ES_WriteToSysLog("OS_lseek call failed from CFE_ES_ShellOutputCmd 1\n");
            Result =  OS_FS_ERROR;
        }



        /* We want to add 3 characters at the end of the telemetry,'\n','$','\0'.
         * To do this we need to make sure there are at least 3 empty characters at
         * the end of the last CFE_ES_MAX_SHELL_PKT so we don't over write any data. If 
         * the current file has only 0,1, or 2 free spaces at the end, we want to 
         * make the file longer to start a new tlm packet of size CFE_ES_MAX_SHELL_PKT.
         * This way we will get a 'blank' packet with the correct 3 characters at the end.
         */

        else
        {
            /* if we are within 2 bytes of the end of the packet*/
            if ( FileSize % CFE_ES_MAX_SHELL_PKT > (CFE_ES_MAX_SHELL_PKT - 3))
            {
                /* add enough bytes to start a new packet */
                for (i = 0; i < CFE_ES_MAX_SHELL_PKT - (FileSize % CFE_ES_MAX_SHELL_PKT) + 1 ; i++)
                {
                    OS_write(fd," ",1);
                }
            }
            else
            {
                /* we are exactly at the end */
                if( FileSize % CFE_ES_MAX_SHELL_PKT == 0)
                {
                    OS_write(fd," ",1);
                }
            }

            /* seek to the end of the file again to get it's new size */
            FileSize = OS_lseek(fd,0,OS_SEEK_END);

            if (FileSize == OS_FS_ERROR)
            {
                OS_close(fd);
                CFE_ES_WriteToSysLog("OS_lseek call failed from CFE_ES_ShellOutputCmd 2\n");
                Result =  OS_FS_ERROR;
            }


            else
            {
                /* set the file back to the beginning */
                OS_lseek(fd,0,OS_SEEK_SET);


                /* start processing the chunks. We want to have one packet left so we are sure this for loop
                * won't run over */
        
                for (CurrFilePtr=0; CurrFilePtr < (FileSize - CFE_ES_MAX_SHELL_PKT); CurrFilePtr += CFE_ES_MAX_SHELL_PKT)
                {
                    OS_read(fd, CFE_ES_TaskData.ShellPacket.ShellOutput, CFE_ES_MAX_SHELL_PKT);

                    /* Send the packet */
                    CFE_SB_TimeStampMsg((CFE_SB_Msg_t *) &CFE_ES_TaskData.ShellPacket);
                    CFE_SB_SendMsg((CFE_SB_Msg_t *) &CFE_ES_TaskData.ShellPacket);
                    /* delay to not flood the pipe on large messages */
                    OS_TaskDelay(200);
                }

                /* finish off the last portion of the file */
                /* over write the last packet with spaces, then it will get filled
               * in with the correct info below. This assures that the last non full
               * part of the packet will be spaces */
                for (i =0; i < CFE_ES_MAX_SHELL_PKT; i++)
                {
                    CFE_ES_TaskData.ShellPacket.ShellOutput[i] = ' ';
                }
  
                OS_read(fd, CFE_ES_TaskData.ShellPacket.ShellOutput, ( FileSize - CurrFilePtr));

                /* From our check above, we are assured that there are at least 3 free
                 * characters to write our data into at the end of this last packet 
                 * 
                 * The \n assures we are on a new line, the $ gives us our prompt, and the 
                 * \0 assures we are null terminalted.
                 */

        
                CFE_ES_TaskData.ShellPacket.ShellOutput[ CFE_ES_MAX_SHELL_PKT - 3] = '\n';
                CFE_ES_TaskData.ShellPacket.ShellOutput[ CFE_ES_MAX_SHELL_PKT - 2] = '$';
                CFE_ES_TaskData.ShellPacket.ShellOutput[ CFE_ES_MAX_SHELL_PKT - 1] = '\0';

                /* Send the last packet */
                CFE_SB_TimeStampMsg((CFE_SB_Msg_t *) &CFE_ES_TaskData.ShellPacket);
                CFE_SB_SendMsg((CFE_SB_Msg_t *) &CFE_ES_TaskData.ShellPacket);
   
                /* Close the file descriptor */
                OS_close(fd);
            } /* if FilseSize == OS_FS_ERROR */
        } /* if FileSeize == OS_FS_ERROR */
    }/* if fd < OS_FS_SUCCESS */


    if (Result != OS_SUCCESS && Result != CFE_SUCCESS )
    {
        ReturnCode = CFE_ES_ERR_SHELL_CMD;
        CFE_ES_WriteToSysLog("OS_ShellOutputToFile call failed from CFE_ES_ShellOutputCommand\n");
    }
    else
    {
        ReturnCode = CFE_SUCCESS;
    }
    
    return ReturnCode;
}