update page now

Voting

: max(eight, six)?
(Example: nine)

The Note You're Voting On

toggio at writeme dot com
9 years ago
A faster implementation of modbus CRC16

function crc16($data)
 {
   $crc = 0xFFFF;
   for ($i = 0; $i < strlen($data); $i++)
   {
     $crc ^=ord($data[$i]);
     
        for ($j = 8; $j !=0; $j--)
        {
            if (($crc & 0x0001) !=0)
            {
                $crc >>= 1;
                $crc ^= 0xA001;
            }
            else
                $crc >>= 1;
        }
    }    
   return $crc;
 }

<< Back to user notes page

To Top