Skip to content

Commit

Permalink
ShartTerminal: Added code to generic search for know executables
Browse files Browse the repository at this point in the history
  • Loading branch information
bcsanches committed Nov 2, 2024
1 parent 001f227 commit ef7e5ae
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
8 changes: 8 additions & 0 deletions data/EFMR/PanelStagingExtC.emulator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"pins":[
{
"pin":1,
"externalVoltage":"high"
}
]
}
17 changes: 5 additions & 12 deletions src/SharpTools/SharpTerminal/Forms/ConsoleUserControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,12 @@ void IResponseHandler.OnResponse(JsonValue response, int id)
var filePath = responseObj["filepath"];
Console_Println("Stored EEPROM at " + filePath);

String viewerPath = "SharpEEpromViewer.exe";
if (!System.IO.File.Exists("SharpEEpromViewer.exe"))
String viewerPath = Util.FindExecutable("SharpEEpromViewer");
if(viewerPath == null)
{
viewerPath = System.Reflection.Assembly.GetEntryAssembly().Location;
viewerPath = viewerPath.Replace("SharpTerminal.dll", "SharpEEPromViewer.exe");
viewerPath = viewerPath.Replace("SharpTerminal", "SharpEEpromViewer");

if (!System.IO.File.Exists(viewerPath))
{
MessageBox.Show("Cannot locate SharpEEPromViewer.exe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
}
MessageBox.Show("Cannot locate SharpEEPromViewer.exe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}

var process = new System.Diagnostics.Process();
process.StartInfo.FileName = viewerPath;
Expand Down
29 changes: 29 additions & 0 deletions src/SharpTools/SharpTerminal/Util.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SharpTerminal
{
/// <summary>
/// All the useful stuff that does not fit anywhere else and does not deserve their own file....
/// </summary>
internal static class Util
{
public static string FindExecutable(string executableName)
{
string executableFile = executableName + ".exe";
string path = executableFile;
if (System.IO.File.Exists(executableFile))
return executableFile;

path = System.Reflection.Assembly.GetEntryAssembly().Location;
path = path.Replace("SharpTerminal.dll", executableFile);
path = path.Replace("SharpTerminal", executableName);

return System.IO.File.Exists(path) ? path : null;
}
}
}
2 changes: 2 additions & 0 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ DCCLite
-------

- Better emulator:
- Make sharpConsole able to start emulator as is
- Make sharpconsole start emulator using a existing device name
- Show it on SharpConsole and remote connect to it.
- Allow pin states to be set:
- Set voltage level: LOW or HIGH
Expand Down

0 comments on commit ef7e5ae

Please sign in to comment.