Problems calculating LRC

998 views Asked by At

I'm trying to calculate the LRC value (Longitudinal Redundancy Check) in order to send a message to a pinpad.

All I know about LRC is: "It is calculated by performing an XOR of all the characters in the message, excluding the STX in the calculation."

I'm using this function to generate the LRC:

 Public Shared Function calculateLRC(bytes As Byte()) As Byte
    Dim LRC As Byte = 0
    For i As Integer = 0 To bytes.Length - 1
        LRC = LRC Xor bytes(i)
    Next
    Return CByte(LRC)
End Function

But I can't make that the pinpad answers me.

Now, I know that I have to send the message in HEX but I can't make that the pinpad answers me and I can't figure out if I have a problem calculating the LRC or i am making something else wrong.

The format is asked this way: < STX > < type of msg> < param>< ETX>< LRC>.

I already tried to calculate the LRC first and then convert everything to hex AND convert everything to hexa and then calculate the LRC but nohing works.

Any help is appreciated.

Edit: Ok, the LRC is ok. The issue is with the way i'm sending the data (mostly because I have so little documentation and I'm just trying everthing I can think of)

I'm gonna try to think how to explain the issues here cause, like I say, I have a very poor documentation and it is in spanish.

0

There are 0 answers