![Dectris MYTHEN Interface Manual Download Page 29](http://html1.mh-extra.com/html/dectris/mythen/mythen_interface-manual_2462219029.webp)
Socket Interface Specification. MYTHEN Detector System. Version: 2
29/34
7.3. Decoding the raw data
The example code below shows how to decode the compressed raw data returned by the "-readoutraw"
command. The usage of this command is only necessary, when very high frame rates (
˃ 300 Hz) are required. All
corrections (flatfield-, rate-, bad channel-corrections) have to be applied afterwards by the client.
// Input
// nmods: number of active modules
// nbits: number of bits, which were read out
// data: response of the -readoutraw command
//
// Output
// result: array of size 1280*nmods with the number of counts of all
// channels
void decodeRawReadout(int nmods, int nbits, int *data, int *result)
{
int chanperline = 1; // default for 24 bits
int mask=0xffffff; // default for 24 bits
if (nbits == 16)
{
chanperline = 2;
mask=0xffff;
}
if (nbits == 8)
{
chanperline = 4;
mask=0xff;
}
if (nbits == 4)
{
chanperline = 8;
mask=0xf;
}
int size = 1280/chanperline*nmods;
u_int32_t tmpArray[size]; // the data has to interpreted
memcpy(tmpArray, data, size*sizeof(int)); // unsigned int32
for (int j = 0; j < chanperline; j++)
{
int shift = nbits*j;
int shiftedMask = mask<<shift;
for (int i = 0; i < size; i++)
{
result[i*chanj]=((tmpArray[i]&shiftedMask)>>shift)&mask;
}
}
}