← Back to team overview

modbus team mailing list archive

Make libmodbus more usable

 

  Dear modbus team!

In my project I need to use your lib. But I am using it in real-time system.

So I need to separate the Communication API from Message-generation
functions.

So, the code must be next:(simple version of slave)

char *InBuf, *OutBuf;
int InLength, OutLength;
volatile bool MessageReceived, ResponceReady;

void nonRT_Thread() {  // (non real-time thread. Communication only)
     ... Initialize Modbus
     for (;;) {
         modbus_receive(...InBuf, &InLength);
         ResponseReady=0; MessageReceived=1;
         while (!ResponceReady) { // Wait response from RT thread
               usleep(20000);
         }
         ResponceReady = 0;
         modbus_send(..., OutBuf, OutLength);
     }
}

void RTThread() { // Task, that cyclically called it RT enviroument
     if (MessageReceived) {
          manage_query(..., InBuf, InLength, OutBuf, OutLength);
          MessageReceived = 0; ResponseReady = 1;
     }

}

---------------------------------------

I can do it all by myself. I do not ask You to work for me. But if I do it
alone, I will lose any quick support from your team.
And you will lose BUG feedback from me.

Please, examine a posibility of doing my proposition

I wish you success!
Stratiyenko Roman

Follow ups