Example #1
0
int main(int ac, char **av)
{
  int offset,ret,first;
  if(ac > 0) av0 = av[0];
  first = 1;
  printf("\n%s starting\n",av0);
  modbus.registerSocket(&sock);
  thread.create(reader,NULL);
  watchdog.create(watchdogthread,NULL);

  shm.write(modbusdaemon_LIFE_COUNTER_BASE,&lifeCounter,2);
  shm.write(modbusdaemon_READ_ERROR_COUNT_BASE,&readErrorCount,2);
  shm.write(modbusdaemon_WRITE_ERROR_COUNT_BASE,&writeErrorCount,2);
  while(1)
  {
    lifeCounter++;
    if(lifeCounter >= 256*128) lifeCounter = 0;
    shm.write(modbusdaemon_LIFE_COUNTER_BASE,&lifeCounter,2);
    offset = 0;
    //    modbusCycle(offset, slave, function, start_adr, num_register);
    ret = modbusCycle(offset,1,3,100,2);
    if(ret>0) offset += ret; else continue;
  }

  // we will never come here
  return 0;
}
Example #2
0
int main(int ac, char **av)
{
PARAM p;
int   s;

  pvInit(ac,av,&p);
  /* here you may interpret ac,av and set p->user to your data */
  memset(sendData,0,sizeof(sendData));
  memset(receiveData,0,sizeof(receiveData));
  pbus.create(profibus,NULL);
  while(1)
  {
    s = pvAccept(&p);
    if(s != -1) pvCreateThread(&p,s);
    else        break;
  }
  return 0;
}
Example #3
0
int create_center()
{
  center.create(centerMain,NULL);
  return 0;
}