private void serialportCommand(string commandname) { try { serialPort1.Open(); serialPort1.WriteLine(commandname); serialPort1.Close(); } catch (Exception ex) { } }