コード例 #1
0
ファイル: main.c プロジェクト: EIPStackGroup/OpENer
void *executeEventLoop() {
  /* The event loop. Put other processing you need done continually in here */
  while (1 != g_end_stack) {
    if (kEipStatusOk != NetworkHandlerProcessOnce() ) {
      OPENER_TRACE_ERR("Error in NetworkHandler loop! Exiting OpENer!\n");
      break;
    }
  }
}
コード例 #2
0
ファイル: main.c プロジェクト: EIPStackGroup/OpENer
int main(int argc,
         char *arg[]) {
  EipUint16 nUniqueConnectionID;

  if (argc != 2) {
    printf("Wrong number of command line parameters!\n");
    printf("The correct command line parameters are:\n");
    printf(
      "./OpENer ip-address\n");
    printf(
      "    e.g. ./OpENer 192.168.259.22\n");
    exit(0);
  } else {
    DoublyLinkedListInitialize(&connection_list,
                               CipConnectionObjectListArrayAllocator,
                               CipConnectionObjectListArrayFree);
    /* fetch Internet address info from the platform */
    ConfigureDomainName();
    ConfigureHostName();
    ConfigureNetworkInterface(arg[1] );
  }

  /*for a real device the serial number should be unique per device */
  SetDeviceSerialNumber(123456789);

  /* nUniqueConnectionID should be sufficiently random or incremented and stored
   *  in non-volatile memory each time the device boots.
   */
  nUniqueConnectionID = rand();

  /* Setup the CIP Layer */
  CipStackInit(nUniqueConnectionID);

  /* Setup Network Handles */
  if ( kEipStatusOk == NetworkHandlerInitialize() ) {
    g_end_stack = 0;
#ifndef WIN32
    /* register for closing signals so that we can trigger the stack to end */
    signal(SIGHUP, LeaveStack);
#endif

    /* The event loop. Put other processing you need done continually in here */
    while (1 != g_end_stack) {
      if ( kEipStatusOk != NetworkHandlerProcessOnce() ) {
        break;
      }
    }

    /* clean up network state */
    NetworkHandlerFinish();
  }
  /* close remaining sessions and connections, cleanup used data */
  ShutdownCipStack();

  return -1;
}
コード例 #3
0
ファイル: main.c プロジェクト: AlexRSc/OpENer
int main(int argc, char *arg[]) {
  EipUint8 acMyMACAddress[6];
  EipUint16 nUniqueConnectionID;

  if (argc != 12) {
    printf("Wrong number of command line parameters!\n");
    printf("The correct command line parameters are:\n");
    printf(
        "./OpENer ipaddress subnetmask gateway domainname hostaddress macaddress\n");
    printf(
        "    e.g. ./OpENer 192.168.0.2 255.255.255.0 192.168.0.1 test.com testdevice 00 15 C5 BF D0 87\n");
    exit(0);
  } else {
    /* fetch Internet address info from the platform */
    ConfigureNetworkInterface(arg[1], arg[2], arg[3]);
    ConfigureDomainName(arg[4]);
    ConfigureHostName(arg[5]);

    acMyMACAddress[0] = (EipUint8) strtoul(arg[6], NULL, 16);
    acMyMACAddress[1] = (EipUint8) strtoul(arg[7], NULL, 16);
    acMyMACAddress[2] = (EipUint8) strtoul(arg[8], NULL, 16);
    acMyMACAddress[3] = (EipUint8) strtoul(arg[9], NULL, 16);
    acMyMACAddress[4] = (EipUint8) strtoul(arg[10], NULL, 16);
    acMyMACAddress[5] = (EipUint8) strtoul(arg[11], NULL, 16);
    ConfigureMacAddress(acMyMACAddress);
  }

  /*for a real device the serial number should be unique per device */
  SetDeviceSerialNumber(123456789);

  /* nUniqueConnectionID should be sufficiently random or incremented and stored
   *  in non-volatile memory each time the device boots.
   */
  nUniqueConnectionID = rand();

  /* Setup the CIP Layer */
  CipStackInit(nUniqueConnectionID);

  /* Setup Network Handles */
  if (kEipStatusOk == NetworkHandlerInitialize()) {
    g_end_stack = 0;
#ifndef WIN32
    /* register for closing signals so that we can trigger the stack to end */
    signal(SIGHUP, LeaveStack);
#endif

    /* The event loop. Put other processing you need done continually in here */
    while (1 != g_end_stack) {
      if (kEipStatusOk != NetworkHandlerProcessOnce()) {
        break;
      }
    }

    /* clean up network state */
    NetworkHandlerFinish();
  }
  /* close remaining sessions and connections, cleanup used data */
  ShutdownCipStack();

  return -1;
}