update firmware + sender
This commit is contained in:
parent
8fc3c4ba03
commit
63befcb95f
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="port" value="COM3"/>
|
||||
<add key="baud" value="115200"/>
|
||||
</appSettings>
|
||||
</configuration>
|
|
@ -1,34 +1,39 @@
|
|||
using System.IO.Ports;
|
||||
using System.Configuration;
|
||||
using System.CommandLine;
|
||||
|
||||
namespace SendEPROM
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
public static async Task<int> Main(string[] args)
|
||||
{
|
||||
if(args.Length != 3 && args.Length != 2)
|
||||
return Usage();
|
||||
var rootCmd = new RootCommand("Send a binary image to the EPROM emulator");
|
||||
|
||||
string port = ConfigurationManager.AppSettings["port"];
|
||||
int baud = int.Parse(ConfigurationManager.AppSettings["baud"]);
|
||||
string file = string.Empty;
|
||||
byte mode = 0;
|
||||
var portOption = new Option<string> (new string[] {"--port", "-p" }, description: "COM port on which to send the file", getDefaultValue: () => "COM3");
|
||||
var baudOption = new Option<int> (new string[] {"--baud", "-b" }, description: "Baud rate at which to send", getDefaultValue: () => 115200);
|
||||
var modeOption = new Option<byte> (new string[] {"--mode", "-m" }, description: "EPROM mode (1 = 27C256, 2 = 27C020)", getDefaultValue: () => 2);
|
||||
|
||||
if(args.Length == 2)
|
||||
var fileArgument = new Argument<FileInfo>("file", description: "File to send");
|
||||
|
||||
rootCmd.AddOption(portOption);
|
||||
rootCmd.AddOption(baudOption);
|
||||
rootCmd.AddOption(modeOption);
|
||||
rootCmd.AddArgument(fileArgument);
|
||||
|
||||
rootCmd.SetHandler((port, baud, mode, file) =>
|
||||
{
|
||||
mode = byte.Parse(args[0]);
|
||||
file = args[1];
|
||||
}
|
||||
else if(args.Length == 3)
|
||||
{
|
||||
port = args[0];
|
||||
baud = int.Parse(args[1]);
|
||||
file = args[2];
|
||||
}
|
||||
SendData(port, baud, mode, file);
|
||||
},
|
||||
portOption, baudOption, modeOption, fileArgument);
|
||||
|
||||
Console.WriteLine($"Reading {file}");
|
||||
byte[] buff = File.ReadAllBytes(file);
|
||||
return await rootCmd.InvokeAsync(args);
|
||||
}
|
||||
|
||||
static void SendData(string port, int baud, byte mode, FileInfo file)
|
||||
{
|
||||
|
||||
Console.WriteLine($"Reading {file.Name}");
|
||||
byte[] buff = File.ReadAllBytes(file.Name);
|
||||
|
||||
Console.WriteLine($"Opening {port} at {baud}");
|
||||
var sp = new SerialPort(port)
|
||||
|
@ -48,14 +53,6 @@ namespace SendEPROM
|
|||
sp.Write(buff, 0, buff.Length);
|
||||
sp.Close();
|
||||
Console.WriteLine("Done!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int Usage()
|
||||
{
|
||||
Console.WriteLine("Usage: SendEPROM [COMX] [baud] [EPROM mode] filename");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
|
||||
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -96,17 +96,15 @@ void loop()
|
|||
|
||||
switch(mode)
|
||||
{
|
||||
// 32Kbit, 8KB, 0x0000-0x7FFF
|
||||
// 256Kbit, 32KB, 0x0000-0x7FFF
|
||||
case m27C256:
|
||||
addr = ((io6 >> 16) & 0x7FFF);
|
||||
break;
|
||||
|
||||
// 2Mbit, 256KB, 0x00000-0x3FFFF
|
||||
case m27C020:
|
||||
addr = ((io6 >> 16) & 0xFFFF) | ((io6 & 0x3000) << 4);
|
||||
break;
|
||||
|
||||
default:
|
||||
addr = ((io6 >> 16) & 0xFFFF) | ((io6 & 0x3000) << 4);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue