I have a console application that is communicating with a custom machine through RS232 Comm port. According to documentation of the machine there are commands such as
- Start machine Command:DC1
Complete Command:'STX' STN 'DC1' 'ETX' BCC
hex codes(02 31 11 03 47) - Stop machine Command:DC2
Complete Command:'STX' STN 'DC2' 'ETX' BCC
hex codes(02 31 12 03 48)
I am able to start and stop machine with this:
byte[] _startMachine = new byte[] { 0x02, 0x31, 0x11, 0x03, 0x47 };
_serialPort.Write(_startMachine, 0, _startMachine.Length);
byte[] _stopMachine = new byte[] { 0x02, 0x31, 0x12, 0x03, 0x48 };
_serialPort.Write(_stopMachine, 0, _stopMachine.Length);
However I am stuck on this command
4. Read out batch total Command: DC4
Complete command:'STX' STN 'DC4' 'ETX' BCC
hex codes(02 31 14 03 4A)
Following the previous logic I am assuming that this should work.
byte[] _getBatchTotal = new byte[] { 0x02, 0x31, 0x14, 0x03, 0x4A };
_serialPort.Write(_getBatchTotal, 0, _getBatchTotal.Length);
I am following the same logic but I think the tricky part is the end of the command, am I translating the hex correctly?
Not sure if thats mistake in the documentation but it is also written that the everywhere used BCC (= Block Check Character) is calculated as sum of all bytes already read (incl. STX and ETX) . So for example starting machine command is simply Example: STX STN DC1 ETX BCC HEX: 02+31+11+03 == 47
Why is the BCC of the read batch command in this weird format then '4A'. Thank you.