FACT++  1.0
bool ConnectionFSC::CheckChecksum ( )
inlineprivate

Definition at line 82 of file fscctrl.cc.

References FSC::BinaryOutput_t::ad7719_values, FSC::BinaryOutput_t::ad7719_values_checksum, FSC::BinaryOutput_t::adc_values, FSC::BinaryOutput_t::adc_values_checksum, Tools::Fletcher16(), FSC::kNumResistanceChannels, and FSC::kNumVoltageChannels.

83  {
84  const uint16_t volt_checksum = Tools::Fletcher16(fMsg.adc_values, kNumVoltageChannels);
85  const uint16_t resi_checksum = Tools::Fletcher16(fMsg.ad7719_values, kNumResistanceChannels);
86 
87  const bool volt_ok = volt_checksum == fMsg.adc_values_checksum;
88  const bool resi_ok = resi_checksum == fMsg.ad7719_values_checksum;
89 
90  if (volt_ok && resi_ok)
91  return true;
92 
94 
95  ostringstream out;
96  out << "Checksum error (V:";
97  out << hex << setfill('0');
98 
99  if (volt_ok)
100  out << "----|----";
101  else
102  {
103  out << setw(4) << volt_checksum;
104  out << "|";
105  out << setw(4) << fMsg.adc_values_checksum;
106  }
107 
108  out << ", R:";
109 
110  if (resi_ok)
111  out << "----|----";
112  else
113  {
114  out << setw(4) << resi_checksum;
115  out << "|";
116  out << setw(4) << fMsg.ad7719_values_checksum;
117  }
118 
119  out << ", " << dec;
120  out << "Nok=" << fNumConsecutiveMessages << ", ";
121  out << "Nerr=" << fNumConsecutiveErrors << ")";
122 
123  Warn(out);
124 
125  fNumConsecutiveMessages = 0;
126 
127  return false;
128  }
uint32_t ad7719_values[kNumResistanceChannels]
Definition: HeadersFSC.h:30
size_t fNumConsecutiveMessages
Definition: fscctrl.cc:36
FSC::BinaryOutput_t fMsg
Definition: fscctrl.cc:30
uint16_t Fletcher16(const T *t, size_t cnt)
Definition: tools.h:22
size_t fNumConsecutiveErrors
Definition: fscctrl.cc:35
uint16_t adc_values[kNumVoltageChannels]
Definition: HeadersFSC.h:38
uint16_t adc_values_checksum
Definition: HeadersFSC.h:39
uint16_t ad7719_values_checksum
Definition: HeadersFSC.h:31

+ Here is the call graph for this function: