The goal of this software is to automatically generate C/C++ code which reads and writes GOOSE and Sampled Value packets. Any valid IEC 61850 Substation Configuration Description (SCD) file, describing GOOSE and/or SV communications, can be used as the input. The output code is lightweight and platform-independent, so it can run on a variety of devices, including low-cost microcontrollers. It\'s ideal for rapid-prototyping new protection and control systems that require communications. This mbed project is a simple example of this functionality. Other code: https://github.com/stevenblair/rapid61850 Project homepage: http://personal.strath.ac.uk/steven.m.blair/
gseEncode.c@1:9399d44c2b1a, 2011-10-07 (annotated)
- Committer:
- sblair
- Date:
- Fri Oct 07 13:48:18 2011 +0000
- Revision:
- 1:9399d44c2b1a
- Parent:
- 0:230c10b228ea
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sblair | 1:9399d44c2b1a | 1 | /** |
sblair | 1:9399d44c2b1a | 2 | * Rapid-prototyping protection schemes with IEC 61850 |
sblair | 1:9399d44c2b1a | 3 | * |
sblair | 1:9399d44c2b1a | 4 | * Copyright (c) 2011 Steven Blair |
sblair | 1:9399d44c2b1a | 5 | * |
sblair | 1:9399d44c2b1a | 6 | * This program is free software; you can redistribute it and/or |
sblair | 1:9399d44c2b1a | 7 | * modify it under the terms of the GNU General Public License |
sblair | 1:9399d44c2b1a | 8 | * as published by the Free Software Foundation; either version 2 |
sblair | 1:9399d44c2b1a | 9 | * of the License, or (at your option) any later version. |
sblair | 1:9399d44c2b1a | 10 | |
sblair | 1:9399d44c2b1a | 11 | * This program is distributed in the hope that it will be useful, |
sblair | 1:9399d44c2b1a | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
sblair | 1:9399d44c2b1a | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
sblair | 1:9399d44c2b1a | 14 | * GNU General Public License for more details. |
sblair | 1:9399d44c2b1a | 15 | |
sblair | 1:9399d44c2b1a | 16 | * You should have received a copy of the GNU General Public License |
sblair | 1:9399d44c2b1a | 17 | * along with this program; if not, write to the Free Software |
sblair | 1:9399d44c2b1a | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
sblair | 1:9399d44c2b1a | 19 | */ |
sblair | 1:9399d44c2b1a | 20 | |
sblair | 1:9399d44c2b1a | 21 | #include "gseEncodeBasic.h" |
sblair | 1:9399d44c2b1a | 22 | #include "ied.h" |
sblair | 0:230c10b228ea | 23 | #include "gseEncode.h" |
sblair | 0:230c10b228ea | 24 | |
sblair | 0:230c10b228ea | 25 | |
sblair | 0:230c10b228ea | 26 | |
sblair | 1:9399d44c2b1a | 27 | int ber_get_length_myAnalogValue(struct myAnalogValue *myAnalogValue) { |
sblair | 1:9399d44c2b1a | 28 | int total = 0; |
sblair | 1:9399d44c2b1a | 29 | int len = 0; |
sblair | 1:9399d44c2b1a | 30 | |
sblair | 1:9399d44c2b1a | 31 | len = BER_GET_LENGTH_CTYPE_FLOAT32(&myAnalogValue->f); |
sblair | 1:9399d44c2b1a | 32 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 33 | |
sblair | 1:9399d44c2b1a | 34 | return total; |
sblair | 0:230c10b228ea | 35 | } |
sblair | 1:9399d44c2b1a | 36 | int ber_encode_myAnalogValue(unsigned char *buf, struct myAnalogValue *myAnalogValue) { |
sblair | 1:9399d44c2b1a | 37 | int offset = 0; |
sblair | 1:9399d44c2b1a | 38 | |
sblair | 1:9399d44c2b1a | 39 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 40 | offset += encodeLength(&buf[offset], ber_get_length_myAnalogValue(myAnalogValue)); |
sblair | 1:9399d44c2b1a | 41 | |
sblair | 1:9399d44c2b1a | 42 | offset += BER_ENCODE_CTYPE_FLOAT32(&buf[offset], &myAnalogValue->f); |
sblair | 1:9399d44c2b1a | 43 | |
sblair | 1:9399d44c2b1a | 44 | return offset; |
sblair | 0:230c10b228ea | 45 | } |
sblair | 1:9399d44c2b1a | 46 | int ber_get_length_ScaledValueConfig(struct ScaledValueConfig *ScaledValueConfig) { |
sblair | 1:9399d44c2b1a | 47 | int total = 0; |
sblair | 1:9399d44c2b1a | 48 | int len = 0; |
sblair | 1:9399d44c2b1a | 49 | |
sblair | 1:9399d44c2b1a | 50 | len = BER_GET_LENGTH_CTYPE_FLOAT32(&ScaledValueConfig->scaleFactor); |
sblair | 1:9399d44c2b1a | 51 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 52 | len = BER_GET_LENGTH_CTYPE_FLOAT32(&ScaledValueConfig->offset); |
sblair | 1:9399d44c2b1a | 53 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 54 | |
sblair | 1:9399d44c2b1a | 55 | return total; |
sblair | 0:230c10b228ea | 56 | } |
sblair | 1:9399d44c2b1a | 57 | int ber_encode_ScaledValueConfig(unsigned char *buf, struct ScaledValueConfig *ScaledValueConfig) { |
sblair | 1:9399d44c2b1a | 58 | int offset = 0; |
sblair | 1:9399d44c2b1a | 59 | |
sblair | 1:9399d44c2b1a | 60 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 61 | offset += encodeLength(&buf[offset], ber_get_length_ScaledValueConfig(ScaledValueConfig)); |
sblair | 1:9399d44c2b1a | 62 | |
sblair | 1:9399d44c2b1a | 63 | offset += BER_ENCODE_CTYPE_FLOAT32(&buf[offset], &ScaledValueConfig->scaleFactor); |
sblair | 1:9399d44c2b1a | 64 | offset += BER_ENCODE_CTYPE_FLOAT32(&buf[offset], &ScaledValueConfig->offset); |
sblair | 1:9399d44c2b1a | 65 | |
sblair | 1:9399d44c2b1a | 66 | return offset; |
sblair | 0:230c10b228ea | 67 | } |
sblair | 1:9399d44c2b1a | 68 | int ber_get_length_myVector(struct myVector *myVector) { |
sblair | 1:9399d44c2b1a | 69 | int total = 0; |
sblair | 1:9399d44c2b1a | 70 | int len = 0; |
sblair | 1:9399d44c2b1a | 71 | |
sblair | 1:9399d44c2b1a | 72 | len = ber_get_length_myAnalogValue(&myVector->mag); |
sblair | 1:9399d44c2b1a | 73 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 74 | len = ber_get_length_myAnalogValue(&myVector->ang); |
sblair | 1:9399d44c2b1a | 75 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 76 | |
sblair | 1:9399d44c2b1a | 77 | return total; |
sblair | 0:230c10b228ea | 78 | } |
sblair | 1:9399d44c2b1a | 79 | int ber_encode_myVector(unsigned char *buf, struct myVector *myVector) { |
sblair | 1:9399d44c2b1a | 80 | int offset = 0; |
sblair | 1:9399d44c2b1a | 81 | |
sblair | 1:9399d44c2b1a | 82 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 83 | offset += encodeLength(&buf[offset], ber_get_length_myVector(myVector)); |
sblair | 1:9399d44c2b1a | 84 | |
sblair | 1:9399d44c2b1a | 85 | offset += ber_encode_myAnalogValue(&buf[offset], &myVector->mag); |
sblair | 1:9399d44c2b1a | 86 | offset += ber_encode_myAnalogValue(&buf[offset], &myVector->ang); |
sblair | 1:9399d44c2b1a | 87 | |
sblair | 1:9399d44c2b1a | 88 | return offset; |
sblair | 0:230c10b228ea | 89 | } |
sblair | 1:9399d44c2b1a | 90 | int ber_get_length_simpleVector(struct simpleVector *simpleVector) { |
sblair | 1:9399d44c2b1a | 91 | int total = 0; |
sblair | 1:9399d44c2b1a | 92 | int len = 0; |
sblair | 1:9399d44c2b1a | 93 | |
sblair | 1:9399d44c2b1a | 94 | len = ber_get_length_myAnalogValue(&simpleVector->mag); |
sblair | 1:9399d44c2b1a | 95 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 96 | len = ber_get_length_myAnalogValue(&simpleVector->ang); |
sblair | 1:9399d44c2b1a | 97 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 98 | |
sblair | 1:9399d44c2b1a | 99 | return total; |
sblair | 0:230c10b228ea | 100 | } |
sblair | 1:9399d44c2b1a | 101 | int ber_encode_simpleVector(unsigned char *buf, struct simpleVector *simpleVector) { |
sblair | 1:9399d44c2b1a | 102 | int offset = 0; |
sblair | 1:9399d44c2b1a | 103 | |
sblair | 1:9399d44c2b1a | 104 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 105 | offset += encodeLength(&buf[offset], ber_get_length_simpleVector(simpleVector)); |
sblair | 1:9399d44c2b1a | 106 | |
sblair | 1:9399d44c2b1a | 107 | offset += ber_encode_myAnalogValue(&buf[offset], &simpleVector->mag); |
sblair | 1:9399d44c2b1a | 108 | offset += ber_encode_myAnalogValue(&buf[offset], &simpleVector->ang); |
sblair | 1:9399d44c2b1a | 109 | |
sblair | 1:9399d44c2b1a | 110 | return offset; |
sblair | 0:230c10b228ea | 111 | } |
sblair | 1:9399d44c2b1a | 112 | int ber_get_length_myMod(struct myMod *myMod) { |
sblair | 1:9399d44c2b1a | 113 | int total = 0; |
sblair | 1:9399d44c2b1a | 114 | int len = 0; |
sblair | 1:9399d44c2b1a | 115 | |
sblair | 1:9399d44c2b1a | 116 | len = BER_GET_LENGTH_CTYPE_ENUM((CTYPE_ENUM *) &myMod->ctlVal); |
sblair | 1:9399d44c2b1a | 117 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 118 | len = BER_GET_LENGTH_CTYPE_ENUM((CTYPE_ENUM *) &myMod->stVal); |
sblair | 1:9399d44c2b1a | 119 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 120 | len = BER_GET_LENGTH_CTYPE_QUALITY(&myMod->q); |
sblair | 1:9399d44c2b1a | 121 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 122 | len = BER_GET_LENGTH_CTYPE_TIMESTAMP(&myMod->t); |
sblair | 1:9399d44c2b1a | 123 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 124 | |
sblair | 1:9399d44c2b1a | 125 | return total; |
sblair | 0:230c10b228ea | 126 | } |
sblair | 1:9399d44c2b1a | 127 | int ber_encode_myMod(unsigned char *buf, struct myMod *myMod) { |
sblair | 1:9399d44c2b1a | 128 | int offset = 0; |
sblair | 1:9399d44c2b1a | 129 | |
sblair | 1:9399d44c2b1a | 130 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 131 | offset += encodeLength(&buf[offset], ber_get_length_myMod(myMod)); |
sblair | 1:9399d44c2b1a | 132 | |
sblair | 1:9399d44c2b1a | 133 | offset += BER_ENCODE_CTYPE_ENUM(&buf[offset], (CTYPE_ENUM *) &myMod->ctlVal); |
sblair | 1:9399d44c2b1a | 134 | offset += BER_ENCODE_CTYPE_ENUM(&buf[offset], (CTYPE_ENUM *) &myMod->stVal); |
sblair | 1:9399d44c2b1a | 135 | offset += BER_ENCODE_CTYPE_QUALITY(&buf[offset], &myMod->q); |
sblair | 1:9399d44c2b1a | 136 | offset += BER_ENCODE_CTYPE_TIMESTAMP(&buf[offset], &myMod->t); |
sblair | 1:9399d44c2b1a | 137 | |
sblair | 1:9399d44c2b1a | 138 | return offset; |
sblair | 0:230c10b228ea | 139 | } |
sblair | 1:9399d44c2b1a | 140 | int ber_get_length_myHealth(struct myHealth *myHealth) { |
sblair | 1:9399d44c2b1a | 141 | int total = 0; |
sblair | 1:9399d44c2b1a | 142 | int len = 0; |
sblair | 1:9399d44c2b1a | 143 | |
sblair | 1:9399d44c2b1a | 144 | len = BER_GET_LENGTH_CTYPE_ENUM((CTYPE_ENUM *) &myHealth->stVal); |
sblair | 1:9399d44c2b1a | 145 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 146 | |
sblair | 1:9399d44c2b1a | 147 | return total; |
sblair | 0:230c10b228ea | 148 | } |
sblair | 1:9399d44c2b1a | 149 | int ber_encode_myHealth(unsigned char *buf, struct myHealth *myHealth) { |
sblair | 1:9399d44c2b1a | 150 | int offset = 0; |
sblair | 1:9399d44c2b1a | 151 | |
sblair | 1:9399d44c2b1a | 152 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 153 | offset += encodeLength(&buf[offset], ber_get_length_myHealth(myHealth)); |
sblair | 1:9399d44c2b1a | 154 | |
sblair | 1:9399d44c2b1a | 155 | offset += BER_ENCODE_CTYPE_ENUM(&buf[offset], (CTYPE_ENUM *) &myHealth->stVal); |
sblair | 1:9399d44c2b1a | 156 | |
sblair | 1:9399d44c2b1a | 157 | return offset; |
sblair | 0:230c10b228ea | 158 | } |
sblair | 1:9399d44c2b1a | 159 | int ber_get_length_myBeh(struct myBeh *myBeh) { |
sblair | 1:9399d44c2b1a | 160 | int total = 0; |
sblair | 1:9399d44c2b1a | 161 | int len = 0; |
sblair | 1:9399d44c2b1a | 162 | |
sblair | 1:9399d44c2b1a | 163 | len = BER_GET_LENGTH_CTYPE_ENUM((CTYPE_ENUM *) &myBeh->stVal); |
sblair | 1:9399d44c2b1a | 164 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 165 | |
sblair | 1:9399d44c2b1a | 166 | return total; |
sblair | 0:230c10b228ea | 167 | } |
sblair | 1:9399d44c2b1a | 168 | int ber_encode_myBeh(unsigned char *buf, struct myBeh *myBeh) { |
sblair | 1:9399d44c2b1a | 169 | int offset = 0; |
sblair | 1:9399d44c2b1a | 170 | |
sblair | 1:9399d44c2b1a | 171 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 172 | offset += encodeLength(&buf[offset], ber_get_length_myBeh(myBeh)); |
sblair | 1:9399d44c2b1a | 173 | |
sblair | 1:9399d44c2b1a | 174 | offset += BER_ENCODE_CTYPE_ENUM(&buf[offset], (CTYPE_ENUM *) &myBeh->stVal); |
sblair | 1:9399d44c2b1a | 175 | |
sblair | 1:9399d44c2b1a | 176 | return offset; |
sblair | 0:230c10b228ea | 177 | } |
sblair | 1:9399d44c2b1a | 178 | int ber_get_length_myINS(struct myINS *myINS) { |
sblair | 1:9399d44c2b1a | 179 | int total = 0; |
sblair | 1:9399d44c2b1a | 180 | int len = 0; |
sblair | 1:9399d44c2b1a | 181 | |
sblair | 1:9399d44c2b1a | 182 | len = BER_GET_LENGTH_CTYPE_INT32(&myINS->stVal); |
sblair | 1:9399d44c2b1a | 183 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 184 | |
sblair | 1:9399d44c2b1a | 185 | return total; |
sblair | 0:230c10b228ea | 186 | } |
sblair | 1:9399d44c2b1a | 187 | int ber_encode_myINS(unsigned char *buf, struct myINS *myINS) { |
sblair | 1:9399d44c2b1a | 188 | int offset = 0; |
sblair | 1:9399d44c2b1a | 189 | |
sblair | 1:9399d44c2b1a | 190 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 191 | offset += encodeLength(&buf[offset], ber_get_length_myINS(myINS)); |
sblair | 1:9399d44c2b1a | 192 | |
sblair | 1:9399d44c2b1a | 193 | offset += BER_ENCODE_CTYPE_INT32(&buf[offset], &myINS->stVal); |
sblair | 1:9399d44c2b1a | 194 | |
sblair | 1:9399d44c2b1a | 195 | return offset; |
sblair | 0:230c10b228ea | 196 | } |
sblair | 1:9399d44c2b1a | 197 | int ber_get_length_myLPL(struct myLPL *myLPL) { |
sblair | 1:9399d44c2b1a | 198 | int total = 0; |
sblair | 1:9399d44c2b1a | 199 | int len = 0; |
sblair | 1:9399d44c2b1a | 200 | |
sblair | 1:9399d44c2b1a | 201 | len = BER_GET_LENGTH_CTYPE_VISSTRING255(&myLPL->ldNs); |
sblair | 1:9399d44c2b1a | 202 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 203 | len = BER_GET_LENGTH_CTYPE_VISSTRING255(&myLPL->configRev); |
sblair | 1:9399d44c2b1a | 204 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 205 | |
sblair | 1:9399d44c2b1a | 206 | return total; |
sblair | 0:230c10b228ea | 207 | } |
sblair | 1:9399d44c2b1a | 208 | int ber_encode_myLPL(unsigned char *buf, struct myLPL *myLPL) { |
sblair | 1:9399d44c2b1a | 209 | int offset = 0; |
sblair | 1:9399d44c2b1a | 210 | |
sblair | 1:9399d44c2b1a | 211 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 212 | offset += encodeLength(&buf[offset], ber_get_length_myLPL(myLPL)); |
sblair | 1:9399d44c2b1a | 213 | |
sblair | 1:9399d44c2b1a | 214 | offset += BER_ENCODE_CTYPE_VISSTRING255(&buf[offset], &myLPL->ldNs); |
sblair | 1:9399d44c2b1a | 215 | offset += BER_ENCODE_CTYPE_VISSTRING255(&buf[offset], &myLPL->configRev); |
sblair | 1:9399d44c2b1a | 216 | |
sblair | 1:9399d44c2b1a | 217 | return offset; |
sblair | 0:230c10b228ea | 218 | } |
sblair | 1:9399d44c2b1a | 219 | int ber_get_length_myDPL(struct myDPL *myDPL) { |
sblair | 1:9399d44c2b1a | 220 | int total = 0; |
sblair | 1:9399d44c2b1a | 221 | int len = 0; |
sblair | 1:9399d44c2b1a | 222 | |
sblair | 1:9399d44c2b1a | 223 | len = BER_GET_LENGTH_CTYPE_VISSTRING255(&myDPL->vendor); |
sblair | 1:9399d44c2b1a | 224 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 225 | len = BER_GET_LENGTH_CTYPE_VISSTRING255(&myDPL->hwRev); |
sblair | 1:9399d44c2b1a | 226 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 227 | |
sblair | 1:9399d44c2b1a | 228 | return total; |
sblair | 0:230c10b228ea | 229 | } |
sblair | 1:9399d44c2b1a | 230 | int ber_encode_myDPL(unsigned char *buf, struct myDPL *myDPL) { |
sblair | 1:9399d44c2b1a | 231 | int offset = 0; |
sblair | 1:9399d44c2b1a | 232 | |
sblair | 1:9399d44c2b1a | 233 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 234 | offset += encodeLength(&buf[offset], ber_get_length_myDPL(myDPL)); |
sblair | 1:9399d44c2b1a | 235 | |
sblair | 1:9399d44c2b1a | 236 | offset += BER_ENCODE_CTYPE_VISSTRING255(&buf[offset], &myDPL->vendor); |
sblair | 1:9399d44c2b1a | 237 | offset += BER_ENCODE_CTYPE_VISSTRING255(&buf[offset], &myDPL->hwRev); |
sblair | 1:9399d44c2b1a | 238 | |
sblair | 1:9399d44c2b1a | 239 | return offset; |
sblair | 0:230c10b228ea | 240 | } |
sblair | 1:9399d44c2b1a | 241 | int ber_get_length_myPos(struct myPos *myPos) { |
sblair | 1:9399d44c2b1a | 242 | int total = 0; |
sblair | 1:9399d44c2b1a | 243 | int len = 0; |
sblair | 1:9399d44c2b1a | 244 | |
sblair | 1:9399d44c2b1a | 245 | len = BER_GET_LENGTH_CTYPE_DBPOS(&myPos->stVal); |
sblair | 1:9399d44c2b1a | 246 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 247 | len = BER_GET_LENGTH_CTYPE_QUALITY(&myPos->q); |
sblair | 1:9399d44c2b1a | 248 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 249 | len = BER_GET_LENGTH_CTYPE_TIMESTAMP(&myPos->t); |
sblair | 1:9399d44c2b1a | 250 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 251 | len = BER_GET_LENGTH_CTYPE_BOOLEAN(&myPos->ctlVal); |
sblair | 1:9399d44c2b1a | 252 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 253 | |
sblair | 1:9399d44c2b1a | 254 | return total; |
sblair | 0:230c10b228ea | 255 | } |
sblair | 1:9399d44c2b1a | 256 | int ber_encode_myPos(unsigned char *buf, struct myPos *myPos) { |
sblair | 1:9399d44c2b1a | 257 | int offset = 0; |
sblair | 1:9399d44c2b1a | 258 | |
sblair | 1:9399d44c2b1a | 259 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 260 | offset += encodeLength(&buf[offset], ber_get_length_myPos(myPos)); |
sblair | 1:9399d44c2b1a | 261 | |
sblair | 1:9399d44c2b1a | 262 | offset += BER_ENCODE_CTYPE_DBPOS(&buf[offset], &myPos->stVal); |
sblair | 1:9399d44c2b1a | 263 | offset += BER_ENCODE_CTYPE_QUALITY(&buf[offset], &myPos->q); |
sblair | 1:9399d44c2b1a | 264 | offset += BER_ENCODE_CTYPE_TIMESTAMP(&buf[offset], &myPos->t); |
sblair | 1:9399d44c2b1a | 265 | offset += BER_ENCODE_CTYPE_BOOLEAN(&buf[offset], &myPos->ctlVal); |
sblair | 1:9399d44c2b1a | 266 | |
sblair | 1:9399d44c2b1a | 267 | return offset; |
sblair | 0:230c10b228ea | 268 | } |
sblair | 1:9399d44c2b1a | 269 | int ber_get_length_mySPS(struct mySPS *mySPS) { |
sblair | 1:9399d44c2b1a | 270 | int total = 0; |
sblair | 1:9399d44c2b1a | 271 | int len = 0; |
sblair | 1:9399d44c2b1a | 272 | |
sblair | 1:9399d44c2b1a | 273 | len = BER_GET_LENGTH_CTYPE_INT32(&mySPS->stVal); |
sblair | 1:9399d44c2b1a | 274 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 275 | len = BER_GET_LENGTH_CTYPE_QUALITY(&mySPS->q); |
sblair | 1:9399d44c2b1a | 276 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 277 | len = BER_GET_LENGTH_CTYPE_TIMESTAMP(&mySPS->t); |
sblair | 1:9399d44c2b1a | 278 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 279 | |
sblair | 1:9399d44c2b1a | 280 | return total; |
sblair | 0:230c10b228ea | 281 | } |
sblair | 1:9399d44c2b1a | 282 | int ber_encode_mySPS(unsigned char *buf, struct mySPS *mySPS) { |
sblair | 1:9399d44c2b1a | 283 | int offset = 0; |
sblair | 1:9399d44c2b1a | 284 | |
sblair | 1:9399d44c2b1a | 285 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 286 | offset += encodeLength(&buf[offset], ber_get_length_mySPS(mySPS)); |
sblair | 1:9399d44c2b1a | 287 | |
sblair | 1:9399d44c2b1a | 288 | offset += BER_ENCODE_CTYPE_INT32(&buf[offset], &mySPS->stVal); |
sblair | 1:9399d44c2b1a | 289 | offset += BER_ENCODE_CTYPE_QUALITY(&buf[offset], &mySPS->q); |
sblair | 1:9399d44c2b1a | 290 | offset += BER_ENCODE_CTYPE_TIMESTAMP(&buf[offset], &mySPS->t); |
sblair | 1:9399d44c2b1a | 291 | |
sblair | 1:9399d44c2b1a | 292 | return offset; |
sblair | 0:230c10b228ea | 293 | } |
sblair | 1:9399d44c2b1a | 294 | int ber_get_length_myMV(struct myMV *myMV) { |
sblair | 1:9399d44c2b1a | 295 | int total = 0; |
sblair | 1:9399d44c2b1a | 296 | int len = 0; |
sblair | 1:9399d44c2b1a | 297 | |
sblair | 1:9399d44c2b1a | 298 | len = ber_get_length_myAnalogValue(&myMV->mag); |
sblair | 1:9399d44c2b1a | 299 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 300 | len = BER_GET_LENGTH_CTYPE_QUALITY(&myMV->q); |
sblair | 1:9399d44c2b1a | 301 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 302 | len = BER_GET_LENGTH_CTYPE_TIMESTAMP(&myMV->t); |
sblair | 1:9399d44c2b1a | 303 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 304 | len = ber_get_length_ScaledValueConfig(&myMV->sVC); |
sblair | 1:9399d44c2b1a | 305 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 306 | |
sblair | 1:9399d44c2b1a | 307 | return total; |
sblair | 0:230c10b228ea | 308 | } |
sblair | 1:9399d44c2b1a | 309 | int ber_encode_myMV(unsigned char *buf, struct myMV *myMV) { |
sblair | 1:9399d44c2b1a | 310 | int offset = 0; |
sblair | 1:9399d44c2b1a | 311 | |
sblair | 1:9399d44c2b1a | 312 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 313 | offset += encodeLength(&buf[offset], ber_get_length_myMV(myMV)); |
sblair | 1:9399d44c2b1a | 314 | |
sblair | 1:9399d44c2b1a | 315 | offset += ber_encode_myAnalogValue(&buf[offset], &myMV->mag); |
sblair | 1:9399d44c2b1a | 316 | offset += BER_ENCODE_CTYPE_QUALITY(&buf[offset], &myMV->q); |
sblair | 1:9399d44c2b1a | 317 | offset += BER_ENCODE_CTYPE_TIMESTAMP(&buf[offset], &myMV->t); |
sblair | 1:9399d44c2b1a | 318 | offset += ber_encode_ScaledValueConfig(&buf[offset], &myMV->sVC); |
sblair | 1:9399d44c2b1a | 319 | |
sblair | 1:9399d44c2b1a | 320 | return offset; |
sblair | 0:230c10b228ea | 321 | } |
sblair | 1:9399d44c2b1a | 322 | int ber_get_length_simpleMV(struct simpleMV *simpleMV) { |
sblair | 1:9399d44c2b1a | 323 | int total = 0; |
sblair | 1:9399d44c2b1a | 324 | int len = 0; |
sblair | 1:9399d44c2b1a | 325 | |
sblair | 1:9399d44c2b1a | 326 | len = BER_GET_LENGTH_CTYPE_FLOAT32(&simpleMV->mag); |
sblair | 1:9399d44c2b1a | 327 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 328 | len = BER_GET_LENGTH_CTYPE_QUALITY(&simpleMV->q); |
sblair | 1:9399d44c2b1a | 329 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 330 | len = BER_GET_LENGTH_CTYPE_TIMESTAMP(&simpleMV->t); |
sblair | 1:9399d44c2b1a | 331 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 332 | len = ber_get_length_ScaledValueConfig(&simpleMV->sVC); |
sblair | 1:9399d44c2b1a | 333 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 334 | |
sblair | 1:9399d44c2b1a | 335 | return total; |
sblair | 0:230c10b228ea | 336 | } |
sblair | 1:9399d44c2b1a | 337 | int ber_encode_simpleMV(unsigned char *buf, struct simpleMV *simpleMV) { |
sblair | 1:9399d44c2b1a | 338 | int offset = 0; |
sblair | 1:9399d44c2b1a | 339 | |
sblair | 1:9399d44c2b1a | 340 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 341 | offset += encodeLength(&buf[offset], ber_get_length_simpleMV(simpleMV)); |
sblair | 1:9399d44c2b1a | 342 | |
sblair | 1:9399d44c2b1a | 343 | offset += BER_ENCODE_CTYPE_FLOAT32(&buf[offset], &simpleMV->mag); |
sblair | 1:9399d44c2b1a | 344 | offset += BER_ENCODE_CTYPE_QUALITY(&buf[offset], &simpleMV->q); |
sblair | 1:9399d44c2b1a | 345 | offset += BER_ENCODE_CTYPE_TIMESTAMP(&buf[offset], &simpleMV->t); |
sblair | 1:9399d44c2b1a | 346 | offset += ber_encode_ScaledValueConfig(&buf[offset], &simpleMV->sVC); |
sblair | 1:9399d44c2b1a | 347 | |
sblair | 1:9399d44c2b1a | 348 | return offset; |
sblair | 0:230c10b228ea | 349 | } |
sblair | 1:9399d44c2b1a | 350 | int ber_get_length_simpleCMV(struct simpleCMV *simpleCMV) { |
sblair | 1:9399d44c2b1a | 351 | int total = 0; |
sblair | 1:9399d44c2b1a | 352 | int len = 0; |
sblair | 1:9399d44c2b1a | 353 | |
sblair | 1:9399d44c2b1a | 354 | len = ber_get_length_simpleVector(&simpleCMV->cVal); |
sblair | 1:9399d44c2b1a | 355 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 356 | len = BER_GET_LENGTH_CTYPE_QUALITY(&simpleCMV->q); |
sblair | 1:9399d44c2b1a | 357 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 358 | len = BER_GET_LENGTH_CTYPE_TIMESTAMP(&simpleCMV->t); |
sblair | 1:9399d44c2b1a | 359 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 360 | |
sblair | 1:9399d44c2b1a | 361 | return total; |
sblair | 0:230c10b228ea | 362 | } |
sblair | 1:9399d44c2b1a | 363 | int ber_encode_simpleCMV(unsigned char *buf, struct simpleCMV *simpleCMV) { |
sblair | 1:9399d44c2b1a | 364 | int offset = 0; |
sblair | 1:9399d44c2b1a | 365 | |
sblair | 1:9399d44c2b1a | 366 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 367 | offset += encodeLength(&buf[offset], ber_get_length_simpleCMV(simpleCMV)); |
sblair | 1:9399d44c2b1a | 368 | |
sblair | 1:9399d44c2b1a | 369 | offset += ber_encode_simpleVector(&buf[offset], &simpleCMV->cVal); |
sblair | 1:9399d44c2b1a | 370 | offset += BER_ENCODE_CTYPE_QUALITY(&buf[offset], &simpleCMV->q); |
sblair | 1:9399d44c2b1a | 371 | offset += BER_ENCODE_CTYPE_TIMESTAMP(&buf[offset], &simpleCMV->t); |
sblair | 1:9399d44c2b1a | 372 | |
sblair | 1:9399d44c2b1a | 373 | return offset; |
sblair | 0:230c10b228ea | 374 | } |
sblair | 1:9399d44c2b1a | 375 | int ber_get_length_simpleWYE(struct simpleWYE *simpleWYE) { |
sblair | 1:9399d44c2b1a | 376 | int total = 0; |
sblair | 1:9399d44c2b1a | 377 | int len = 0; |
sblair | 1:9399d44c2b1a | 378 | |
sblair | 1:9399d44c2b1a | 379 | len = ber_get_length_simpleCMV(&simpleWYE->phsA); |
sblair | 1:9399d44c2b1a | 380 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 381 | len = ber_get_length_simpleCMV(&simpleWYE->phsB); |
sblair | 1:9399d44c2b1a | 382 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 383 | len = ber_get_length_simpleCMV(&simpleWYE->phsC); |
sblair | 1:9399d44c2b1a | 384 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 385 | |
sblair | 1:9399d44c2b1a | 386 | return total; |
sblair | 0:230c10b228ea | 387 | } |
sblair | 1:9399d44c2b1a | 388 | int ber_encode_simpleWYE(unsigned char *buf, struct simpleWYE *simpleWYE) { |
sblair | 1:9399d44c2b1a | 389 | int offset = 0; |
sblair | 1:9399d44c2b1a | 390 | |
sblair | 1:9399d44c2b1a | 391 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 392 | offset += encodeLength(&buf[offset], ber_get_length_simpleWYE(simpleWYE)); |
sblair | 1:9399d44c2b1a | 393 | |
sblair | 1:9399d44c2b1a | 394 | offset += ber_encode_simpleCMV(&buf[offset], &simpleWYE->phsA); |
sblair | 1:9399d44c2b1a | 395 | offset += ber_encode_simpleCMV(&buf[offset], &simpleWYE->phsB); |
sblair | 1:9399d44c2b1a | 396 | offset += ber_encode_simpleCMV(&buf[offset], &simpleWYE->phsC); |
sblair | 1:9399d44c2b1a | 397 | |
sblair | 1:9399d44c2b1a | 398 | return offset; |
sblair | 0:230c10b228ea | 399 | } |
sblair | 1:9399d44c2b1a | 400 | int ber_get_length_myCMV(struct myCMV *myCMV) { |
sblair | 1:9399d44c2b1a | 401 | int total = 0; |
sblair | 1:9399d44c2b1a | 402 | int len = 0; |
sblair | 1:9399d44c2b1a | 403 | |
sblair | 1:9399d44c2b1a | 404 | len = ber_get_length_myVector(&myCMV->cVal); |
sblair | 1:9399d44c2b1a | 405 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 406 | len = BER_GET_LENGTH_CTYPE_QUALITY(&myCMV->q); |
sblair | 1:9399d44c2b1a | 407 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 408 | len = BER_GET_LENGTH_CTYPE_TIMESTAMP(&myCMV->t); |
sblair | 1:9399d44c2b1a | 409 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 410 | |
sblair | 1:9399d44c2b1a | 411 | return total; |
sblair | 0:230c10b228ea | 412 | } |
sblair | 1:9399d44c2b1a | 413 | int ber_encode_myCMV(unsigned char *buf, struct myCMV *myCMV) { |
sblair | 1:9399d44c2b1a | 414 | int offset = 0; |
sblair | 1:9399d44c2b1a | 415 | |
sblair | 1:9399d44c2b1a | 416 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 417 | offset += encodeLength(&buf[offset], ber_get_length_myCMV(myCMV)); |
sblair | 1:9399d44c2b1a | 418 | |
sblair | 1:9399d44c2b1a | 419 | offset += ber_encode_myVector(&buf[offset], &myCMV->cVal); |
sblair | 1:9399d44c2b1a | 420 | offset += BER_ENCODE_CTYPE_QUALITY(&buf[offset], &myCMV->q); |
sblair | 1:9399d44c2b1a | 421 | offset += BER_ENCODE_CTYPE_TIMESTAMP(&buf[offset], &myCMV->t); |
sblair | 1:9399d44c2b1a | 422 | |
sblair | 1:9399d44c2b1a | 423 | return offset; |
sblair | 0:230c10b228ea | 424 | } |
sblair | 1:9399d44c2b1a | 425 | int ber_get_length_mySEQ(struct mySEQ *mySEQ) { |
sblair | 1:9399d44c2b1a | 426 | int total = 0; |
sblair | 1:9399d44c2b1a | 427 | int len = 0; |
sblair | 1:9399d44c2b1a | 428 | |
sblair | 1:9399d44c2b1a | 429 | len = ber_get_length_myCMV(&mySEQ->c1); |
sblair | 1:9399d44c2b1a | 430 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 431 | len = ber_get_length_myCMV(&mySEQ->c2); |
sblair | 1:9399d44c2b1a | 432 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 433 | len = ber_get_length_myCMV(&mySEQ->c3); |
sblair | 1:9399d44c2b1a | 434 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 435 | len = BER_GET_LENGTH_CTYPE_ENUM((CTYPE_ENUM *) &mySEQ->seqT); |
sblair | 1:9399d44c2b1a | 436 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 437 | |
sblair | 1:9399d44c2b1a | 438 | return total; |
sblair | 0:230c10b228ea | 439 | } |
sblair | 1:9399d44c2b1a | 440 | int ber_encode_mySEQ(unsigned char *buf, struct mySEQ *mySEQ) { |
sblair | 1:9399d44c2b1a | 441 | int offset = 0; |
sblair | 1:9399d44c2b1a | 442 | |
sblair | 1:9399d44c2b1a | 443 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 444 | offset += encodeLength(&buf[offset], ber_get_length_mySEQ(mySEQ)); |
sblair | 1:9399d44c2b1a | 445 | |
sblair | 1:9399d44c2b1a | 446 | offset += ber_encode_myCMV(&buf[offset], &mySEQ->c1); |
sblair | 1:9399d44c2b1a | 447 | offset += ber_encode_myCMV(&buf[offset], &mySEQ->c2); |
sblair | 1:9399d44c2b1a | 448 | offset += ber_encode_myCMV(&buf[offset], &mySEQ->c3); |
sblair | 1:9399d44c2b1a | 449 | offset += BER_ENCODE_CTYPE_ENUM(&buf[offset], (CTYPE_ENUM *) &mySEQ->seqT); |
sblair | 1:9399d44c2b1a | 450 | |
sblair | 1:9399d44c2b1a | 451 | return offset; |
sblair | 0:230c10b228ea | 452 | } |
sblair | 1:9399d44c2b1a | 453 | int ber_get_length_mySAV(struct mySAV *mySAV) { |
sblair | 1:9399d44c2b1a | 454 | int total = 0; |
sblair | 1:9399d44c2b1a | 455 | int len = 0; |
sblair | 1:9399d44c2b1a | 456 | |
sblair | 1:9399d44c2b1a | 457 | len = ber_get_length_myAnalogValue(&mySAV->instMag); |
sblair | 1:9399d44c2b1a | 458 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 459 | len = BER_GET_LENGTH_CTYPE_QUALITY(&mySAV->q); |
sblair | 1:9399d44c2b1a | 460 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 461 | |
sblair | 1:9399d44c2b1a | 462 | return total; |
sblair | 0:230c10b228ea | 463 | } |
sblair | 1:9399d44c2b1a | 464 | int ber_encode_mySAV(unsigned char *buf, struct mySAV *mySAV) { |
sblair | 1:9399d44c2b1a | 465 | int offset = 0; |
sblair | 1:9399d44c2b1a | 466 | |
sblair | 1:9399d44c2b1a | 467 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 468 | offset += encodeLength(&buf[offset], ber_get_length_mySAV(mySAV)); |
sblair | 1:9399d44c2b1a | 469 | |
sblair | 1:9399d44c2b1a | 470 | offset += ber_encode_myAnalogValue(&buf[offset], &mySAV->instMag); |
sblair | 1:9399d44c2b1a | 471 | offset += BER_ENCODE_CTYPE_QUALITY(&buf[offset], &mySAV->q); |
sblair | 1:9399d44c2b1a | 472 | |
sblair | 1:9399d44c2b1a | 473 | return offset; |
sblair | 0:230c10b228ea | 474 | } |
sblair | 1:9399d44c2b1a | 475 | int ber_get_length_simpleSAV(struct simpleSAV *simpleSAV) { |
sblair | 1:9399d44c2b1a | 476 | int total = 0; |
sblair | 1:9399d44c2b1a | 477 | int len = 0; |
sblair | 1:9399d44c2b1a | 478 | |
sblair | 1:9399d44c2b1a | 479 | len = ber_get_length_myAnalogValue(&simpleSAV->instMag); |
sblair | 1:9399d44c2b1a | 480 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 481 | len = BER_GET_LENGTH_CTYPE_QUALITY(&simpleSAV->q); |
sblair | 1:9399d44c2b1a | 482 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 483 | |
sblair | 1:9399d44c2b1a | 484 | return total; |
sblair | 0:230c10b228ea | 485 | } |
sblair | 1:9399d44c2b1a | 486 | int ber_encode_simpleSAV(unsigned char *buf, struct simpleSAV *simpleSAV) { |
sblair | 1:9399d44c2b1a | 487 | int offset = 0; |
sblair | 1:9399d44c2b1a | 488 | |
sblair | 1:9399d44c2b1a | 489 | buf[offset++] = 0xA2; |
sblair | 1:9399d44c2b1a | 490 | offset += encodeLength(&buf[offset], ber_get_length_simpleSAV(simpleSAV)); |
sblair | 1:9399d44c2b1a | 491 | |
sblair | 1:9399d44c2b1a | 492 | offset += ber_encode_myAnalogValue(&buf[offset], &simpleSAV->instMag); |
sblair | 1:9399d44c2b1a | 493 | offset += BER_ENCODE_CTYPE_QUALITY(&buf[offset], &simpleSAV->q); |
sblair | 1:9399d44c2b1a | 494 | |
sblair | 1:9399d44c2b1a | 495 | return offset; |
sblair | 0:230c10b228ea | 496 | } |
sblair | 1:9399d44c2b1a | 497 | int ber_get_length_Itl() { |
sblair | 1:9399d44c2b1a | 498 | int total = 0; |
sblair | 1:9399d44c2b1a | 499 | int len = 0; |
sblair | 1:9399d44c2b1a | 500 | |
sblair | 1:9399d44c2b1a | 501 | len = ber_get_length_myAnalogValue(&E1Q1SB1.S1.C1.TVTR_1.Vol.instMag); |
sblair | 1:9399d44c2b1a | 502 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 503 | len = ber_get_length_myPos(&E1Q1SB1.S1.C1.CSWI_1.Pos); |
sblair | 1:9399d44c2b1a | 504 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 505 | len = ber_get_length_myPos(&E1Q1SB1.S1.C1.CSWI_2.Pos); |
sblair | 1:9399d44c2b1a | 506 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 507 | len = BER_GET_LENGTH_CTYPE_ENUM((CTYPE_ENUM *) &E1Q1SB1.S1.C1.MMXU_1.Mod.stVal); |
sblair | 1:9399d44c2b1a | 508 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 509 | len = ber_get_length_myMV(&E1Q1SB1.S1.C1.MMXU_1.Amps); |
sblair | 1:9399d44c2b1a | 510 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 511 | len = ber_get_length_myMV(&E1Q1SB1.S1.C1.MMXU_1.Volts); |
sblair | 1:9399d44c2b1a | 512 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 513 | |
sblair | 1:9399d44c2b1a | 514 | return total; |
sblair | 0:230c10b228ea | 515 | } |
sblair | 1:9399d44c2b1a | 516 | int ber_encode_Itl(unsigned char *buf) { |
sblair | 1:9399d44c2b1a | 517 | int offset = 0; |
sblair | 1:9399d44c2b1a | 518 | |
sblair | 1:9399d44c2b1a | 519 | offset += ber_encode_myAnalogValue(&buf[offset], &E1Q1SB1.S1.C1.TVTR_1.Vol.instMag); |
sblair | 1:9399d44c2b1a | 520 | offset += ber_encode_myPos(&buf[offset], &E1Q1SB1.S1.C1.CSWI_1.Pos); |
sblair | 1:9399d44c2b1a | 521 | offset += ber_encode_myPos(&buf[offset], &E1Q1SB1.S1.C1.CSWI_2.Pos); |
sblair | 1:9399d44c2b1a | 522 | offset += BER_ENCODE_CTYPE_ENUM(&buf[offset], (CTYPE_ENUM *) &E1Q1SB1.S1.C1.MMXU_1.Mod.stVal); |
sblair | 1:9399d44c2b1a | 523 | offset += ber_encode_myMV(&buf[offset], &E1Q1SB1.S1.C1.MMXU_1.Amps); |
sblair | 1:9399d44c2b1a | 524 | offset += ber_encode_myMV(&buf[offset], &E1Q1SB1.S1.C1.MMXU_1.Volts); |
sblair | 1:9399d44c2b1a | 525 | |
sblair | 1:9399d44c2b1a | 526 | return offset; |
sblair | 0:230c10b228ea | 527 | } |
sblair | 1:9399d44c2b1a | 528 | int ber_get_length_SynChk() { |
sblair | 1:9399d44c2b1a | 529 | int total = 0; |
sblair | 1:9399d44c2b1a | 530 | int len = 0; |
sblair | 1:9399d44c2b1a | 531 | |
sblair | 1:9399d44c2b1a | 532 | len = ber_get_length_mySPS(&D1Q1SB4.S1.C1.RSYN_1.Rel); |
sblair | 1:9399d44c2b1a | 533 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 534 | |
sblair | 1:9399d44c2b1a | 535 | return total; |
sblair | 0:230c10b228ea | 536 | } |
sblair | 1:9399d44c2b1a | 537 | int ber_encode_SynChk(unsigned char *buf) { |
sblair | 1:9399d44c2b1a | 538 | int offset = 0; |
sblair | 1:9399d44c2b1a | 539 | |
sblair | 1:9399d44c2b1a | 540 | offset += ber_encode_mySPS(&buf[offset], &D1Q1SB4.S1.C1.RSYN_1.Rel); |
sblair | 1:9399d44c2b1a | 541 | |
sblair | 1:9399d44c2b1a | 542 | return offset; |
sblair | 0:230c10b228ea | 543 | } |
sblair | 1:9399d44c2b1a | 544 | int ber_get_length_MMXUResult() { |
sblair | 1:9399d44c2b1a | 545 | int total = 0; |
sblair | 1:9399d44c2b1a | 546 | int len = 0; |
sblair | 1:9399d44c2b1a | 547 | |
sblair | 1:9399d44c2b1a | 548 | len = ber_get_length_simpleWYE(&D1Q1SB4.S1.C1.MMXU_1.A); |
sblair | 1:9399d44c2b1a | 549 | total += len + getLengthBytes(len) + 1; |
sblair | 1:9399d44c2b1a | 550 | |
sblair | 1:9399d44c2b1a | 551 | return total; |
sblair | 0:230c10b228ea | 552 | } |
sblair | 1:9399d44c2b1a | 553 | int ber_encode_MMXUResult(unsigned char *buf) { |
sblair | 1:9399d44c2b1a | 554 | int offset = 0; |
sblair | 1:9399d44c2b1a | 555 | |
sblair | 1:9399d44c2b1a | 556 | offset += ber_encode_simpleWYE(&buf[offset], &D1Q1SB4.S1.C1.MMXU_1.A); |
sblair | 1:9399d44c2b1a | 557 | |
sblair | 1:9399d44c2b1a | 558 | return offset; |
sblair | 0:230c10b228ea | 559 | } |
sblair | 0:230c10b228ea | 560 | |
sblair | 0:230c10b228ea | 561 |