Thanks Vasile, I don't get the input of this function, It says "byte in", and function is "read_byte_with_crc". If there is CRC data for this byte, the input would be more then one byte.
How would you like it to be implemented? Do you like how I have done it: function crc_3_byte_create(byte in polynomial, byte in data) function crc_3_byte_verify(byte in polynomial, byte in data, byte in crc) Should the CRC data be inputted as a separate byte, or should it be part of the data? Should I allow the user to enter a polynomial as I have, or should it be set? What is everyone's preference? Matt. On Mar 9, 1:32 am, vasile surducan <[email protected]> wrote: > Nice library Matt! > > Please take a look how this guy implemented an X^8 + X^5 + X^4 + 1 CRC in > DS18B20 library: > > function d1w_read_byte_with_CRC( byte in nbre_byte )return bit is > > var byte bb = 0, n = 0 , crcbyte = 0 -- ! crcbyte must be set to 0 > var bit bb_bit0 at bb : 0 > var bit crcbyte_bit0 at crcbyte : 0 , crcbyte_bit2 at crcbyte : 2 > var bit crcbyte_bit3 at crcbyte : 3 , crcbyte_bit7 at crcbyte : 7 > var bit crcbit > > for nbre_byte loop -- 8 bytes for ID, 9 bytes for read temp > > d1w_read_byte( bb ) > > n = n + 1 -- ène byte > if n == 1 then d1 = bb end if -- note d1 to d9 are globals > var > if n == 2 then d2 = bb end if -- > if n == 3 then d3 = bb end if -- > if n == 4 then d4 = bb end if -- > if n == 5 then d5 = bb end if > if n == 6 then d6 = bb end if > if n == 7 then d7 = bb end if > if n == 8 then d8 = bb end if > if n == 9 then d9 = bb end if > > -- ---calcul of crc--------------- > for 8 loop > crcbit = crcbyte_bit0 ^ bb_bit0 > crcbyte = crcbyte >> 1 > crcbyte_bit7 = crcbit > crcbyte_bit2 = crcbyte_bit2 ^ crcbit > crcbyte_bit3 = crcbyte_bit3 ^ crcbit > bb = bb >> 1 > end loop > -- --------------------------------- > > end loop > > if crcbyte == 0 then crcbit = true else crcbit = False end if -- crcbyte > must be 0 for crc without error > return crcbit > end function > > On Tue, Mar 9, 2010 at 7:11 AM, mattschinkel <[email protected]>wrote: > > > > > I have added a CRC library + Sample for error checking. Please give me > > your thoughts and suggestions. > > > To be honest, I may not be the best person to create such a library > > since CRC creation must be as fast, and as optimized as possible. > > Please let me know if there is a better way to create CRC data, and to > > verify it. At least I can start this library so others can add to it. > > > This library so far only has functions for 3-bit CRC, but I am sure > > there are other CRC types needed. > > > Wikipedia has a list of many popular crc types. It does not however > > show 3-bit which I currently need > >http://en.wikipedia.org/wiki/Cyclic_redundancy_check > > > I can think of many related things that use CRC, and I believe some of > > your libraries already do CRC? > > USB, sd cards, Ethernet.... > > > I currently need this library to send servo data from master to slave > > since an ISR may occur during transmission. > > > Matt. > > > -- > > You received this message because you are subscribed to the Google Groups > > "jallib" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<jallib%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/jallib?hl=en.- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
