Code Menghitung LRC dengan C#

Metode pengecekan LRC digunakan  pada  data yg dikirim  MODBUS  mode ASCII (text) .

 public static byte calculateLRC(byte[] bytes)
       {
           /* https://gist.github.com/953550
            * http://en.wikipedia.org/wiki/Longitudinal_redundancy_check
            */
           byte LRC = (byte)0;
           for (int i = 0; i < bytes.Length; i++)
           {
               LRC ^= bytes[i];
           }
           return LRC;
       }

sumber:
http://en.wikipedia.org/wiki/Longitudinal_redundancy_check
Advertisements

About pccontrol

Berisi Tutorial Menggunakan PC untuk mengontrol Peralatan dengan cara mudah & praktis untuk pemula.

Posted on 29/11/2011, in Tips & Trik. Bookmark the permalink. Leave a comment.

Komentar ,Saran atau Pertanyaan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: