private void btnWriteAccTab_Click(object sender, EventArgs e) { if (_serialPort == null) { Log("Serial port is not connected.", Color.Red); return; } try { WriteAccTab command = new WriteAccTab(); if (!InitCommand(command)) { return; } string[] data = txtInput.Text.Split(','); command.Data = new UInt16[data.Length]; for (int i = 0; i < data.Length; i++) { UInt16 intData; if (!UInt16.TryParse(data[i], out intData)) { Log("Invalid data. Use a comma to separate multiple values.", Color.Red); return; } command.Data[i] = intData; } 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 btnWriteAccTab_Click(object sender, EventArgs e) { if (_serialPort == null) { Log("Serial port is not connected.", Color.Red); return; } try { WriteAccTab command = new WriteAccTab(); if (!InitCommand(command)) return; string[] data = txtInput.Text.Split(','); command.Data = new UInt16[data.Length]; for (int i = 0; i < data.Length; i++) { UInt16 intData; if (!UInt16.TryParse(data[i], out intData)) { Log("Invalid data. Use a comma to separate multiple values.", Color.Red); return; } command.Data[i] = intData; } 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); } }