Lantronix XPress-DR XPress-DR / XPress-DR-IAP - User Guide - Page 102

Calculating the Checksum, 2.5 Calculating the Two's Complement, Table 24 - Block Types

Page 102 highlights

UDP To get and set the node configuration, 120 bytes should be exchanged at once in 32-Byte records. The IP address in the record (bytes 0 to 3) will be ignored (unless the UDP FD command is being used). 8.2.4 Calculating the Checksum As mentioned in Table 24 - Block Types above, the last two characters of an Intel Hex setup record represent a checksum of the data in the line. Since the checksum is a two-digit hexadecimal value, it can represent a value from 0 to 255. The checksum is calculated by summing the value of the data on the line and taking the two's complement of the sum. Note: Do not include the leading colon or the checksum byte in the sum. Example: 0300300002337A1E Record length: 03 (3 bytes of data) Address: 0030 (the 3 bytes will be stored at 0030, 0031, and 0032) Record Type: 00 (normal data) Data: 02, 33, 7A Checksum: 1E 03 + 00 + 30 + 00+ 02 + 33 + 7A = E2 The two's complement of E2 is 1E. See Calculating the Two's Complement below. 8.2.5 Calculating the Two's Complement The two's complement of a number is the value that must be added to the number to reach a Hexadecimal value of 100 (256 in decimal). In the example above, E2 + 1E = 100. You can also calculate the two's complement by subtracting the sum from 100. Using the example above again, 100 - E2 = 1E. It may help to use a scientific calculator. 8-6 DSTni-XPress DR User Guide

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149

UDP
To get and set the node configuration, 120 bytes should be exchanged at once in 32-Byte
records. The IP address in the record (bytes 0 to 3) will be ignored (unless the UDP FD
command is being used).
8.2.4 Calculating the Checksum
As mentioned in
Table 24 - Block Types
above, the last two characters of an Intel Hex setup
record represent a checksum of the data in the line. Since the checksum is a two-digit
hexadecimal value, it can represent a value from 0 to 255.
The checksum is calculated by summing the value of the data on the line and taking the two°s
complement of the sum.
Note: Do not include the leading colon or the checksum byte in the sum.
Example:
0300300002337A1E
Record length: 03 (3 bytes of data)
Address: 0030 (the 3 bytes will be stored at 0030, 0031, and 0032)
Record Type: 00 (normal data)
Data: 02, 33, 7A
Checksum: 1E
03 + 00 + 30 + 00+ 02 + 33 + 7A = E2
The two°s complement of E2 is 1E. See
Calculating the Two’s Complement
below.
8.2.5 Calculating the Two’s Complement
The two°s complement of a number is the value that must be added to the number to reach a
Hexadecimal value of 100 (256 in decimal). In the example above, E2 + 1E = 100.
You can also calculate the two°s complement by subtracting the sum from 100. Using the
example above again, 100 - E2 = 1E. It may help to use a scientific calculator.
8-6
DSTni-XPress DR User Guide