Merge pull request #33 from stv0g/sv-add-smprate

Sampled Values: add support for sample rate attribute
pull/37/head
Michael Zillgith 8 years ago committed by GitHub
commit 5d03e77343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -59,6 +59,7 @@ struct sSV_ASDU {
uint64_t refrTm; uint64_t refrTm;
uint8_t smpMod; uint8_t smpMod;
uint16_t smpRate;
uint8_t* smpCntBuf; uint8_t* smpCntBuf;
@ -397,7 +398,8 @@ SV_ASDU_encodeToBuffer(SV_ASDU self, uint8_t* buffer, int bufPos)
buffer[bufPos++] = self->smpSynch; buffer[bufPos++] = self->smpSynch;
/* SmpRate */ /* SmpRate */
//TODO implement me bufPos = BerEncoder_encodeTL(0x86, 2, buffer, bufPos);
bufPos = encodeUInt16FixedSize(self->smpRate, buffer, bufPos);
/* Sample */ /* Sample */
bufPos = BerEncoder_encodeTL(0x87, self->dataSize, buffer, bufPos); bufPos = BerEncoder_encodeTL(0x87, self->dataSize, buffer, bufPos);
@ -639,3 +641,9 @@ SV_ASDU_setSmpMod(SV_ASDU self, uint8_t smpMod)
self->smpMod = smpMod; self->smpMod = smpMod;
} }
void
SV_ASDU_setSmpRate(SV_ASDU self, uint16_t smpRate)
{
self->hasSmpRate = true;
self->smpRate = smpRate;
}

@ -127,6 +127,18 @@ SV_ASDU_setRefrTm(SV_ASDU self, uint64_t refrTm);
void void
SV_ASDU_setSmpMod(SV_ASDU self, uint8_t smpMod); SV_ASDU_setSmpMod(SV_ASDU self, uint8_t smpMod);
/**
* \brief Set the sample rate of the ASDU.
*
* If not set the transmitted ASDU will not contain an smpRate value.
*
* \param self the SV_ASDU
*
* \param smpRate Amount of samples (default per nominal period, see SmpMod).
*/
void
SV_ASDU_setSmpRate(SV_ASDU self, uint16_t smpRate);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

Loading…
Cancel
Save