| 614 | } |
| 615 | |
| 616 | int DecodeData(const EipUint8 cip_data_type, |
| 617 | void *const cip_data, |
| 618 | const EipUint8 **const cip_message) { |
| 619 | int number_of_decoded_bytes = -1; |
| 620 | |
| 621 | switch (cip_data_type) |
| 622 | /* check the data type of attribute */ |
| 623 | { |
| 624 | case (kCipBool): |
| 625 | case (kCipSint): |
| 626 | case (kCipUsint): |
| 627 | case (kCipByte): |
| 628 | *(EipUint8 *) (cip_data) = **cip_message; |
| 629 | ++(*cip_message); |
| 630 | number_of_decoded_bytes = 1; |
| 631 | break; |
| 632 | |
| 633 | case (kCipInt): |
| 634 | case (kCipUint): |
| 635 | case (kCipWord): |
| 636 | (*(EipUint16 *) (cip_data) ) = GetIntFromMessage(cip_message); |
| 637 | number_of_decoded_bytes = 2; |
| 638 | break; |
| 639 | |
| 640 | case (kCipDint): |
| 641 | case (kCipUdint): |
| 642 | case (kCipDword): |
| 643 | case (kCipReal): |
| 644 | (*(EipUint32 *) (cip_data) ) = GetDintFromMessage(cip_message); |
| 645 | number_of_decoded_bytes = 4; |
| 646 | break; |
| 647 | |
| 648 | #ifdef OPENER_SUPPORT_64BIT_DATATYPES |
| 649 | case (kCipLint): |
| 650 | case (kCipUlint): |
| 651 | case (kCipLword): { |
| 652 | (*(EipUint64 *) (cip_data) ) = GetLintFromMessage(cip_message); |
| 653 | number_of_decoded_bytes = 8; |
| 654 | } |
| 655 | break; |
| 656 | #endif |
| 657 | |
| 658 | case (kCipString): { |
| 659 | CipString *string = (CipString *) cip_data; |
| 660 | string->length = GetIntFromMessage(cip_message); |
| 661 | memcpy(string->string, *cip_message, string->length); |
| 662 | *cip_message += string->length; |
| 663 | |
| 664 | number_of_decoded_bytes = string->length + 2; /* we have a two byte length field */ |
| 665 | if (number_of_decoded_bytes & 0x01) { |
| 666 | /* we have an odd byte count */ |
| 667 | ++(*cip_message); |
| 668 | number_of_decoded_bytes++; |
| 669 | } |
| 670 | } |
| 671 | break; |
| 672 | case (kCipShortString): { |
| 673 | CipShortString *short_string = (CipShortString *) cip_data; |
nothing calls this directly
no test coverage detected