├── README.md ├── s7.cpp └── s7.h /README.md: -------------------------------------------------------------------------------- 1 | # S7-cpp-for-Snap7 2 | Mapping data for Snap7 library in C/C++ 3 | 4 | This S7 C/C++ functions allows to parsing data read from Siemens PLC/SINAMICs by the Snap7 library (Author Davide Nardella, http://snap7.sourceforge.net/) 5 | 6 | History of versions 7 | 21-Dic-2015 - First version 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /s7.cpp: -------------------------------------------------------------------------------- 1 | //****************************************************************************************************** 2 | // This library is comlement of snap7 library to do mapping of buffer and define types 3 | // 4 | // S7 Library allow to mapping the buffer into the different S7 data types 5 | // based on wrapper made for .Net and tested for C++. It defines other types such us PLCs, Area Sources 6 | // 7 | // It uses Snap7 Library 1.4, made by Davide Nardella, http://snap7.sourceforge.net/ 8 | // 9 | // Made by Reyan Valdes, reyanvaldes@yahoo.com 10 | // 11 | //****************************************************************************************************** 12 | 13 | #include "s7.h" 14 | #include "string.h" // for memcpy 15 | 16 | 17 | using namespace std; 18 | 19 | static byte Mask[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; 20 | 21 | //**************************************************************************** 22 | 23 | // Get Text description of PLC Type 24 | string S7_GetTxtPLCType (short int plcType) 25 | { 26 | switch (plcType) 27 | { 28 | case S7_PLC_300_400: 29 | return "S7 300/400"; 30 | break; 31 | 32 | case S7_PLC_1200_1500: 33 | return "S7 1200/1500"; 34 | break; 35 | 36 | case S7_PLC_LOGO_200: 37 | return "LOGO/S7 200"; 38 | break; 39 | 40 | case S7_PLC_SINAMICS: 41 | return "SINAMICS"; 42 | break; 43 | } 44 | } 45 | 46 | //**************************************************************************** 47 | 48 | // Get data type size in bytes of the specified type 49 | int S7_GetDataTypeSize (int type) 50 | { 51 | int size =0; // for unkown type return 0 52 | 53 | switch (type) 54 | { 55 | case S7_TYPE_BOOL: 56 | case S7_TYPE_BYTE: 57 | case S7_TYPE_SINT: 58 | size = 1; 59 | break; 60 | 61 | case S7_TYPE_WORD: 62 | case S7_TYPE_UINT: 63 | case S7_TYPE_INT: 64 | size = 2; 65 | break; 66 | 67 | case S7_TYPE_DWORD: 68 | case S7_TYPE_UDINT: 69 | case S7_TYPE_DINT: 70 | case S7_TYPE_REAL: 71 | size = 4; 72 | break; 73 | 74 | case S7_TYPE_LWORD: 75 | case S7_TYPE_ULINT: 76 | case S7_TYPE_LINT: 77 | case S7_TYPE_LREAL: 78 | size = 8; 79 | break; 80 | 81 | }; 82 | 83 | return size; 84 | } 85 | 86 | //**************************************************************************** 87 | 88 | // Get the word from Transport Service Access Point (TSAP) in hex format, e.g: 10.02 => 0x1002, used by Cli_SetConnectionParams 89 | // Enter TSAP in format ##.## in hex 90 | // Return: the TSAP number in a word and decimal format 91 | uint16_t S7_GetWordFromTSAP ( string TSAP) 92 | { 93 | short int pos = TSAP.find ('.'); // find the delimiter into the source string 94 | 95 | if (pos == string::npos) {// no delimiter was found, return 0 96 | return 0; 97 | } 98 | else { // was found '.' 99 | string first = TSAP.substr (0,pos); // get the first argument 100 | string second = TSAP.substr (pos+1,2) ; // get the second argument 101 | 102 | // convert both TSAP arguments from hex (16) in string format to a number in decimal 103 | char* p; // used in the strtol function 104 | 105 | uint8_t number1 = strtol(first.c_str(), &p, 16); // convert string with data in any base (10, 16) to long 106 | uint8_t number2 = strtol(second.c_str(), &p, 16); // convert string with data in any base (10, 16) to long 107 | 108 | uint16_t res = number1 << 8 | number2; 109 | 110 | return res; 111 | } 112 | 113 | } 114 | 115 | //**************************************************************************** 116 | // Get Text message of Area Source 117 | string S7_GetTxtAreaSource (int areaSource) 118 | { 119 | switch (areaSource) 120 | { 121 | case S7_AREA_SOURCE_I: // Inputs 122 | return "INPUTS"; 123 | break; 124 | 125 | case S7_AREA_SOURCE_Q: // Outputs 126 | return "OUTPUTS"; 127 | break; 128 | 129 | case S7_AREA_SOURCE_M: // Memory Marks 130 | return "Marks"; 131 | break; 132 | 133 | case S7_AREA_SOURCE_DB: // Data Block 134 | return "DB"; 135 | break; 136 | 137 | default: 138 | return "Unkown Data Source"; 139 | }; 140 | } 141 | 142 | 143 | //**************************************************************************** 144 | 145 | // Get BDC and convert to byte 146 | int S7_BDCToByte (byte B) 147 | { 148 | return ((B >> 4) * 10 ) + (B & 0x0F); 149 | } 150 | 151 | //**************************************************************************** 152 | 153 | // Convert Byte to BDC 154 | byte S7_ByteToBDC (int Value) 155 | { 156 | return (byte) ((( Value /10 ) << 4) | (Value % 10)); 157 | } 158 | 159 | //**************************************************************************** 160 | 161 | // Get Bit position at buffer of bytes, bits 0..7 162 | bool S7_GetBitAt ( byte Buffer[], int Pos, int Bit) 163 | { 164 | if (Bit < 0) Bit = 0; 165 | if (Bit > 7) Bit = 7; 166 | 167 | return (Buffer[Pos] & Mask[Bit]) != 0; 168 | } 169 | 170 | 171 | //**************************************************************************** 172 | 173 | // Set Bit position at buffer of bytes 174 | 175 | void S7_SetBitAt ( byte Buffer[], int Pos, int Bit, bool Value) 176 | { 177 | if (Bit < 0) Bit = 0; 178 | if (Bit > 7) Bit = 7; 179 | 180 | if (Value) 181 | Buffer[Pos] = (byte)(Buffer[Pos] | Mask[Bit]); 182 | else 183 | Buffer[Pos] = (byte)(Buffer[Pos] & ~Mask[Bit]); 184 | } 185 | 186 | //**************************************************************************** 187 | 188 | // Get Byte (0..255) at buffer of bytes 189 | uint8_t S7_GetByteAt(byte Buffer[], int Pos) 190 | { 191 | return Buffer[Pos] ; 192 | } 193 | 194 | //**************************************************************************** 195 | 196 | // Set Byte (0..255) at buffer of bytes 197 | void S7_SetByteAt(byte Buffer[], int Pos, uint8_t Value ) 198 | { 199 | Buffer [Pos] = Value; 200 | } 201 | 202 | 203 | //**************************************************************************** 204 | 205 | // Get SInt (-128..127) at buffer of bytes 206 | int8_t S7_GetSIntAt(byte Buffer[], int Pos) 207 | { 208 | int Value = Buffer[Pos]; 209 | if (Value < 128) 210 | return Value; 211 | else 212 | return (int8_t) (Value - 256); 213 | } 214 | 215 | //**************************************************************************** 216 | 217 | // Set SInt (-128..127) at buffer of bytes 218 | void S7_SetSIntAt(byte Buffer[], int Pos, int8_t Value) 219 | { 220 | if (Value < -128) Value = -128; 221 | if (Value > 127) Value = 127; 222 | Buffer[Pos] = (byte)Value; 223 | } 224 | 225 | //**************************************************************************** 226 | 227 | // Get 16 bit unsigned value (S7 UInt) 0..65535 228 | uint16_t S7_GetUIntAt(byte Buffer[], int Pos) 229 | { 230 | return (uint16_t)((Buffer[Pos] << 8) | Buffer[Pos + 1]); 231 | } 232 | 233 | //**************************************************************************** 234 | 235 | // Set 16 bit unsigned value (S7 UInt) 0..65535 236 | 237 | void S7_SetUIntAt(byte Buffer[], int Pos, uint16_t Value ) 238 | { 239 | Buffer[Pos] = (byte)(Value >> 8); 240 | Buffer[Pos + 1] = (byte)(Value & 0x00FF); 241 | } 242 | 243 | //**************************************************************************** 244 | 245 | // Get 16 bit unsigned value (S7 Word) 0..65535 246 | 247 | uint16_t S7_GetWordAt(byte Buffer[], int Pos) 248 | { 249 | return S7_GetUIntAt(Buffer, Pos) ; 250 | } 251 | 252 | //**************************************************************************** 253 | // Set 16 bit unsigned value (S7 Word) 0..65535 254 | void S7_SetWordAt(byte Buffer[], int Pos, uint16_t Value ) 255 | { 256 | S7_SetUIntAt(Buffer, Pos, Value); 257 | } 258 | 259 | 260 | //**************************************************************************** 261 | 262 | // Get 16 bit signed value (S7 int) -32768..32767 at buffer of bytes 263 | int16_t S7_GetIntAt(byte Buffer[], int Pos) 264 | { 265 | return (int16_t)((Buffer[Pos] << 8) | Buffer[Pos + 1]); 266 | } 267 | 268 | //**************************************************************************** 269 | 270 | // Set 16 bit signed value (S7 int) -32768..32767 at buffer of bytes 271 | 272 | void S7_SetIntAt(byte Buffer[], int Pos, int16_t Value) 273 | { 274 | Buffer[Pos] = (byte)(Value >> 8); 275 | Buffer[Pos + 1] = (byte)(Value & 0x00FF); 276 | } 277 | 278 | //**************************************************************************** 279 | 280 | // Get 32 bit signed value (S7 DInt) -2147483648..2147483647 281 | long S7_GetDIntAt(byte Buffer[], int Pos) 282 | { 283 | long Result; 284 | Result = Buffer[Pos]; Result <<= 8; 285 | Result += Buffer[Pos + 1]; Result <<= 8; 286 | Result += Buffer[Pos + 2]; Result <<= 8; 287 | Result += Buffer[Pos + 3]; 288 | return Result; 289 | } 290 | 291 | //**************************************************************************** 292 | 293 | // Set 32 bit signed value (S7 DInt) -2147483648..2147483647 294 | 295 | void S7_SetDIntAt(byte Buffer[], int Pos, long Value) 296 | { 297 | Buffer[Pos + 3] = (byte)(Value & 0xFF); 298 | Buffer[Pos + 2] = (byte)((Value >> 8) & 0xFF); 299 | Buffer[Pos + 1] = (byte)((Value >> 16) & 0xFF); 300 | Buffer[Pos] = (byte)((Value >> 24) & 0xFF); 301 | } 302 | 303 | //**************************************************************************** 304 | 305 | // Get 32 bit unsigned value (S7 UDInt) 0..4294967295 306 | uint32_t S7_GetUDIntAt(byte Buffer[], int Pos) 307 | { 308 | uint32_t Result; 309 | Result = Buffer[Pos]; Result <<= 8; 310 | Result |= Buffer[Pos + 1]; Result <<= 8; 311 | Result |= Buffer[Pos + 2]; Result <<= 8; 312 | Result |= Buffer[Pos + 3]; 313 | return Result; 314 | } 315 | 316 | //**************************************************************************** 317 | 318 | // Set 32 bit unsigned value (S7 UDInt) 0..4294967295 319 | 320 | void S7_SetUDIntAt(byte Buffer[], int Pos, uint32_t Value) 321 | { 322 | Buffer[Pos + 3] = (byte)(Value & 0xFF); 323 | Buffer[Pos + 2] = (byte)((Value >> 8) & 0xFF); 324 | Buffer[Pos + 1] = (byte)((Value >> 16) & 0xFF); 325 | Buffer[Pos] = (byte)((Value >> 24) & 0xFF); 326 | } 327 | 328 | 329 | //**************************************************************************** 330 | 331 | // Get 32 bit unsigned value (S7 UDInt) 0..4294967295 332 | uint32_t S7_GetDWordAt(byte Buffer[], int Pos) 333 | { 334 | return S7_GetUDIntAt (Buffer, Pos); 335 | } 336 | 337 | //**************************************************************************** 338 | 339 | // Set 32 bit unsigned value (S7 UDInt) 0..4294967295 340 | 341 | void S7_SetDWordAt(byte Buffer[], int Pos, uint32_t Value) 342 | { 343 | S7_SetUDIntAt(Buffer, Pos, Value); 344 | } 345 | 346 | //**************************************************************************** 347 | 348 | // Set 64 bit unsigned value (S7 ULint) 0..18446744073709551615 349 | uint64_t S7_GetULIntAt(byte Buffer[], int Pos) 350 | { 351 | uint64_t Result; 352 | Result = Buffer[Pos]; Result <<= 8; 353 | Result |= Buffer[Pos + 1]; Result <<= 8; 354 | Result |= Buffer[Pos + 2]; Result <<= 8; 355 | Result |= Buffer[Pos + 3]; Result <<= 8; 356 | Result |= Buffer[Pos + 4]; Result <<= 8; 357 | Result |= Buffer[Pos + 5]; Result <<= 8; 358 | Result |= Buffer[Pos + 6]; Result <<= 8; 359 | Result |= Buffer[Pos + 7]; 360 | return Result; 361 | } 362 | 363 | //**************************************************************************** 364 | 365 | // Set 64 bit unsigned value (S7 ULint) 0..18446744073709551615 366 | void S7_SetULIntAt(byte Buffer[], int Pos, uint64_t Value) 367 | { 368 | Buffer[Pos + 7] = (byte)(Value & 0xFF); 369 | Buffer[Pos + 6] = (byte)((Value >> 8) & 0xFF); 370 | Buffer[Pos + 5] = (byte)((Value >> 16) & 0xFF); 371 | Buffer[Pos + 4] = (byte)((Value >> 24) & 0xFF); 372 | Buffer[Pos + 3] = (byte)((Value >> 32) & 0xFF); 373 | Buffer[Pos + 2] = (byte)((Value >> 40) & 0xFF); 374 | Buffer[Pos + 1] = (byte)((Value >> 48) & 0xFF); 375 | Buffer[Pos] = (byte)((Value >> 56) & 0xFF); 376 | } 377 | 378 | //**************************************************************************** 379 | // Set 64 bit unsigned value (S7 ULint) 0..18446744073709551615 380 | 381 | uint64_t S7_GetLWordAt(byte Buffer[], int Pos) 382 | { 383 | return S7_GetULIntAt (Buffer, Pos) ; 384 | } 385 | 386 | //**************************************************************************** 387 | // Set 64 bit unsigned value (S7 ULint) 0..18446744073709551615 388 | 389 | void S7_SetLWordAt(byte Buffer[], int Pos, uint64_t Value) 390 | { 391 | S7_SetULIntAt ( Buffer, Pos, Value) ; 392 | } 393 | 394 | 395 | //**************************************************************************** 396 | 397 | // Get 64 bit signed value (S7 LInt) -9223372036854775808..9223372036854775807 398 | int64_t S7_GetLIntAt(byte Buffer[], int Pos) 399 | { 400 | int64_t Result; 401 | Result = Buffer[Pos]; Result <<= 8; 402 | Result += Buffer[Pos + 1]; Result <<= 8; 403 | Result += Buffer[Pos + 2]; Result <<= 8; 404 | Result += Buffer[Pos + 3]; Result <<= 8; 405 | Result += Buffer[Pos + 4]; Result <<= 8; 406 | Result += Buffer[Pos + 5]; Result <<= 8; 407 | Result += Buffer[Pos + 6]; Result <<= 8; 408 | Result += Buffer[Pos + 7]; 409 | return Result; 410 | } 411 | 412 | //**************************************************************************** 413 | 414 | // Set 64 bit signed value (S7 LInt) -9223372036854775808..9223372036854775807 415 | void S7_SetLIntAt(byte Buffer[], int Pos, int64_t Value) 416 | { 417 | Buffer[Pos + 7] = (byte)(Value & 0xFF); 418 | Buffer[Pos + 6] = (byte)((Value >> 8) & 0xFF); 419 | Buffer[Pos + 5] = (byte)((Value >> 16) & 0xFF); 420 | Buffer[Pos + 4] = (byte)((Value >> 24) & 0xFF); 421 | Buffer[Pos + 3] = (byte)((Value >> 32) & 0xFF); 422 | Buffer[Pos + 2] = (byte)((Value >> 40) & 0xFF); 423 | Buffer[Pos + 1] = (byte)((Value >> 48) & 0xFF); 424 | Buffer[Pos] = (byte)((Value >> 56) & 0xFF); 425 | } 426 | 427 | //**************************************************************************** 428 | // Get 32 bit floating point number (S7 Real) (Range of float) 429 | float S7_GetRealAt(byte Buffer[], int Pos) 430 | { 431 | uint32_t Pack = S7_GetUDIntAt(Buffer, Pos); 432 | float Res; memcpy (&Res, &Pack, 4); 433 | return Res; 434 | } 435 | 436 | //**************************************************************************** 437 | 438 | // Set 32 bit floating point number (S7 Real) (Range of float) 439 | void S7_SetRealAt(byte Buffer[], int Pos, float Value) 440 | { 441 | 442 | uint32_t Pack; 443 | memcpy (&Pack, &Value, 4); 444 | S7_SetUDIntAt (Buffer, Pos, Pack); 445 | } 446 | 447 | //**************************************************************************** 448 | 449 | // Get 64 bit floating point number (S7 LReal) (Range of double) 450 | double S7_GetLRealAt(byte Buffer[], int Pos) 451 | { 452 | uint64_t Pack = S7_GetULIntAt(Buffer, Pos) ; 453 | double Res; memcpy (&Res, &Pack, 8); 454 | return Res; 455 | } 456 | 457 | //**************************************************************************** 458 | 459 | // Set 64 bit floating point number (S7 LReal) (Range of double) 460 | void S7_SetLRealAt(byte Buffer[], int Pos, double Value) 461 | { 462 | uint64_t Pack; 463 | memcpy (&Pack, &Value, 8); 464 | S7_SetULIntAt (Buffer, Pos, Pack); 465 | } 466 | 467 | //**************************************************************************** 468 | // Get String (S7 String) 469 | // In Siemens the standard string has format: 470 | // - 1st byte: Max Length 471 | // - 2nd byte: Current Length 472 | // - 3rd ... n byte: string characters 473 | 474 | string S7_GetStringAt(byte Buffer[], int Pos) 475 | { 476 | string res; 477 | 478 | int size = (int) Buffer[Pos + 1]; 479 | 480 | res.insert (0, (char*) &Buffer[Pos+2],size); 481 | 482 | return res; 483 | } 484 | 485 | //**************************************************************************** 486 | // Set String (S7 String) 487 | // In Siemens the standard string has format: 488 | // - 1st byte: Max Length 489 | // - 2nd byte: Current Length 490 | // - 3rd ... n byte: string characters 491 | 492 | void S7_SetStringAt(byte Buffer[], int Pos, int MaxLen, string Value) 493 | { 494 | int size = Value.size(); 495 | 496 | Buffer[Pos] = (byte)MaxLen; 497 | Buffer[Pos + 1] = (byte)size; 498 | 499 | Value.copy ((char*) &Buffer[Pos+2],size); 500 | } 501 | 502 | //**************************************************************************** 503 | //Get Array of char (S7 ARRAY OF CHARS) 504 | string S7_GetCharsAt(byte Buffer[], int Pos, int Size) 505 | { 506 | string res; 507 | 508 | res.insert (0, (char*) &Buffer[Pos],Size); 509 | 510 | return res; 511 | } 512 | 513 | #include 514 | 515 | //**************************************************************************** 516 | //Set Array of char (S7 ARRAY OF CHARS) 517 | void S7_SetCharsAt(byte Buffer[], int BufferLen, int Pos, string Value) 518 | { 519 | int MaxLen = BufferLen - Pos; 520 | int Size = Value.size(); 521 | 522 | cout << " Max Len: " << MaxLen << " Size: " << Size << endl; 523 | 524 | // Truncs the string if there's no room enough 525 | if (Size > MaxLen) Size = MaxLen; 526 | 527 | 528 | 529 | Value.copy ((char*) &Buffer[Pos],Size); 530 | } 531 | 532 | //**************************************************************************** 533 | -------------------------------------------------------------------------------- /s7.h: -------------------------------------------------------------------------------- 1 | //************************************************************************************* 2 | // S7 Library allow to mapping the buffer into the different data types 3 | // based on wrapper made for .Net. And defines other types such us PLCs, Area Sources 4 | // 5 | // It uses Snap7 Library 1.4,made by Davide Nardella, http://snap7.sourceforge.net/ made by 6 | // 7 | // Made by Reyan Valdes, reyanvaldes@yahoo.com 8 | // 9 | //************************************************************************************* 10 | 11 | #ifndef S7_H 12 | #define S7_H 13 | 14 | #include "snap7.h" 15 | 16 | using namespace std; 17 | 18 | // Define different PLC Types 19 | #define S7_PLC_300_400 0 // for PLC S7 300/400 20 | #define S7_PLC_1200_1500 1 // for PLC S7 1200/1500 21 | #define S7_PLC_LOGO_200 2 // for PLC S7 LOGO / 200 22 | #define S7_PLC_SINAMICS 3 // for SINAMICS Driver 23 | 24 | // Define different Area sources 25 | #define S7_AREA_SOURCE_I 0 // Inputs 26 | #define S7_AREA_SOURCE_Q 1 // Outputs 27 | #define S7_AREA_SOURCE_M 2 // Memory Marks 28 | #define S7_AREA_SOURCE_DB 3 // Data Blocks 29 | 30 | // Define different S7 data types 31 | #define S7_TYPE_BOOL 1 32 | #define S7_TYPE_BYTE 2 33 | #define S7_TYPE_SINT 3 34 | #define S7_TYPE_WORD 4 35 | #define S7_TYPE_UINT 5 36 | #define S7_TYPE_INT 6 37 | #define S7_TYPE_DWORD 7 38 | #define S7_TYPE_UDINT 8 39 | #define S7_TYPE_DINT 9 40 | #define S7_TYPE_LWORD 10 41 | #define S7_TYPE_ULINT 11 42 | #define S7_TYPE_LINT 12 43 | #define S7_TYPE_REAL 13 44 | #define S7_TYPE_LREAL 14 45 | 46 | #define S7_TYPE_STRING 15 47 | #define S7_TYPE_ARRAYCHAR 16 48 | 49 | string S7_GetTxtPLCType (short int plcType); // Get Text description of PLC Type 50 | 51 | int S7_GetDataTypeSize (int type); // Get data type size 52 | 53 | uint16_t S7_GetWordFromTSAP ( string TSAP); // Get the word from Transport Service Access Point (TSAP) in hex format, e.g: 10.02 => 0x1002, used by Cli_SetConnectionParams 54 | 55 | string S7_GetTxtAreaSource (int areaSource); // Get Text message of Area Source 56 | 57 | int S7_BDCToByte (byte B); // Get BDC and convert to byte 58 | 59 | byte S7_ByteToBDC (int Value); // Convert Byte to BDC 60 | 61 | bool S7_GetBitAt ( byte Buffer[], int Pos, int Bit); // Get Bit position at buffer of bytes 62 | 63 | void S7_SetBitAt ( byte Buffer[], int Pos, int Bit, bool Value); // Set Bit position at buffer of bytes 64 | 65 | uint8_t S7_GetByteAt(byte Buffer[], int Pos); // Get Byte (0..255) at buffer of bytes 66 | 67 | void S7_SetByteAt(byte Buffer[], int Pos, uint8_t Value ); // Set Byte (0..255) at buffer of bytes 68 | 69 | int8_t S7_GetSIntAt(byte Buffer[], int Pos); // Get SInt (-128..127) at buffer of bytes 70 | 71 | void S7_SetSIntAt(byte Buffer[], int Pos, int Value); // Set SInt (-128..127) at buffer of bytes 72 | 73 | uint16_t S7_GetUIntAt(byte Buffer[], int Pos); // Get 16 bit unsigned value (S7 UInt) 0..65535 74 | 75 | void S7_SetUIntAt(byte Buffer[], int Pos, uint16_t Value ); // Set 16 bit unsigned value (S7 UInt) 0..65535 76 | 77 | uint16_t S7_GetWordAt(byte Buffer[], int Pos); // Get 16 bit unsigned value (S7 UInt) 0..65535 78 | 79 | void S7_SetWordAt(byte Buffer[], int Pos, uint16_t Value ); // Set 16 bit unsigned value (S7 UInt) 0..65535 80 | 81 | int16_t S7_GetIntAt(byte Buffer[], int Pos); // Get 16 bit signed value (S7 int) -32768..32767 at buffer of bytes 82 | 83 | void S7_SetIntAt(byte Buffer[], int Pos, int16_t Value); // Set 16 bit signed value (S7 int) -32768..32767 at buffer of bytes 84 | 85 | uint32_t S7_GetUDIntAt(byte Buffer[], int Pos); // Get 32 bit unsigned value (S7 UDInt) 0..4294967295 86 | 87 | void S7_SetUDIntAt(byte Buffer[], int Pos, uint32_t Value); // Set 32 bit unsigned value (S7 UDInt) 0..4294967295 88 | 89 | uint32_t S7_GetDWordAt(byte Buffer[], int Pos); // Get 32 bit unsigned value (S7 UDInt) 0..4294967295 90 | 91 | void S7_SetDWordAt(byte Buffer[], int Pos, uint32_t Value); // Set 32 bit unsigned value (S7 UDInt) 0..4294967295 92 | 93 | long S7_GetDIntAt(byte Buffer[], int Pos); // Get 32 bit signed value (S7 DInt) -2147483648..2147483647 94 | 95 | void S7_SetDIntAt(byte Buffer[], int Pos, long Value); // Set 32 bit signed value (S7 DInt) -2147483648..2147483647 96 | 97 | uint64_t S7_GetULIntAt(byte Buffer[], int Pos); // Set 64 bit unsigned value (S7 ULint) 0..18446744073709551615 98 | 99 | void S7_SetULIntAt(byte Buffer[], int Pos, uint64_t Value); // Set 64 bit unsigned value (S7 ULint) 0..18446744073709551615 100 | 101 | uint64_t S7_GetLWordAt(byte Buffer[], int Pos); // Set 64 bit unsigned value (S7 ULint) 0..18446744073709551615 102 | 103 | void S7_SetLWordAt(byte Buffer[], int Pos, uint64_t Value); // Set 64 bit unsigned value (S7 ULint) 0..18446744073709551615 104 | 105 | int64_t S7_GetLIntAt(byte Buffer[], int Pos); // Get 64 bit signed value (S7 LInt) -9223372036854775808..9223372036854775807 106 | 107 | void S7_SetLIntAt(byte Buffer[], int Pos, int64_t Value); // Set 64 bit signed value (S7 LInt) -9223372036854775808..9223372036854775807 108 | 109 | float S7_GetRealAt(byte Buffer[], int Pos); // Get 32 bit floating point number (S7 Real) (Range of float) 110 | 111 | void S7_SetRealAt(byte Buffer[], int Pos, float Value); // Set 32 bit floating point number (S7 Real) (Range of float) 112 | 113 | double S7_GetLRealAt(byte Buffer[], int Pos); // Get 64 bit floating point number (S7 LReal) (Range of double) 114 | 115 | void S7_SetLRealAt(byte Buffer[], int Pos, double Value); // Set 64 bit floating point number (S7 LReal) (Range of double) 116 | 117 | string S7_GetStringAt(byte Buffer[], int Pos); // Get String (S7 String) 118 | 119 | void S7_SetStringAt(byte Buffer[], int Pos, int MaxLen, string Value); // Set String (S7 String) 120 | 121 | string S7_GetCharsAt(byte Buffer[], int Pos, int Size); //Get Array of char (S7 ARRAY OF CHARS) 122 | 123 | void S7_SetCharsAt(byte Buffer[], int BufferLen, int Pos, string Value); //Set Array of char (S7 ARRAY OF CHARS) 124 | 125 | #endif // S7_H 126 | --------------------------------------------------------------------------------