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 void CloseComPort() { chronos.CloseComPort(); }