User Tools

Site Tools

blog:2023-09-07_c_serial_port_send_string_padding



2023-09-07 C#: Serial Port Send String Padding

  • Here is the example for sending the string padding in serial port send
  •         private void Task_SendMessage()
            {
                if (Global_UartCmdPaddingString == "\\n")
                    serialPort1.Write(Global_UartCmdString + "\n");
                else if (Global_UartCmdPaddingString == "\\r")
                    serialPort1.Write(Global_UartCmdString + "\r");
                else if (Global_UartCmdPaddingString == "\\r\\n")
                    serialPort1.Write(Global_UartCmdString + "\r\n");
                else if (Global_UartCmdPaddingString == "0x00")
                {
                    byte[] _byteSend = new byte[1] { 0x00 };
                    serialPort1.Write(Global_UartCmdString);
                    serialPort1.Write(_byteSend, 0, 1);
                }
                else if (Global_UartCmdPaddingString == "None")
                    serialPort1.Write(Global_UartCmdString);
                else
                    MessageBox.Show("Error Sending UART in Padding\n" + Global_UartCmdPaddingString);
            }

TAGS

  • 58 person(s) visited this page until now.

Permalink blog/2023-09-07_c_serial_port_send_string_padding.txt · Last modified: 2023/09/07 15:24 by jethro

oeffentlich