Unified · Split
| @@ -154,7 +154,7 @@ namespace GSF.PhasorProtocols.IEEEC37_118 · 153 unmodified lines | |||
| 154 | byte[] image = this.BinaryImage(); | 154 | byte[] image = this.BinaryImage(); |
| 155 | int imageLength = image.Length; | 155 | int imageLength = image.Length; |
| 156 | 156 | ||
| 157 | if (imageLength < MaxFrameLength) | 157 | if (imageLength <= MaxFrameLength) |
| 158 | { | 158 | { |
| 159 | // Full image fits within one frame, return current image as-is | 159 | // Full image fits within one frame, return current image as-is |
| 160 | yield return image; | 160 | yield return image; |
| @@ -202,14 +202,18 @@ namespace GSF.PhasorProtocols.IEEEC37_118 · 41 unmodified lines | |||
| 202 | 202 | ||
| 203 | if (firstFrame) | 203 | if (firstFrame) |
| 204 | { | 204 | { |
| 205 | byte[] frame = image.BlockCopy(0, frameSize); | 205 | // Copy in FRAMESIZE for first frame (should always be 65535) |
| 206 | BigEndian.CopyBytes((ushort)frameSize, image, 2); | ||
| 206 | 207 | ||
| 207 | // Initial frame already has full header, replace CONT_IDX with a value of 1 | 208 | // Initial frame already has full header, replace CONT_IDX with a value of 1 |
| 208 | // that indicates this is the first frame in a series of frames that follow: | 209 | // that indicates this is the first frame in a series of frames that follow: |
| 209 | Buffer.BlockCopy(BigEndian.GetBytes(continuationIndex), 0, frame, CommonFrameHeader.FixedLength, 2); | 210 | Buffer.BlockCopy(BigEndian.GetBytes(continuationIndex), 0, image, CommonFrameHeader.FixedLength, 2); |
| 210 | 211 | ||
| 212 | // Fix CRC of cumulative image with updated initial frame header | ||
| 213 | BigEndian.CopyBytes(CalculateChecksum(image, 0, imageLength - 2), image, imageLength - 2); | ||
| 214 | |||
| 211 | // Return first frame | 215 | // Return first frame |
| 212 | yield return frame; | 216 | yield return image.BlockCopy(0, frameSize); |
| 213 | } | 217 | } |
| 214 | else | 218 | else |
| 215 | { | 219 | { |
| @@ -217,7 +221,10 @@ namespace GSF.PhasorProtocols.IEEEC37_118 · 1 unmodified line | |||
| 217 | 221 | ||
| 218 | // Copy fixed header bytes into frame | 222 | // Copy fixed header bytes into frame |
| 219 | Buffer.BlockCopy(header, 0, frame, 0, CommonFrameHeader.FixedLength); | 223 | Buffer.BlockCopy(header, 0, frame, 0, CommonFrameHeader.FixedLength); |
| 220 | 224 | ||
| 225 | // Copy FRAMESIZE into frame | ||
| 226 | BigEndian.CopyBytes((ushort)frame.Length, frame, 2); | ||
| 227 | |||
| 221 | // Copy CONT_IDX into frame | 228 | // Copy CONT_IDX into frame |
| 222 | Buffer.BlockCopy(BigEndian.GetBytes(continuationIndex), 0, frame, CommonFrameHeader.FixedLength, 2); | 229 | Buffer.BlockCopy(BigEndian.GetBytes(continuationIndex), 0, frame, CommonFrameHeader.FixedLength, 2); |
| 223 | 230 | ||
| @@ -268,6 +275,9 @@ namespace GSF.PhasorProtocols.IEEEC37_118 · 44 unmodified lines | |||
| 268 | length = frameImages.BinaryLength; | 275 | length = frameImages.BinaryLength; |
| 269 | startIndex = 0; | 276 | startIndex = 0; |
| 270 | 277 | ||
| 278 | // Fix parsed binary length to be the cumulative frame image length | ||
| 279 | State.ParsedBinaryLength = length; | ||
| 280 | |||
| 271 | // Base class will check CRC for entire image | 281 | // Base class will check CRC for entire image |
| 272 | return base.ParseBinaryImage(buffer, startIndex, length); | 282 | return base.ParseBinaryImage(buffer, startIndex, length); |
| 273 | } | 283 | } |