It smells something along the lines of Modbus...
Go here to get an idea as to the Poly (BTW, using a polynomial is a clear indication that should this actually be Modbus, then it's of the RTU flavor).
https://ghsi.de/CRC/
Next, get yourself a free Modbus monitoring program. I've included this link which I came across just the other day, it (along with Modbus DLLs) includes a monitoring program:
http://sites.google.com/site/shortbusdll
Or here:
http://www.modbusdriver.com/modpoll.html
Since it's likely that your PLC is doing nothing more with the data than decoding measurements, you don't need much in the way of a PLC driver. Something to decode the incoming message, and something to spit out the ACK back to the gauge.
No need for a protocol analyzer, unless you just want one, and this is a pretty good excuse.
Just tap into the 485/422 as you would with any other device on a Modbus network and listen in.
That said, I would forego the Modbus program and listen in using ReatTerm. While the setup here resembles Modbus, the CRC calculation doesn't follow either the RTU CRC (which uses Polys and shifting), or the ASCII LRC (simple XOR).
If you do log responses, be sure to post them here.
.
Here's my CRC routine (written in PowerBasic). It's my interpretation of a "standard" Modbus CRC routine. Notice that it uses a different (but standard for the Modbus world) Poly than the one in your code. So while it may be Modbus-like, I sense a bit of divergence (nothing all that unusual in the Modbus world). No byte swap or shifting either.
So that one way of doing it, and to the best of my recollection, it works.
Here's a discussion of the CRC16 code in (more or less) plain English:
http://www.control.com/thread/1026148035
So the bottom line is that you will have to do it their way. But you have the source, it shouldn't be too hard. Like I said, snoop in on the transmissions and post the results here.
Go here to get an idea as to the Poly (BTW, using a polynomial is a clear indication that should this actually be Modbus, then it's of the RTU flavor).
https://ghsi.de/CRC/
Next, get yourself a free Modbus monitoring program. I've included this link which I came across just the other day, it (along with Modbus DLLs) includes a monitoring program:
http://sites.google.com/site/shortbusdll
Or here:
http://www.modbusdriver.com/modpoll.html
Since it's likely that your PLC is doing nothing more with the data than decoding measurements, you don't need much in the way of a PLC driver. Something to decode the incoming message, and something to spit out the ACK back to the gauge.
No need for a protocol analyzer, unless you just want one, and this is a pretty good excuse.
Just tap into the 485/422 as you would with any other device on a Modbus network and listen in.
That said, I would forego the Modbus program and listen in using ReatTerm. While the setup here resembles Modbus, the CRC calculation doesn't follow either the RTU CRC (which uses Polys and shifting), or the ASCII LRC (simple XOR).
If you do log responses, be sure to post them here.
.
Here's my CRC routine (written in PowerBasic). It's my interpretation of a "standard" Modbus CRC routine. Notice that it uses a different (but standard for the Modbus world) Poly than the one in your code. So while it may be Modbus-like, I sense a bit of divergence (nothing all that unusual in the Modbus world). No byte swap or shifting either.
Code:
Sub CRC16ComputeB (MBStr$, Poly As Word, CRC As Word) 'calculate the CRC treating each character as one byte (Binary).
Dim tCRC As Word
Dim b$
Dim i%
If MBStr$ = "" Then Exit Sub 'Not too much that we can do with an empty string.
tCRC = &hFFFF 'Seed tCRC with -1
Do While MBStr$ <> ""
b$ = Left$(MBStr$,1) 'Grab a character.
MBStr$ = Right$(MBStr$, Len(MBStr$) - 1) 'Now remove it from MBStr$
tCRC = tCRC Xor Asc(b$) 'Xor tCRC with the first byte
For i% = 1 To 8 'If tCRC is an odd number, we need to shift it right on place and Xor it with the Polynominal (in this case, &hA001)
If (tCRC And 1) = 1 Then
Shift Right tCRC, 1
tCRC = tCRC Xor Poly
Else
Shift Right tCRC, 1 'Otherwise, just shift it right one bit.
End If
Next i%
Wend
MBStr$ = Hex$(tCRC) 'The result needs to be byte-swapped (little endian to big endian) for the Modbus world
MBStr$ = Right$(MBStr$, 2) + Left$(MBStr$, 2) 'This gets the string swapped
CRC = Val("&h" + MBStr$) 'And this gets you the actual value.
FF_TextBox_SetText (ByVal HWND_FORM1_TXTMODBUSCRC, ByVal MBStr$)
End Sub
Here's a discussion of the CRC16 code in (more or less) plain English:
http://www.control.com/thread/1026148035
So the bottom line is that you will have to do it their way. But you have the source, it shouldn't be too hard. Like I said, snoop in on the transmissions and post the results here.