OmronSerialCommWithCSharp/OmronSerialCommWithCSharp/Form1.cs
/// <summary>
/// Get the FCS value based on command
/// </summary>
Get the FCS value based on command
Get the FCS value based on command
private void GetFCS(string command)
        {
            char c;
            decimal B;
            int L;
            int A;
            string TJ;
            L = command.Length;
            A = 0;
            for (int i = 0; i < command.Length; i++)
            {
                TJ = command.Substring(i, 1);
                A = Decimal.ToInt32(char.Parse(TJ)) ^ A;
            }
            FCS = A.ToString("X");
            if (FCS.Length == 1)
            {
                FCS = "0" + FCS;
            }
        }
private void GetFCS ( string command ) { char c ; decimal B ; int L ; int A ; string TJ ; L = command . Length ; A = 0 ; for ( int i = 0 ; i < command . Length ; i ++ ) { TJ = command . Substring ( i , 1 ) ; A = Decimal . ToInt32 ( char . Parse ( TJ ) ) ^ A ; } FCS = A . ToString ( " " ) ; if ( FCS . Length == 1 ) { FCS = " " + FCS ; } }
Get the FCS value based on command
Get the FCS value based on command
command
string