I am developing instrument driver and I want to know how to calculate checksum for a Laboratory Information System (LIS) frame.
Explanation:
Expressed by characters [0-9] and [A-F].
Characters beginning from the character after [STX] and until [ETB] or [ETX] (including [ETB] or [ETX]) are added in binary.
The 2-digit numbers, which represent the least significant 8 bits in hexadecimal code, are converted to ASCII characters [0-9] and [A-F].
The most significant digit is stored in CHK1 and the least significant digit in CHK2.
This is sample frame :
<STX>2Q|1|2^1||||20011001153000<CR><ETX><CHK1><CHK2><CR><LF>
and I want to know what is value of chk1 and chk2 and I am new in this so I am totally blank about how to calculate checksum
I am not getting above 3rd and 4th point.
Can anyone provide sample code for c#?
Best Answer
Speaking as someone who has developed an entire LIS communication protocol from serial driver to strongly typed entities for a machine used in hundreds of different labs.
I've come to a lot of conclusions (short list):
That being said:
http://www.hendricksongroup.com/code_003.aspx
Is a really simple example of how to calculate a checksum for an LIS frame.
If you are writing an LIS Driver my advice to you is to get LOTS of logs from the vendor (so that you may see exactly the communication taking place) you are connecting to and write LOTS of unit tests to match those logs, (that and if it needs to be for more than one vendor to make it EXTREMELY flexible). Oh and add lots of logging for yourself.