History

GSF.PhasorProtocols: Fixed issues with CFG3 parsing/generation related to proper appliction of FRAMESIZE field when spanning multiple frames.

J. Ritchie Carroll committed 5 years ago

Commit a780a471 parent 50b521c1 file · +16 −6Browse files

Unified · Split

Source/Libraries/GSF.PhasorProtocols/IEEEC37_118/ConfigurationFrame3.cs+16−6
@@ -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-is159 // 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 1208 // 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 frame215 // Return first frame
212 yield return frame;216 yield return image.BlockCopy(0, frameSize);
213 }217 }
214 else218 else
215 {219 {
@@ -217,7 +221,10 @@ namespace GSF.PhasorProtocols.IEEEC37_118 · 1 unmodified line
217 221
218 // Copy fixed header bytes into frame222 // 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 frame228 // 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 image281 // Base class will check CRC for entire image
272 return base.ParseBinaryImage(buffer, startIndex, length);282 return base.ParseBinaryImage(buffer, startIndex, length);
273 }283 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t