private void btnControlONOFF_Click(object sender, EventArgs e) { if (_serialPort == null) { Log("Serial port is not connected.", Color.Red); return; } try { Control_ON_OFF command = new Control_ON_OFF(); if (!InitCommand(command)) { return; } Log(command.ToString(), Color.Black); command.Send(_serialPort); if (!command.Receive(_serialPort)) { return; } } catch (Exception ex) { Log(ex.Message, Color.Red); Log(ex.StackTrace, Color.Red); } }
private void btnControlONOFF_Click(object sender, EventArgs e) { if (_serialPort == null) { Log("Serial port is not connected.", Color.Red); return; } try { Control_ON_OFF command = new Control_ON_OFF(); if (!InitCommand(command)) return; Log(command.ToString(), Color.Black); command.Send(_serialPort); if (!command.Receive(_serialPort)) return; } catch (Exception ex) { Log(ex.Message, Color.Red); Log(ex.StackTrace, Color.Red); } }