static void Main(string[] args) { ComReader comReader = ComReader.Instance; comReader.DataReceived += ComReader_DataReceived; comReader.LostConnection += ComReader_LostConnection; Console.WriteLine("Key: '1' - Init, '2' - Start, 3 - 'Stop'"); while (true) { var keyInfo = Console.ReadKey(); switch (keyInfo.KeyChar) { case '1': comReader.Init(); break; case '2': comReader.Start(); break; case '3': comReader.Stop(); break; default: return; } } }
private async Task ScanIcpDevices(BznModel bznModel) { ComReader comReader = new ComReader(bznModel.ComDevice.Port); if (comReader.Open()) { bznModel.IcpDevices = new ObservableCollection <IcpDeviceModel>(await IcpDeviceManager.ScanIcpDevicesAsync(comReader)); } }
private static bool SendCommand(ComReader comReader, IcpDeviceModel icpDevice, IcpCommand command, int addr) { string request = IcpDcom.CreateIcpDcomRequest(command, addr); string response = comReader.SendCommand(request); bool result = IcpDcom.ParseIcpResponse(command, response, icpDevice); if (!result) { logger.Error($"Cant send {command} to {icpDevice.Name}, addr: {addr}, com: {comReader.Port}"); } return(result); }
private static IcpDeviceModel GetFullInfo(ComReader comReader, int addr) { IcpDeviceModel icpDeviceModel = new IcpDeviceModel { Address = addr }; SendCommand(comReader, icpDeviceModel, IcpCommand.GetName, addr); SendCommand(comReader, icpDeviceModel, IcpCommand.GetFirmware, addr); SendCommand(comReader, icpDeviceModel, IcpCommand.GetInputState, addr); return(icpDeviceModel); }
// parse the assembly definitions using metadata reader public MethodParser(string assemblyPath) { var comReader = new ComReader(assemblyPath); foreach (MetadataMethod method in comReader.getMethodsWithCustomAttribute(ComReader.exportAttribute)) { var tokens = method.typeName.Split('.'); if (tokens.Length > 1) { methods.Add(new Method(method.name, tokens[0], tokens[1])); } } }
static void Main(string[] args) { ComReader comReader = new ComReader("COM1"); IcpDeviceModel deviceModel_3 = new IcpDeviceModel(); IcpDeviceModel deviceModel_9 = new IcpDeviceModel(); if (comReader.Open()) { string cmd = ""; { string request = IcpDcom.CreateIcpDcomRequest(IcpCommand.GetName, 9); string response = comReader.SendCommand(request); bool res = IcpDcom.ParseIcpResponse(IcpCommand.GetName, response, deviceModel_9); request = IcpDcom.CreateIcpDcomRequest(IcpCommand.GetModuleStatus, 9); response = comReader.SendCommand(request); res = IcpDcom.ParseIcpResponse(IcpCommand.GetModuleStatus, response, deviceModel_9); request = IcpDcom.CreateIcpDcomRequest(IcpCommand.GetFirmware, 9); response = comReader.SendCommand(request); res = IcpDcom.ParseIcpResponse(IcpCommand.GetFirmware, response, deviceModel_9); request = IcpDcom.CreateIcpDcomRequest(IcpCommand.SetOutputs, 9, "", 15); response = comReader.SendCommand(request); res = IcpDcom.ParseIcpResponse(IcpCommand.SetOutputs, response, deviceModel_9); } { string request = IcpDcom.CreateIcpDcomRequest(IcpCommand.GetName, 3); string response = comReader.SendCommand(request); bool res = IcpDcom.ParseIcpResponse(IcpCommand.GetName, response, deviceModel_3); request = IcpDcom.CreateIcpDcomRequest(IcpCommand.GetFirmware, 3); response = comReader.SendCommand(request); res = IcpDcom.ParseIcpResponse(IcpCommand.GetFirmware, response, deviceModel_3); request = IcpDcom.CreateIcpDcomRequest(IcpCommand.GetInputState, 3); response = comReader.SendCommand(request); res = IcpDcom.ParseIcpResponse(IcpCommand.GetInputState, response, deviceModel_3); } do { Console.Write("Enter command: "); cmd = Console.ReadLine(); var resp = comReader.SendCommand(cmd); Console.WriteLine($"Response: {resp}"); Console.WriteLine(); } while (cmd != "quit"); } }
static void Main(string[] args) { Action <string> foundAction = s => { //var client = new RestClient("https://www.size.com"); //var request = new RestRequest("/doorbell.asp", Method.POST); //client.Proxy = new WebProxy("proxy..."); //client.Execute(request); System.Console.WriteLine(s); }; ComReader.Register(foundAction); System.Console.ReadLine(); }
public static bool PingDevice(int addr, ComReader comReader) { var req = CreateIcpDcomRequest(IcpCommand.GetModuleStatus, addr); var resp = comReader.SendCommand(req); if (string.IsNullOrEmpty(resp)) { return(false); } if (resp[0] == '!') { return(true); } return(false); }
//[TestMethod] public async Task TestMethod1Async() { ComReader comReader = new ComReader("COM1"); if (comReader.Open()) { IcpDeviceManager icpDeviceManager = new IcpDeviceManager(comReader); var devices = await icpDeviceManager.ScanIcpDevicesAsync(); foreach (var item in devices) { Debug.WriteLine($"-- {item.Name}"); } } comReader.Close(); }
static void Main(string[] args) { Notifier.header("############################################################"); Notifier.header("########### ~°~ Welcome to the ICU 0.0 ~°~ ###########"); Notifier.header("############################################################"); Notifier.header(""); // Listen from UDP for incoming requests UdpReceive recv = new UdpReceive(); // Read from the COMPORT ComReader comReader = new ComReader(); //UdpSend.Instance.SendMessage("127.0.0.1", 5000, "HELLOOO"); // And that's it ! Console.ReadLine(); }
protected override void OnStart(string[] args) { EventLog.WriteEntry("Knocker Service Starting..."); Action <string> foundAction = s => { EventLog.WriteEntry(s); // launch the application ApplicationLoader.PROCESS_INFORMATION procInfo; ApplicationLoader.StartProcessAndBypassUAC(@"C:\Services\Tallon.Knocker.Notification.exe", out procInfo); //var client = new RestClient("https://www.size.com"); //var request = new RestRequest("/doorbell.asp", Method.POST); //client.Proxy = new WebProxy("proxy..."); //client.Execute(request); }; ComReader.Register(foundAction); }
//[TestMethod] public void ComReaderTestMethod() { ComReader comReader = ComReader.Instance; if (comReader.Init()) { comReader.Start(); } else { Debug.WriteLine($"Cant Init ComReader"); } comReader.DataReceived += ComReader_DataReceived; comReader.LostConnection += ComReader_LostConnection; while (true) { var key = Console.ReadKey(); } }
public static async Task <List <IcpDeviceModel> > ScanIcpDevicesAsync(ComReader comReader) { await TaskEx.Run(() => { List <IcpDeviceModel> icpDevices = new List <IcpDeviceModel>(); for (int i = 1; i < 10; i++) { if (!IcpDcom.PingDevice(i, comReader)) { continue; } IcpDeviceModel devInfo = GetFullInfo(comReader, i); icpDevices.Add(devInfo); } return(icpDevices); }); return(null); }
public void TestMethod1() { ComReader comReader = new ComReader("COM1"); comReader.Close(); Thread.Sleep(200); comReader.Close(); Thread.Sleep(200); if (comReader.Open()) { string resp = comReader.SendCommand("$02M"); resp = comReader.SendCommand("$02C"); resp = comReader.SendCommand("$03C"); resp = comReader.SendCommand("$03M"); resp = comReader.SendCommand("$03L0"); resp = comReader.SendCommand("$02L0"); resp = comReader.SendCommand("$@03"); resp = comReader.SendCommand("$@02"); } }
public void init() { _assemblyPath = createAssembly(); _comReader = new ComReader(_assemblyPath); }
public void FoundArduinoPortTest() { var result = ComReader.FoundPort(); Assert.IsTrue(result); }
public IcpDeviceManager(ComReader comReader) { ComReader = comReader; }
private void MainForm_Load(object sender, EventArgs e) { Action <string> resultAction = s => MessageBox.Show(s); ComReader.Register(resultAction); }