V2/Cet/IO/Cet.IO.Serial/SerialPortParams.cs
/// <summary>
/// Parser for the textual compact form
/// </summary>
/// <param name="settings">The settings as string (e.g. "9600,E,8,1")</param>
Parser for the textual compact form
Parser for the textual compact form
private static void ParseSettings(
            string settings,
            out int baudRate,
            out Parity parity,
            out int dataBits,
            out StopBits stopBits)
        {
            string[] tokens = settings.Split(',');
            baudRate = int.Parse(tokens[0]);
            switch (tokens[1])
            {
                case "N":
                    parity = Parity.None;
                    break;
                case "E":
                    parity = Parity.Even;
                    break;
                case "O":
                    parity = Parity.Odd;
                    break;
                case "M":
                    parity = Parity.Mark;
                    break;
                case "S":
                    parity = Parity.Space;
                    break;
                default:
                    throw new NotSupportedException("Parity value not supported");
            }
            dataBits = int.Parse(tokens[2]);
            switch (tokens[3])
            {
                case "0":
                    stopBits = StopBits.None;
                    break;
                case "1":
                    stopBits = StopBits.One;
                    break;
                case "2":
                    stopBits = StopBits.Two;
                    break;
                default:
                    throw new NotSupportedException("StopBits value not supported");
            }
        }
private static void ParseSettings ( string settings , out int baudRate , out Parity parity , out int dataBits , out StopBits stopBits ) { string [ ] tokens = settings . Split ( ' ' ) ; baudRate = int . Parse ( tokens [ 0 ] ) ; switch ( tokens [ 1 ] ) { case " " : parity = Parity . None ; break ; case " " : parity = Parity . Even ; break ; case " " : parity = Parity . Odd ; break ; case " " : parity = Parity . Mark ; break ; case " " : parity = Parity . Space ; break ; default : throw new NotSupportedException ( " " ) ; } dataBits = int . Parse ( tokens [ 2 ] ) ; switch ( tokens [ 3 ] ) { case " " : stopBits = StopBits . None ; break ; case " " : stopBits = StopBits . One ; break ; case " " : stopBits = StopBits . Two ; break ; default : throw new NotSupportedException ( " " ) ; } }
Parser for the textual compact form
Parser for the textual compact form
//split the input string upon commas //baud-rate //parity //data-bits //stop-bits
settings
string
The settings as string
The settings as string
int
out
Parity
out
StopBits
out