TestDbus.cpp



/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 2 -*- */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <dbus.hpp>

int main(int argc, char *argv[])
{

  if(argc<2)
  {
    puts("\nUSE:\nTestDbus <type>\n");
    puts("types:");
    puts("\tsend <name> <signal> <data>");
    puts("\trecv <name> <signal>\n");
    puts("\t  e.g.");
    puts("\t    TestDbus send test testing \"something to send\" => Sends \"something\" to test/testing.");
    puts("\t    TestDbus recv test testing => Waits to receive something on test/testing\n");

    exit(EXIT_SUCCESS);
  }


  if(strcmp(argv[1],"recv")==0)
  {
    char* buffer=(char*)malloc(100*sizeof(char));
    CMDbus conexion(argv[2],argv[3],1024);
    conexion.ruleSignal();
    printf("Waiting signal...\n");
    int a=0;
    while(a<1)
      a=conexion.recvSignal(buffer);

    printf("Number of characters received:\t%d\nReceived:\t%s\n",a,buffer);
    free(buffer);
  }

  if(strcmp(argv[1],"send")==0)
  {
    CMDbus conexion(argv[2],argv[3],1024);
    conexion.sendSignal(argv[4]);
  }
  
}
 All Data Structures Functions Variables
Generated on Mon Sep 12 07:59:09 2011 for API MokArdu by  doxygen 1.6.3