Mod Bus TCPIP for QNX4.25

Hello all ,
We are using watcom 10.6 (wcc only) and QNX 4.25 and we need a Mod Bus TCPIP drivers for QNX.

Cogent (www.cogent.ca ) makes some good driver maybe they have one for ModBus Plus. Steinhoff also makes drivers, check them out.

Having written a bunch of stuff to interface to PLC, I can tell you from experience that info it’s not that hard to write a driver for this type of thing.

The problem with cogent is you have to use a dedicated hardware and the license is link directly to the hardware.If your hardware failed and you have to replace it … well … you software stop to work because the licence doesn’t match with the new hardware.

Multiplie this by a 1000 , just to much.

Also cogent don’t have Mod Bus TCPIP.

I found this company from australia

focus-sw.com/
*They have a drivers for QNX in c++.

I was looking for something for c instead of c++.

They sell the source? Get someone to convert it to C shouldn’t be very difficult. I wouldn’t mind taking a stab at stuff like that ;)

Some materials are on www.modbus.org->Modbus Resources

It is really simple to create a client communicating with modbus over TCPIP. Materials on www.modbus.org are fully adequate.

Depending on your architecture TCPIP “driver” is not necessary. I created small communicating client in 2 days ( simple, nice and small :slight_smile:

Hi michalek,
Simple , nice and small . That sound good to me. :wink:
We would like to be able to look at your small communicating client if possible of course.

By the way this is the link of the other protocol

Internet IP Spec (Allen Bradley)
odva.org/

Mario ,
If you have a library compile in C++ and your link this to a regular C project , can you compile with wcc ? I believe you have to do some extern wrapping when you include your file.

For some reason I can’t add attachment so I just paste the tcpip demo exemple.


// Platform header
#include <stdio.h>
#include <stdlib.h>

// Include FieldTalk package header
#include "MbusTcpMasterProtocol.hpp"


/************************************************************
 * Gobal data
 ************************************************************/

char *hostName = "127.0.0.1";
MbusTcpMasterProtocol mbusProtocol;


/************************************************************
 * Function implementation
 ************************************************************/

/**
 * Opens protocol
 */
void openProtocol()
{
   int result;

   result = mbusProtocol.openProtocol(hostName);
   if (result != FTALK_SUCCESS)
   {
      fprintf(stderr, "Error opening protocol: %s!\n",
                       getBusProtocolErrorText(result));
      exit(EXIT_FAILURE);
   }
}


/**
 * Closes protocol
 */
void closeProtocol()
{
   mbusProtocol.closeProtocol();
}


/**
 * Cyclic loop which polls every one second 10 registers starting at
 * reference 100 from slave # 1
 */
void runPollLoop()
{
   short dataArr[10];

   for (;;)
   {
      int i;
      int result;

      result = mbusProtocol.readMultipleRegisters(1, 100,
                                                  dataArr,
                                                  sizeof(dataArr) / 2);
      if (result == FTALK_SUCCESS)
         for (i = 0; i < int(sizeof(dataArr) / 2); i++)
            printf("[%d]: %hd\n", 100 + i, dataArr[i]);
      else
      {
         fprintf(stderr, "%s!\n", getBusProtocolErrorText(result));
         // Stop for fatal errors
         if (!(result & FTALK_BUS_PROTOCOL_ERROR_CLASS))
            return;
      }

#ifdef __WIN32__
      Sleep(1000);
#else
      sleep(1);
#endif
   }
}


/**
 * Main function.
 *
 * @return Error code: 0 = OK, else error
 */
int main()
{
   openProtocol();

   runPollLoop();

   closeProtocol();
   return (EXIT_SUCCESS);
}

There will be problem at link time. Either you write wrapper or you compile your C code with C++ compiler (which I like to do as a general practice)

Sorry, I was very busy ;(
I can send you simple app comunicating with MODBUS to your mail address ( sent by private message or on my fake email mmichalek at yahoo dot com ).