Thanks everyone. I think I have successfully converted the HEX/ASCII output from serial monitor (Arduino software).
I copy and pasted all of the text from the monitor window and used a script I wrote to convert the string hex representation to a byte within the file.
void Main()
{
string filePath = @"F:\epromreadingfromarduino.txt";
string[] rawLines = File.ReadAllLines(filePath);
string dirPath = Path.GetDirectoryName(filePath);
string fileName = Path.GetFileNameWithoutExtension(filePath);
string binFile = $"{dirPath}\\{fileName}.bin";
List<byte> bytesList = new List<byte>();
foreach(var line in rawLines)
{
if(line.Equals("Reading ROM ...", StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(line)) continue;
var lineData = line.Substring(0,32);
var bytes = ConvertHexStringToByteArray(lineData);
bytesList.AddRange(bytes);
}
ByteArrayToFile(binFile, bytesList.ToArray());
}
// Define other methods and classes here
private static byte[] ConvertHexStringToByteArray(string hexString)
{
return Enumerable
.Range(0, hexString.Length / 2)
.Select(i => Convert.ToByte(hexString.Substring(i * 2, 2), 16))
.ToArray();
}
public bool ByteArrayToFile(string fileName, byte[] byteArray)
{
try
{
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
fs.Write(byteArray, 0, byteArray.Length);
return true;
}
}
catch (Exception ex)
{
Console.WriteLine("Exception caught in process: {0}", ex);
return false;
}
}
The file went from looking like this...

To this, in a hex editor...

Hopefully that is correct.
