任何人都可以帮助我如何在VB.NET中检查LRC [英] Can any one help me that how to check LRC in VB.NET
问题描述
嗨我对vb.net完全陌生你可以为我提供源代码并附上说明
我尝试了什么: < br $>
i没有尝试任何东西
Dim SampleMessage()As Byte = {& H2,& H0,& H35,& H30,& H30,& H30,& H30,& H30,& H30,& H30,& H30,& H30, & H30,& H30,& H30,_
& H32,& H30,& H30,& H30,& H30,& H1C,& H34,& H30,& H0,& H12,_
& H30,& H30,& H30,& H30,& H30,& H30,& H30,& H31,& H32,& H38,& H30,& H30,_
$ b $& H1C,& H3,& H19}
>
mySerialPort.Write(SampleMessage,0,40)
Dim TerminalACK( 2)作为Byte
'mySerialPort。 ReadTimeout = 10000
'mySerialPort.Read(TerminalACK,0,1)
mySerialPort.Close()
i需要检查LRC的输出
LRC(或纵向冗余校验)非常简单:所有你要做的就是对每一个被确认的字节进行异或一起!
Dim lrc As < span class =code-keyword>字节 = 0
对于 < span class =code-keyword>每个 b 作为 字节 在 sampleMessage
lrc = lrc Xor b
Next < /跨度>
hi i am totally new to vb.net can you provide source code for me with explanation
What I have tried:
i haven't tried anything
Dim SampleMessage() As Byte = {&H2, &H0, &H35, &H30, &H30, &H30, &H30, &H30, &H30, &H30, &H30, &H30, &H30, &H30, &H30, _
&H32, &H30, &H30, &H30, &H30, &H1C, &H34, &H30, &H0, &H12, _
&H30, &H30, &H30, &H30, &H30, &H30, &H30, &H31, &H32, &H38, &H30, &H30, _
&H1C, &H3, &H19}
mySerialPort.Write(SampleMessage, 0, 40)
Dim TerminalACK(2) As Byte
'mySerialPort.ReadTimeout = 10000
'mySerialPort.Read(TerminalACK, 0, 1)
mySerialPort.Close()
i need to check the LRC for this output
LRC (Or Longitudinal Redundancy Check) is very simple: all you have to do is XOR each of the bytes being confirmed together!
Dim lrc As Byte = 0 For Each b As Byte In sampleMessage lrc = lrc Xor b Next
这篇关于任何人都可以帮助我如何在VB.NET中检查LRC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!