public void handleSimpliciTI() { chron = new Chronos(); while (true) { try { chron.OpenComPort(chron.GetComPortName()); writeLog("Found access point on port: " + chron.GetComPortName()); break; } catch (Exception) { System.Threading.Thread.Sleep(1000); } } chron.StartSimpliciTI(); writeLog("SimpliciTI started"); while (true) { uint data; if (!chron.GetData(out data)) { break; } if (data != 0xFF) { writeLog("Got data: " + data); } //Star if (data == 2) { key.pressKey(0x44); } if (data == 3) { key.releaseKey(0x44); } //NUM if (data == 4) { key.pressKey(0x41); } if (data == 5) { key.releaseKey(0x41); } //UP if (data == 6) { key.pressKey(0x57); } if (data == 7) { key.releaseKey(0x57); } } writeLog("Error!"); }
private void connectButton_Click(object sender, EventArgs e) { portName = ez.GetComPortName(); if (portName == "") { log("Check your receiver and drivers. COM port device is not found"); return; } if (isConnected) { ez.CloseComPort(); log("AP Disconnected"); isConnected = false; connectButton.Text = "Connect"; } else if (ez.OpenComPort(portName)) { if (!ez.StartSimpliciTI()) { log("Error while StartSimpliciTI"); } /* * In C++ library it is said: * After power-up, the hardware is not automatically reset. * Use the following function to initialize the RF AP. * ... * * Returns true if RF AP COULD be initialized succesfully. * * However in ez430_chronos_net library sources: * ResetAP() return true : * * APStatus BM_errorstate = (APStatus)response.Data[Constants.PACKET_BYTE_CMD]; * if (BM_errorstate != APStatus.HW_NO_ERROR) return false; * return true; * */ /* * if (!ez.ResetAP()) * { * log("Error while starting AP"); * if (ez.PortOpen) ez.CloseComPort(); * isConnected = false; * return; * } */ rmm.load("C:\\temp"); Thread.Sleep(1000); //Pause to initialize AP. connectButton.Text = "Disconnect"; log("AP Connected"); isConnected = true; } else { log("AP is not responding"); } }
public string GetComPortName() { return(chronos.GetComPortName()); }