mz-automation / libiec61850

Official repository for libIEC61850, the open-source library for the IEC 61850 protocols
http://libiec61850.com/libiec61850
GNU General Public License v3.0
857 stars 459 forks source link

Issue in SVPublisher_ASDU_setSmpRate #308

Open faheemahmed21 opened 3 years ago

faheemahmed21 commented 3 years ago

I am trying to generate 4000 samples per second by setting sample mod to samples per second and then specifying 4000 samples per second to be generated.

    SVPublisher_ASDU_setSmpMod  (asdu1, IEC61850_SV_SMPMOD_SAMPLES_PER_SECOND);
    SVPublisher_ASDU_setSmpRate     (asdu1, 4000);

However, upon execution, the programme generates samples per second randomly rather than 4000 samples per second.

mzillgith commented 3 years ago

It sends one message when you call SVPublisher_publish. So the code that is calling SVPublisher_publish is responsible to ensure the sample rate. SVPublisher_ASDU_setSmpRate only set the value in the SV message header.

faheemahmed21 commented 3 years ago

Thank you for your response.

My purpose to see these commands is to define the sample rate of 4000 samples per second and for that purpose, I am using SVPublisher_ASDU_setSmpRate. However, upon using that command, I am unable to achieve the desired sample rate of 4000 samples per second. Could you please comment on how to achieve the desired sample rate? Thank you.

mzillgith commented 3 years ago

You have to ensure that you call SVPublisher_publish in the frequency required by your sampling rate and the number of samples per ASDU. On a linux system you can approximate this with calling usleep and tweaking the wait time between SVPublisher_publish calls. This might work for a prototype. But for a production solution you would need some kind of RTOS integration.