Hi again.
Sorry for the delay, but I was in the delegation.
The description of BCC in the manual (translated from original Spanish) is as follows:
BCC = Four hexadecimales. Binary sum of all prior bytes
In my opinion the binary sum of all bytes is nothing but the sum of the ASCII codes of each character in the string.
From a mathematical point of view, it does not matter if we add up the number of binary, hexadecimal or decimal notation. The sum should always be the same.
For example:
the sum in binary notation : 101 + 110 = 1011; decimal = 11
the sum in decimal notation: 5 + 6 = 11
I'm surprised the given example, because the sum of all bytes (from [STX] to [ETX]) results in a hexadecimal notation 0554, not 0054.
Example according to andyglezl
DecToHexa (BIntODEC (DecToBin (asciisum ("123"))))
is OK, but shorter is
NTOC( AsciiSum ( cSent ), 16, 4, '0' )
Code: Select all
STX:=CHR(2)
ESC:=CHR(27)
FS:=CHR(28)
ETX:=CHR(3)
cSent:=STX+'1'+ESC+'*'+FS+'0000'+FS+'0000'+FS+'0004'+FS+'3'+FS+'83'+FS+'81'+FS+'2'+FS+'0'+FS+'0'+ETX
BCC:=NTOC( AsciiSum ( cSent ), 16, 4, '0' ) // => '0554'
Manufacturer fiscal printer does not provide any libraries to operate the device?
Edward.