An mbed implementation of IEC 61850-9-2LE Sample Values. Creating using the rapid61850 library, available at: https://github.com/stevenblair/rapid61850.
svDecodeBasic.c
00001 /** 00002 * Rapid-prototyping protection schemes with IEC 61850 00003 * 00004 * Copyright (c) 2012 Steven Blair 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "ctypes.h" 00022 #include "datatypes.h" 00023 #include "ied.h" 00024 #include "svDecodeBasic.h" 00025 #include <string.h> 00026 00027 // SV encoding of basic types 00028 int DECODE_CTYPE_FLOAT32(unsigned char *buf, CTYPE_FLOAT32 *value) { 00029 netmemcpy(value, buf, SV_GET_LENGTH_FLOAT32); 00030 00031 return SV_GET_LENGTH_FLOAT32; 00032 } 00033 int DECODE_CTYPE_FLOAT64(unsigned char *buf, CTYPE_FLOAT64 *value) { 00034 netmemcpy(value, buf, SV_GET_LENGTH_FLOAT64); 00035 00036 return SV_GET_LENGTH_FLOAT64; 00037 } 00038 int DECODE_CTYPE_QUALITY(unsigned char *buf, CTYPE_QUALITY *value) { 00039 netmemcpy(value, buf, SV_GET_LENGTH_QUALITY); 00040 00041 return SV_GET_LENGTH_QUALITY; 00042 } 00043 int DECODE_CTYPE_TIMESTAMP(unsigned char *buf, CTYPE_TIMESTAMP *value) { 00044 netmemcpy(value, buf, SV_GET_LENGTH_TIMESTAMP); 00045 00046 return SV_GET_LENGTH_TIMESTAMP; 00047 } 00048 int DECODE_CTYPE_ENUM(unsigned char *buf, CTYPE_ENUM *value) { // assuming enum is an int - allows any enum type to be used 00049 netmemcpy(value, buf, SV_GET_LENGTH_ENUM); 00050 00051 return SV_GET_LENGTH_ENUM; 00052 } 00053 int DECODE_CTYPE_INT8(unsigned char *buf, CTYPE_INT8 *value) { 00054 netmemcpy(value, buf, SV_GET_LENGTH_INT8); 00055 00056 return SV_GET_LENGTH_INT8; 00057 } 00058 int DECODE_CTYPE_INT16(unsigned char *buf, CTYPE_INT16 *value) { 00059 netmemcpy(value, buf, SV_GET_LENGTH_INT16); 00060 00061 return SV_GET_LENGTH_INT16; 00062 } 00063 int DECODE_CTYPE_INT32(unsigned char *buf, CTYPE_INT32 *value) { 00064 netmemcpy(value, buf, SV_GET_LENGTH_INT32); 00065 00066 return SV_GET_LENGTH_INT32; 00067 } 00068 int DECODE_CTYPE_INT16U(unsigned char *buf, CTYPE_INT16U *value) { 00069 netmemcpy(value, buf, SV_GET_LENGTH_INT16U); 00070 00071 return SV_GET_LENGTH_INT16U; 00072 } 00073 int DECODE_CTYPE_INT32U(unsigned char *buf, CTYPE_INT32U *value) { 00074 netmemcpy(value, buf, SV_GET_LENGTH_INT32U); 00075 00076 return SV_GET_LENGTH_INT32U; 00077 } 00078 int DECODE_CTYPE_VISSTRING255(unsigned char *buf, CTYPE_VISSTRING255 *value) { 00079 netmemcpy(value, buf, SV_GET_LENGTH_VISSTRING255); 00080 00081 return SV_GET_LENGTH_VISSTRING255; 00082 } 00083 int DECODE_CTYPE_BOOLEAN(unsigned char *buf, CTYPE_BOOLEAN *value) { 00084 netmemcpy(value, buf, SV_GET_LENGTH_BOOLEAN); 00085 00086 return SV_GET_LENGTH_BOOLEAN; 00087 } 00088 int DECODE_CTYPE_DBPOS(unsigned char *buf, CTYPE_DBPOS *value) { 00089 netmemcpy(value, buf, SV_GET_LENGTH_DBPOS); 00090 00091 return SV_GET_LENGTH_DBPOS; 00092 }
Generated on Sat Jul 23 2022 01:15:10 by 1.7.2