Changeset 295 in pacpusframework for branches


Ignore:
Timestamp:
03/31/14 15:24:03 (10 years ago)
Author:
DHERBOMEZ Gérald
Message:

Bug fix in BinaryDecoder.h file, notably for the mDecodeToUI8 function (error when decoding UI8 whose the size(in bits) < 8 bits )

Location:
branches
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/0.0.x/include/Pacpus/PacpusTools/BinaryDecoder.h

    r76 r295  
    766766        } else {
    767767            *result = 0;
    768             return true;
     768            return false;
    769769        }
    770770    } else {
    771771        // ok data is stored at most in 1 byte
    772772        unsigned char c;
    773         c = data[startBit>>3];                // >>3 <=> div 8
    774         c >>= (8-((startBit & 0x07)+1));      // &0x07 <=> modulo 8
    775         *result = c & getMask8( length );
     773       
     774                c = data[startBit>>3];                // >>3 <=> div 8
     775        //c >>= (8-((startBit & 0x07)+1));      // &0x07 <=> modulo 8
     776                c >>= startBit & 0x07 - (length - 1);    // &0x07 <=> modulo 8
     777                *result = c & getMask8( length );
    776778
    777779        return true;
     
    798800        } else {
    799801            *result = 0;
    800             return true;
     802            return false;
    801803        }
    802804    }
  • branches/0.1.x/include/Pacpus/PacpusTools/BinaryDecoder.h

    r126 r295  
    3131#define BINARYDECODER_H
    3232
    33 #include "PacpusToolsConfig.h"
    34 
    3533#ifdef __cplusplus
    3634extern "C"
     
    3836#endif // __cplusplus
    3937
     38#include "PacpusToolsConfig.h" 
     39 
    4040#include <stdio.h>
    4141
     
    768768        } else {
    769769            *result = 0;
    770             return true;
     770            return false;
    771771        }
    772772    } else {
    773773        // ok data is stored at most in 1 byte
    774774        unsigned char c;
    775         c = data[startBit>>3];                // >>3 <=> div 8
    776         c >>= (8-((startBit & 0x07)+1));      // &0x07 <=> modulo 8
    777         *result = c & getMask8( length );
     775       
     776                c = data[startBit>>3];                // >>3 <=> div 8
     777        //c >>= (8-((startBit & 0x07)+1));      // &0x07 <=> modulo 8
     778                c >>= startBit & 0x07 - (length - 1);    // &0x07 <=> modulo 8
     779                *result = c & getMask8( length );
    778780
    779781        return true;
     
    800802        } else {
    801803            *result = 0;
    802             return true;
     804            return false;
    803805        }
    804806    }
Note: See TracChangeset for help on using the changeset viewer.