поискавой системы для электроныых деталей |
|
CFA631 датащи(PDF) 72 Page - Crystalfontz America, Inc. |
|
CFA631 датащи(HTML) 72 Page - Crystalfontz America, Inc. |
72 / 81 page Crystalfontz Data Sheet Release 2014-11-17 www.crystalfontz.com CFA631 Intelligent Display Modules Page 72 'My understanding of visual basic is very limited--however it appears that there is no way 'to initialize an array of structures. Nice language. Fast processors, lots of memory, big 'disks, and we fill them up with this . . this . . this . . STUFF. Sub Initialize_CRC_Lookup_Table() crcLookupTable(0).Lo = &H0 crcLookupTable(0).Hi = &H0 . . . 'For purposes of brevity in this data sheet, I have removed 251 entries of this table, the 'full source is available in our forum: 'http://www.crystalfontz.com/forum/showthread.php?postid=9921#post9921 . . . crcLookupTable(255).Lo = &H78 crcLookupTable(255).Hi = &HF End Sub 'This function returns the CRC of the array at data for length positions Private Function Get_Crc(ByRef data() As Byte, ByVal length As Integer) As WORD Dim Index As Integer Dim Table_Index As Integer Dim newCrc As WORD newCrc.Lo = &HFF newCrc.Hi = &HFF For Index = 0 To length - 1 'exclusive-or the input byte with the low-order byte of the CRC register 'to get an index into crcLookupTable Table_Index = newCrc.Lo Xor data(Index) 'shift the CRC register eight bits to the right newCrc.Lo = newCrc.Hi newCrc.Hi = 0 ' exclusive-or the CRC register with the contents of Table at Table_Index newCrc.Lo = newCrc.Lo Xor crcLookupTable(Table_Index).Lo newCrc.Hi = newCrc.Hi Xor crcLookupTable(Table_Index).Hi Next Index 'Invert & return newCrc Get_Crc.Lo = newCrc.Lo Xor &HFF Get_Crc.Hi = newCrc.Hi Xor &HFF End Function Private Sub Send_Packet(ByRef packet As PACKET_STRUCT) Dim Index As Integer 'Need to put the whole packet into a linear array 'since you can’t do type overrides. VB, gotta love it. Dim linear_array(26) As Byte linear_array(0) = packet.command linear_array(1) = packet.data_length For Index = 0 To packet.data_length - 1 linear_array(Index + 2) = packet.data(Index) Next Index packet.crc = Get_Crc(linear_array, packet.data_length + 2) 'Might as well move the CRC into the linear array too linear_array(packet.data_length + 2) = packet.crc.Lo linear_array(packet.data_length + 3) = packet.crc.Hi 'Now a simple loop can dump it out the port. For Index = 0 To packet.data_length + 3 MSComm.Output = Chr(linear_array(Index)) Next Index End Sub Algorithm 5: “Java” Table Implementation This code was posted in our forum by user “norm” as a working example of a Java CRC calculation. public class CRC16 extends Object { public static void main(String[] args) { byte[] data = new byte[2]; |
Аналогичный номер детали - CFA631 |
|
Аналогичное описание - CFA631 |
|
|
ссылки URL |
Конфиденциальность |
ALLDATASHEETRU.COM |
Вашему бизинису помогли Аллдатащит? [ DONATE ] |
Что такое Аллдатащит | реклама | контакт | Конфиденциальность | обмен ссыками | поиск по производителю All Rights Reserved©Alldatasheet.com |
Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
Family Site : ic2ic.com |
icmetro.com |