#include #include #include #include #include #include int makeFcomPVNamewithSlotNumber_(const char *muxName, const char *fcomPVName, int slot_number) { return sprintf(fcomPVName, "%s:GETFCOM_%d", muxName, slot_number); } int verifyBlob(FcomBlob *pBlob, mux_ts *pMux) { pau_ts *pPau = pMux->pPau; unsigned int dataSlot = pPau->advance.matchedDataSlot; epicsTimeStamp prev_timestamp = pPau->current.prev_timestamp[dataSlot]; epicsTimeStamp sent_timestamp; unsigned int sentPulseId, matchedPulseId; if(pBlob) { if((pBlob->hdr.vers != FCOM_PROTO_VERSION) || (pBlob->hdr.type != FCOM_EL_DOUBLE)) return RF_FCOM_MISMATCH; /* version/type mismatch */ sent_timestamp.secPastEpoch = pBlob->fc_tsHi; sent_timestamp.nsec = pBlob->fc_tsLo; matchedPulseId = PULSEID(prev_timestamp); sentPulseId = PULSEID(sent_timestamp); if(matchedPulseId != sentPulseId) return RF_FCOM_WRONGTIMMING; /* Not healthy */ else return RF_FCOM_OK; /* OK */ } return RF_FCOM_COMMERR; /* communication error */ } int verifyBlob2(FcomBlob *pBlob, mux_ts *pMux) { pau_ts *pPau = pMux->pPau; unsigned int dataSlot = pPau->advance.matchedDataSlot; epicsTimeStamp prev_timestamp = pPau->current.prev_timestamp[dataSlot]; epicsTimeStamp sent_timestamp; unsigned int sentPulseId, matchedPulseId; if(pBlob) { if((pBlob->hdr.vers != FCOM_PROTO_VERSION) || (pBlob->hdr.type != FCOM_EL_DOUBLE)) return RF_FCOM_MISMATCH; /* version/type mismatch */ sent_timestamp.secPastEpoch = pBlob->fc_tsHi; sent_timestamp.nsec = pBlob->fc_tsLo; matchedPulseId = PULSEID(prev_timestamp); sentPulseId = PULSEID(sent_timestamp); if(matchedPulseId != sentPulseId) printf("L1S: %d, %d, (%d)\n", matchedPulseId, sentPulseId, matchedPulseId-sentPulseId); if(matchedPulseId != sentPulseId) return RF_FCOM_WRONGTIMMING; /* Not healthy */ else return RF_FCOM_OK; /* OK */ } return RF_FCOM_COMMERR; /* communication error */ }