Merhaba arkadaşlar ;
STM32L'nin hardware CRC'sini kullanıyorum. Referance Manuel'inde belirtildiği üzere CRC32 kullanıyor.
Uses CRC-32 (Ethernet) polynomial: 0x4C11DB7
– X32 + X26 + X23 + X22 + X16 + X12 + X11 + X10 +X8 + X7 + X5 + X4 + X2+ X +1
Bunun için kullandığınız online crc hesaplayıcısı var mı acaba ? Birde bu yapının formülü hazırda var mıdır acaba ? C# yazılımı ile online 'dan da kurtulmak istiyorum açıkçası
http://www.coskunergan.com/bin-dosyalari-icin-crc32-hesaplama-yazilimi-c/ (http://www.coskunergan.com/bin-dosyalari-icin-crc32-hesaplama-yazilimi-c/)
Alıntı yapılan: X-Fi - 29 Ocak 2015, 09:33:36
http://www.coskunergan.com/bin-dosyalari-icin-crc32-hesaplama-yazilimi-c/ (http://www.coskunergan.com/bin-dosyalari-icin-crc32-hesaplama-yazilimi-c/)
Teşekkürler hocam inceleyeceğim :)
STM32L için aşağıdaki linkteki algoritmayı kullandım ;
https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/CRC%20computation&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=4051 (https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/CRC%20computation&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=4051)
C#'a dönüştürülmüş hali bu;
public const UInt32 DefaultPolynomial = 0x04C11DB7;
bool IsBitSet(UInt32 b, int pos)
{
return (b & (1 << pos)) != 0;
}
private UInt32 Crc32(UInt32[] numbers, int number_of_bytes)
{
UInt32 result=0xFFFFFFFF;
int sayac = 0,i;
while (number_of_bytes > 0)
{
result = result ^ numbers[sayac];
for (i = 0; i < 32; i++)
{
// Check MSB Value of given byte
if (IsBitSet(result,31))
result = (result << 1) ^ DefaultPolynomial; // Polynomial used in STM32L
else
result = (result << 1);
}
sayac++;
number_of_bytes--;
}
return result;
}
private void button1_Click(object sender, EventArgs e)
{
string text = 00000000;
UInt32[] test = StringTo32ByteArray(text);
UInt32 sonuc = Crc32(test, test.Length);
}
public static UInt32[] StringTo32ByteArray(string hex)
{
return Enumerable.Range(0, hex.Length)
.Where(x => x % 8 == 0)
.Select(x => Convert.ToUInt32(hex.Substring(x, 8), 16))
.ToArray();
}