初始化

This commit is contained in:
2025-12-11 10:55:32 +08:00
commit 14c4a121a2
111 changed files with 92565 additions and 0 deletions

30
RS485Loader/CRC16.vb Normal file
View File

@@ -0,0 +1,30 @@
Public Class CRC16
Public Shared Function NetCRC16(ByRef buffer() As Byte, ByVal offset As UInt32, ByVal len As Integer, ByRef logstr As String) As UInt16
Dim xda As UInt16
Dim xdapoly As UInt16
Dim i As Integer
Dim j As Integer
Dim xdabit As UInt16
xda = &HFFFF
xdapoly = &HA001
For i = 0 To (len - 1)
xda = xda Xor buffer(offset)
'logstr += Hex(buffer(offset)).PadLeft(2, "0")
'logstr += " "
offset += 1
For j = 0 To 7
xdabit = CByte(xda And &H1)
xda = xda \ 2
If xdabit > 0 Then
xda = xda Xor xdapoly
End If
Next
Next
Return xda
End Function
End Class