KFDtool/sw/control/KFDtool.Cmd/Program.cs

83 lines
2.3 KiB
C#
Raw Normal View History

2019-07-29 15:24:10 -06:00
using KFDtool.Adapter.Bundle;
using Mono.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KFDtool.Cmd
{
class Program
{
static void Main(string[] args)
{
bool create = false;
string input = string.Empty;
string output = string.Empty;
2019-09-02 17:44:06 -06:00
string port = string.Empty;
bool read = false;
2019-07-29 15:24:10 -06:00
OptionSet commandLineOptions = new OptionSet
{
2019-09-02 17:44:06 -06:00
{ "create", "create update file", v => create = v != null },
{ "input=", "input file", v => input = v },
{ "output=", "output file", v => output = v },
{ "port=", "port number", v => port = v },
{ "read", "free run read", v => read = v != null }
2019-07-29 15:24:10 -06:00
};
try
{
commandLineOptions.Parse(args);
}
catch (OptionException ex)
{
Console.WriteLine(ex.Message);
}
if (create)
{
if (input == string.Empty)
{
Console.WriteLine("no input file specified");
return;
}
if (output == string.Empty)
{
Console.WriteLine("no output file specified");
return;
}
Console.WriteLine("creating update file");
try
{
Firmware.GenerateUpdate(input, output);
}
catch (Exception ex)
{
Console.WriteLine("error when generating update file -- {0}", ex.Message);
}
}
2019-09-02 17:44:06 -06:00
else if (read)
{
if (port == string.Empty)
{
Console.WriteLine("no port number specified");
return;
}
Analyzer.FreeRunRead(port);
}
2019-07-29 15:24:10 -06:00
else
{
Console.WriteLine("no action specified");
}
Console.WriteLine("exiting");
}
}
}