/// <summary> /// Main program. /// </summary> /// <param name="args">Input commandline arguments</param> /// <returns>Return code</returns> static Int32 Main(String[] args) { // Assumes that in AssemblyInfo.cs, the version is specified as 1.0.* or the like, // with only 2 numbers specified; the next two are generated from the date. System.Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; // v.Build is days since Jan. 1, 2000, v.Revision*2 is seconds since local midnight Int32 buildYear = new DateTime( v.Build * TimeSpan.TicksPerDay + v.Revision * TimeSpan.TicksPerSecond * 2 ).AddYears(1999).Year; // Begin main code Console.Clear(); Console.WriteLine("-----------------------------------------------------"); Console.WriteLine(" TI AIS Hex File Generator for " + devString ); Console.WriteLine(" (C) "+buildYear+", Texas Instruments, Inc." ); Console.WriteLine(" Ver. "+v.Major+"."+v.Minor.ToString("D2") ); Console.WriteLine("-----------------------------------------------------"); Console.Write("\n\n"); // Parse the input command line parameters ProgramCmdParams cmdParams = ParseCmdLine(args); if (!cmdParams.valid) { DispHelp(); return -1; } // Now proceed with main program FileStream tempAIS_fs = null; Byte[] AISData, convertedData; AISGen_DM643x_Secure generator = new AISGen_DM643x_Secure(); // Update the default INI file name to the one supplied on the command line if (cmdParams.iniFileName == null) { cmdParams.iniFileName = generator.DeviceNameShort + ".ini"; } // Read the INI data from file INISection[] iniSecs = INI.Parse(new FileStream(cmdParams.iniFileName, FileMode.Open, FileAccess.Read)); // Force section-by-section CRC checks (may be overridden in INI file) generator.CRCType = CRCCheckType.SECTION_CRC; // Do the AIS generation try { AISData = AISGen.SecureGenAIS(cmdParams.inputfileName, generator, iniSecs); } catch (Exception e) { System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(e, true); Console.WriteLine(e.StackTrace); Console.WriteLine(e.Message); Console.WriteLine("Unhandled Exception!!! Application will now exit."); return -1; } // Check if SecureAISGen completed successfully if (AISData == null) { Console.WriteLine("AIS conversion failed."); return -1; } using (tempAIS_fs = new FileStream(cmdParams.outFileName, FileMode.Create, FileAccess.Write)) { Console.WriteLine("Saving output as {0}.", cmdParams.outFileName); // Convert the AIS data to the correct output format switch ( cmdParams.convType ) { case ConvType.Exec2Bin: tempAIS_fs.Write(AISData, 0, (int)AISData.Length); break; case ConvType.Exec2CArray: convertedData = CArray.bin2CArray(AISData, 4); tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length); break; case ConvType.Exec2Srec: convertedData = SRecord.bin2srec(AISData, 0x60000000, 32); tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length); break; case ConvType.Exec2Text: Console.WriteLine("Mode Not supported."); //Byte[] val = SRecord.bin2srec(aisData, 0x60000000, 32); break; } } Console.WriteLine("Conversion complete."); return 0; }
/// <summary> /// Main program. /// </summary> /// <param name="args">Input commandline arguments</param> /// <returns>Return code</returns> static Int32 Main(String[] args) { // Assumes that in AssemblyInfo.cs, the version is specified as 1.0.* or the like, // with only 2 numbers specified; the next two are generated from the date. System.Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; // v.Build is days since Jan. 1, 2000, v.Revision*2 is seconds since local midnight Int32 buildYear = new DateTime(v.Build * TimeSpan.TicksPerDay + v.Revision * TimeSpan.TicksPerSecond * 2).AddYears(1999).Year; // Begin main code Console.Clear(); Console.WriteLine("-----------------------------------------------------"); Console.WriteLine(" TI AIS Hex File Generator for " + devString); Console.WriteLine(" (C) " + buildYear + ", Texas Instruments, Inc."); Console.WriteLine(" Ver. " + v.Major + "." + v.Minor.ToString("D2")); Console.WriteLine("-----------------------------------------------------"); Console.Write("\n\n"); // Parse the input command line parameters ProgramCmdParams cmdParams = ParseCmdLine(args); if (!cmdParams.valid) { DispHelp(); return(-1); } // Now proceed with main program FileStream tempAIS_fs = null; Byte[] AISData, convertedData; AISGen_DM643x_Secure generator = new AISGen_DM643x_Secure(); // Update the default INI file name to the one supplied on the command line if (cmdParams.iniFileName == null) { cmdParams.iniFileName = generator.DeviceNameShort + ".ini"; } // Read the INI data from file INISection[] iniSecs = INI.Parse(new FileStream(cmdParams.iniFileName, FileMode.Open, FileAccess.Read)); // Force section-by-section CRC checks (may be overridden in INI file) generator.CRCType = CRCCheckType.SECTION_CRC; // Do the AIS generation try { AISData = AISGen.SecureGenAIS(cmdParams.inputfileName, generator, iniSecs); } catch (Exception e) { System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(e, true); Console.WriteLine(e.StackTrace); Console.WriteLine(e.Message); Console.WriteLine("Unhandled Exception!!! Application will now exit."); return(-1); } // Check if SecureAISGen completed successfully if (AISData == null) { Console.WriteLine("AIS conversion failed."); return(-1); } using (tempAIS_fs = new FileStream(cmdParams.outFileName, FileMode.Create, FileAccess.Write)) { Console.WriteLine("Saving output as {0}.", cmdParams.outFileName); // Convert the AIS data to the correct output format switch (cmdParams.convType) { case ConvType.Exec2Bin: tempAIS_fs.Write(AISData, 0, (int)AISData.Length); break; case ConvType.Exec2CArray: convertedData = CArray.bin2CArray(AISData, 4); tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length); break; case ConvType.Exec2Srec: convertedData = SRecord.bin2srec(AISData, 0x60000000, 32); tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length); break; case ConvType.Exec2Text: Console.WriteLine("Mode Not supported."); //Byte[] val = SRecord.bin2srec(aisData, 0x60000000, 32); break; } } Console.WriteLine("Conversion complete."); return(0); }