Esempio n. 1
0
main (int argc, char**argv)
{
	/* handling of -b option */
	const char* bus = 0;
	char c;
	while (c = getopt (argc, argv, "b:") != EOF) {
		switch (c) {
		case 'b':
			bus = optarg;
			break;
		}
	}

	/* handling of environment variable */
	if (!bus)
		bus = getenv ("IVYBUS");

	/* initializations */
	IvyInit ("IvyTranslater", "Hello le monde", 0, 0, 0, 0);
	IvyStart (bus);

	/* binding of HelloCallback to messages starting with 'Hello' */
	IvyBindMsg (HelloCallback, 0, "^Hello(.*)");

	/* binding of ByeCallback to 'Bye' */
	IvyBindMsg (ByeCallback, 0, "^Bye$");

	/* main loop */
	IvyMainLoop();
}
Esempio n. 2
0
void nps_ivy_common_init(char* ivy_bus) {
  const char* agent_name = AIRFRAME_NAME"_NPS";
  const char* ready_msg = AIRFRAME_NAME"_NPS Ready";
  IvyInit(agent_name, ready_msg, NULL, NULL, NULL, NULL);
  IvyBindMsg(on_DL_PING, NULL, "^(\\S*) DL_PING");
  IvyBindMsg(on_DL_SETTING, NULL, "^(\\S*) DL_SETTING (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_DL_GET_SETTING, NULL, "^(\\S*) GET_DL_SETTING (\\S*) (\\S*)");
  IvyBindMsg(on_DL_BLOCK, NULL,   "^(\\S*) BLOCK (\\S*) (\\S*)");

#ifdef RADIO_CONTROL_TYPE_DATALINK
  IvyBindMsg(on_DL_RC_3CH, NULL, "^(\\S*) RC_3CH (\\S*) (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_DL_RC_4CH, NULL, "^(\\S*) RC_4CH (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
#endif

#ifdef __APPLE__
  const char* default_ivy_bus = "224.255.255.255";
#else
  const char* default_ivy_bus = "127.255.255.255";
#endif
  if (ivy_bus == NULL) {
    IvyStart(default_ivy_bus);
  } else {
    IvyStart(ivy_bus);
  }
}
Esempio n. 3
0
int main(int argc, char** argv)
{
    int ret = 0;

    if (!parse_args(argc, argv))
        return 1;

    GMainLoop *ml =  g_main_loop_new(NULL, FALSE);

    gpsdata = malloc(sizeof(struct gps_data_t));

    printf("Connecting to gpsd server %s, port %s\n", server, port);

    ret = gps_open(server, port, gpsdata);
    if (ret != 0) {
        perror("error connecting to gpsd");
        return 1;
    }

    gps_stream(gpsdata, WATCH_ENABLE, NULL);

    IvyInit ("GPSd2Ivy", "GPSd2Ivy READY", NULL, NULL, NULL, NULL);
    IvyStart(ivy_bus);

    g_timeout_add(TIMEOUT_PERIOD, gps_periodic, NULL);

    g_main_loop_run(ml);

    (void) gps_stream(gpsdata, WATCH_DISABLE, NULL);
    (void) gps_close (gpsdata);

    free(gpsdata);

    return ret;
}
Esempio n. 4
0
int main(int argc, char *argv[])
{
    char *server = NULL, *port = DEFAULT_GPSD_PORT;
    bool running = true;
    int ret = 0;
    GMainLoop *ml =  g_main_loop_new(NULL, FALSE);


    gpsdata = malloc(sizeof(struct gps_data_t));

    ret = gps_open(NULL, port, gpsdata);
    if (ret != 0) {
        perror("error connecting to gpsd");
        return 1;
    }

    gps_stream(gpsdata, WATCH_ENABLE, NULL);

    IvyInit ("GPSd2Ivy", "GPSd2Ivy READY", NULL, NULL, NULL, NULL);
    IvyStart("224.255.255.255:2010");

    g_timeout_add(TIMEOUT_PERIOD, gps_periodic, NULL);

    g_main_loop_run(ml);

    (void) gps_stream(gpsdata, WATCH_DISABLE, NULL);
    (void) gps_close (gpsdata);

    free(gpsdata);

    return ret;
}
Esempio n. 5
0
int main ( int argc, char** argv) {
  GIOChannel *sk;
  struct hostent *hent;
  int c;

  printf("Starting TCP2IVY agent for AC %s (id:%d)\n", AIRFRAME_NAME, AC_ID);
  fflush(stdout);

  IvyInit ("IvySatCom", "IvySatCom READY", NULL, NULL, NULL, NULL);
  IvyStart("127.255.255.255");

  while ((c = getopt(argc, argv, "h:s:")) != EOF) {
    switch (c) {

    case 'h':
      printf(usage_str);
      break;

    case 's':
      strncpy(hostaddr, optarg, strlen(optarg)+1);
      break;
    }
  }

  sock = socket(PF_INET, SOCK_STREAM, 0);
  if (sock < 0) {
    perror("socket");
    exit(1);
  }

  hent = gethostbyname(hostaddr);
  if (hent == 0) {
    perror("unknown host");
    exit(1);
  }

  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_port = htons(PORT_OUT);
  memcpy((char *)&addr.sin_addr,
         (char *)hent->h_addr_list[0],
         4);

  if (connect(sock, (struct sockaddr *) &addr, sizeof(addr))) {
    perror("connect");
    exit(1);
  }

  sk = g_io_channel_unix_new(sock);
  g_io_add_watch(sk, G_IO_IN | G_IO_NVAL | G_IO_HUP,
                 read_data, NULL);
  g_timeout_add(TIMEOUT_PERIOD, alive, NULL);

  ml =  g_main_loop_new(NULL, FALSE);

  g_main_loop_run(ml);

  return 0;
}
Esempio n. 6
0
int main(int argc, char **argv)
{
	double angular_velocity_covariance, angular_velocity_stdev;
	double linear_acceleration_covariance, linear_acceleration_stdev;
	double orientation_covariance, orientation_stdev;
	std::string frame_id;
	
	// Initializing ROS
	ros::init(argc, argv, "imu");
	ros::NodeHandle nh("~");
	
	imu_message = nh.advertise<sensor_msgs::Imu>("data", 10);
	att_message = nh.advertise<sensor_msgs::Imu>("att", 10);
	mag_message = nh.advertise<geometry_msgs::Vector3Stamped>("mag", 10);
	acc_message = nh.advertise<geometry_msgs::Vector3Stamped>("acc", 10);
	
	// Getting Parameters
	nh.param<std::string>("frame_id", frame_id, "imu");
    imu_data.header.frame_id = frame_id;
    mag_data.header.frame_id = frame_id;

    nh.param("linear_acceleration_stdev", linear_acceleration_stdev, 0.0); 
    nh.param("orientation_stdev", orientation_stdev, 0.0); 
    nh.param("angular_velocity_stdev", angular_velocity_stdev, 0.0); 

    angular_velocity_covariance = pow(angular_velocity_stdev,2);
    orientation_covariance = pow(orientation_stdev,2);
    linear_acceleration_covariance = pow(linear_acceleration_stdev,2);
    
    // Fill IMU Message with covariances
    imu_data.linear_acceleration_covariance[0] = linear_acceleration_covariance;
    imu_data.linear_acceleration_covariance[4] = linear_acceleration_covariance;
    imu_data.linear_acceleration_covariance[8] = linear_acceleration_covariance;

    imu_data.angular_velocity_covariance[0] = angular_velocity_covariance;
    imu_data.angular_velocity_covariance[4] = angular_velocity_covariance;
    imu_data.angular_velocity_covariance[8] = angular_velocity_covariance;
    
    imu_data.orientation_covariance[0] = orientation_covariance;
    imu_data.orientation_covariance[4] = orientation_covariance;
    imu_data.orientation_covariance[8] = orientation_covariance;

	// Initializing Ivy
	IvyInit ("imu_parser", "'Imu Parser' is READY!", 0, 0, 0, 0);
	IvyStart("127.255.255.255");
	TimerRepeatAfter (TIMER_LOOP, 500, ROSCallback, 0);
	
	// Binding Messages
	IvyBindMsg(ATTCallback, 0, "BOOZ2_AHRS_EULER(.*)");
	IvyBindMsg(GYROCallback, 0, "IMU_GYRO_SCALED(.*)");
	IvyBindMsg(ACCELCallback, 0, "IMU_ACCEL_SCALED(.*)");
	IvyBindMsg(MAGCallback, 0, "IMU_MAG_SCALED(.*)");
	
	ROS_INFO("IMU: Starting Aquisition Loop");

	IvyMainLoop();
	
	return 0;
}
Esempio n. 7
0
void nps_ivy_init(void) {
  const char* agent_name = AIRFRAME_NAME"_NPS";
  const char* ready_msg = AIRFRAME_NAME"_NPS Ready";
  IvyInit(agent_name, ready_msg, NULL, NULL, NULL, NULL);
  IvyBindMsg(on_DL_PING, NULL, "^(\\S*) DL_PING");
  IvyBindMsg(on_DL_SETTING, NULL, "^(\\S*) DL_SETTING (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_DL_GET_SETTING, NULL, "^(\\S*) DL_GET_SETTING (\\S*) (\\S*)");
  IvyBindMsg(on_DL_BLOCK, NULL,   "^(\\S*) BLOCK (\\S*) (\\S*)");
  IvyBindMsg(on_DL_MOVE_WP, NULL, "^(\\S*) MOVE_WP (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
  IvyStart("127.255.255.255");
}
Esempio n. 8
0
void calibrator_init(void) {

  IvyInit ("IrCalib", "IrCalib READY", NULL, NULL, NULL, NULL);
  IvyBindMsg(on_Attitude, NULL, "^(\\S*) ATTITUDE (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_GPS, NULL, "^(\\S*) GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_Wind, NULL, "^(\\S*) WIND (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_IrSensors, NULL, "^(\\S*) IR_SENSORS (\\S*) (\\S*) (\\S*)");
  IvyStart("127.255.255.255");

  reset_average();
}
int main ( int argc, char** argv) {

  GMainLoop *ml =  g_main_loop_new(NULL, FALSE);
  
  parse_args(argc, argv);
  
  IvyInit ("IvyFdmStep", "IvyFdmStep READY", NULL, NULL, NULL, NULL);
  IvyStart("127.255.255.255");

  g_timeout_add(TIMEOUT_PERIOD, periodic, NULL);
  
  g_main_loop_run(ml);

  return 0;
}
Esempio n. 10
0
int main (int argc, char** argv) {

  gtk_init(&argc, &argv);

  GtkWidget* window = build_gui();
  gtk_widget_show_all(window);

  IvyInit ("AntennaTracker", "AntennaTracker READY", NULL, NULL, NULL, NULL);
  IvyBindMsg(on_GPS_STATUS, NULL, "^\\S* GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_NAV_STATUS, NULL, "^\\S* NAVIGATION (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
  IvyStart("127.255.255.255");

  gtk_main();
  return 0;
}
Esempio n. 11
0
int main(int argc, char **argv)
{
  // Set the default tracking system position and angle
  struct EcefCoor_d tracking_ecef;
  //alt 45 m because of ellipsoid altitude in Delft
  tracking_ecef.x = 3924331.5;
  tracking_ecef.y = 300361.7;
  tracking_ecef.z = 5002197.1;
  tracking_offset_angle = 33.0 / 57.6;
  ltp_def_from_ecef_d(&tracking_ltp, &tracking_ecef);

  // Parse the options from cmdline
  parse_options(argc, argv);
  printf_debug("Tracking system Latitude: %f Longitude: %f Offset to North: %f degrees\n", DegOfRad(tracking_ltp.lla.lat),
               DegOfRad(tracking_ltp.lla.lon), DegOfRad(tracking_offset_angle));

  // Create the network connections
  printf_debug("Starting NatNet listening (multicast address: %s, data port: %d, version: %d.%d)\n",
               natnet_multicast_addr, natnet_data_port, natnet_major, natnet_minor);
  udp_socket_create(&natnet_data, "", -1, natnet_data_port, 0); // Only receiving
  udp_socket_subscribe_multicast(&natnet_data, natnet_multicast_addr);
  udp_socket_set_recvbuf(&natnet_data, 0x100000); // 1MB

  printf_debug("Starting NatNet command socket (server address: %s, command port: %d)\n", natnet_addr, natnet_cmd_port);
  udp_socket_create(&natnet_cmd, natnet_addr, natnet_cmd_port, 0, 1);
  udp_socket_set_recvbuf(&natnet_cmd, 0x100000); // 1MB

  // Create the Ivy Client
  GMainLoop *ml =  g_main_loop_new(NULL, FALSE);
  IvyInit("natnet2ivy", "natnet2ivy READY", 0, 0, 0, 0);
  IvyStart(ivy_bus);

  // Create the main timers
  printf_debug("Starting transmitting and sampling timeouts (transmitting frequency: %dHz, minimum velocity samples: %d)\n",
               freq_transmit, min_velocity_samples);
  g_timeout_add(1000 / freq_transmit, timeout_transmit_callback, NULL);

  GIOChannel *sk = g_io_channel_unix_new(natnet_data.sockfd);
  g_io_add_watch(sk, G_IO_IN | G_IO_NVAL | G_IO_HUP,
                 sample_data, NULL);

  // Run the main loop
  g_main_loop_run(ml);

  return 0;
}
Esempio n. 12
0
int main(int argc,char *argv[]){
  Widget toplevel,pushb;
  XtAppContext app_context;
  Arg myargs[10];
  char *bus=getenv("IVYBUS");
  char *tosend="foo";
  toplevel=XtAppInitialize(&app_context,"Ivy Button",NULL,0,&argc,argv,NULL,myargs,0);
  pushb=XmCreatePushButton(toplevel,"send message",myargs,1);
  XtManageChild(pushb);
  XtAddCallback(pushb,XmNactivateCallback,myMotifCallback,&tosend);
  XtRealizeWidget(toplevel);
  IvyXtChannelAppContext(app_context);
  IvyInit("IvyMotif","IvyMotif connected",NULL,NULL,DieCallback,NULL);
  IvyBindMsg(textCallback,&tosend,"^Ivy Button text=(.*)");
  IvyStart(bus);
  XtAppMainLoop(app_context);
  return 0;
}
Esempio n. 13
0
int main (int argc, char** argv) {

  gtk_init(&argc, &argv);

  GtkWidget* window = build_gui();
  gtk_widget_show_all(window);

  IvyInit ("MotorBench", "MotorBench READY", NULL, NULL, NULL, NULL);
  IvyBindMsg(on_MOTOR_BENCH_STATUS, NULL, "^\\S* MOTOR_BENCH_STATUS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_MOTOR_BENCH_STATIC, NULL, "^\\S* MOTOR_BENCH_STATIC (\\S*) (\\S*) (\\S*) (\\S*)");
  IvyStart("127.255.255.255");

  g_timeout_add(40, timeout_callback, NULL);
  
  mb_state.log_channel = NULL;

  gtk_main();
  return 0;
}
Esempio n. 14
0
int main ( int argc, char** argv) {

  printf("hello\n");

  g_timeout_add(1000/25, timeout_callback, NULL);

  GMainLoop *ml =  g_main_loop_new(NULL, FALSE);
  
  IvyInit ("test_ahrs", "test_ahrs READY", NULL, NULL, NULL, NULL);
  IvyStart("127.255.255.255");

  imu_init();
  ahrs_init();

  aos_init();

  g_main_loop_run(ml);

  return 0;
}
Esempio n. 15
0
/* Real TCL interface */
static int
IvyInitCmd(ClientData	clientData,
	   Tcl_Interp	*interp,
	   int		argc,
	   const char	**argv)
{
  filter_struct	*app;
  filter_struct	*die;
     
  if (nom_de_l_appli) {
    Tcl_AppendResult(interp, "Ivy has been already inited", (char *) NULL);
    return TCL_ERROR;
  }

  if (argc != 5) {
    Tcl_AppendResult(interp, "wrong # of args: \"",
		     argv[0], " appName readyMsg connectScript dieScript\"",
		     (char *) NULL);
    return TCL_ERROR;
  }
  nom_de_l_appli = ckalloc(strlen(argv[1])+1);
  strcpy(nom_de_l_appli, argv[1]);
  message_de_bienvenue = ckalloc(strlen(argv[2])+1);
  strcpy(message_de_bienvenue, argv[2]);
  app = (filter_struct *) ckalloc(sizeof(filter_struct));
  die = (filter_struct *) ckalloc(sizeof(filter_struct));
  app->interp = interp;
  die->interp = interp;
  app->script = ckalloc(strlen(argv[3])+1);
  strcpy(app->script, argv[3]);
  die->script = ckalloc(strlen(argv[4])+1);
  strcpy(die->script, argv[4]);
  
  Tcl_InitHashTable(&filter_table, TCL_ONE_WORD_KEYS);
  Tcl_InitHashTable(&app_table, TCL_STRING_KEYS);
  /*printf("appel de businit avec %s %d %s\n", argv[1], port, argv[3]);*/
  IvyInit(nom_de_l_appli,  message_de_bienvenue,
	  IvyAppCB, (void *) app, IvyDieCB, (void *) die);
  
  return TCL_OK;
}
Esempio n. 16
0
void nps_ivy_init(char* ivy_bus) {
  const char* agent_name = AIRFRAME_NAME"_NPS";
  const char* ready_msg = AIRFRAME_NAME"_NPS Ready";
  IvyInit(agent_name, ready_msg, NULL, NULL, NULL, NULL);
  IvyBindMsg(on_DL_PING, NULL, "^(\\S*) DL_PING");
  IvyBindMsg(on_DL_SETTING, NULL, "^(\\S*) DL_SETTING (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_DL_GET_SETTING, NULL, "^(\\S*) DL_GET_SETTING (\\S*) (\\S*)");
  IvyBindMsg(on_DL_BLOCK, NULL,   "^(\\S*) BLOCK (\\S*) (\\S*)");
  IvyBindMsg(on_DL_MOVE_WP, NULL, "^(\\S*) MOVE_WP (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");

#ifdef __APPLE__
  const char* default_ivy_bus = "224.255.255.255";
#else
  const char* default_ivy_bus = "127.255.255.255";
#endif
  if (ivy_bus == NULL) {
    IvyStart(default_ivy_bus);
  } else {
    IvyStart(ivy_bus);
  }
}
Esempio n. 17
0
int main( int   argc, char *argv[] )
{
    GtkWidget *window;
    GtkWidget *button;
    GtkWidget *box1;

    char *bus=getenv("IVYBUS");

    gtk_init(&argc, &argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_container_set_border_width(GTK_CONTAINER(window), 10);
    gtk_window_set_title (GTK_WINDOW (window), "River Tracking");

    box1 = gtk_hbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), box1);

    //first button...
    button = gtk_button_new_with_label("(Re)define region of interest");
    g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(init_river_tracking), 0);
    gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0);
    gtk_widget_show (button);

    //second button...
    button = gtk_button_new_with_label("Quit");
    g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(destroy), 0);
    gtk_box_pack_start(GTK_BOX (box1), button, TRUE, TRUE, 0);
    gtk_widget_show (button);

    gtk_widget_show(box1);
    gtk_widget_show(window);

    IvyInit("river_track", "river_track READY", NULL, NULL, NULL, NULL);
    IvyBindMsg(textCallback,0,"^river_track hello(.*)");
    IvyBindMsg(start_track,0,"(NAV_STATUS 1 1 +.*)");
    IvyBindMsg(set_end,0,"(WAYPOINT_MOVED 1 5 +.*)");
    IvyStart(bus);

    gtk_main();
    return 0;
}
Esempio n. 18
0
int main(int argc, char *argv[])
{
    char *server = NULL, *port = DEFAULT_GPSD_PORT;
    GMainLoop *ml =  g_main_loop_new(NULL, FALSE);

    gpsdata = gps_open(server, port);

    if (!gpsdata) perror("error connecting to gpsd");

    gps_set_raw_hook(gpsdata, update_gps);

    gps_stream(gpsdata, WATCH_ENABLE, NULL);
  
    IvyInit ("GPSd2Ivy", "GPSd2Ivy READY", NULL, NULL, NULL, NULL);
    IvyStart("127.255.255.255");
  
    g_timeout_add(TIMEOUT_PERIOD, gps_periodic, NULL);
  
    g_main_loop_run(ml);

    return 0;
}
Esempio n. 19
0
void nps_ivy_init(char *ivy_bus)
{
  const char *agent_name = AIRFRAME_NAME"_NPS";
  const char *ready_msg = AIRFRAME_NAME"_NPS Ready";
  IvyInit(agent_name, ready_msg, NULL, NULL, NULL, NULL);

  // bind on a general WORLD_ENV (not a reply to request)
  IvyBindMsg(on_WORLD_ENV, NULL, "^(\\S*) WORLD_ENV (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");

  // to be able to change datalink_enabled setting back on
  IvyBindMsg(on_DL_SETTING, NULL, "^(\\S*) DL_SETTING (\\S*) (\\S*) (\\S*)");

#ifdef __APPLE__
  const char *default_ivy_bus = "224.255.255.255";
#else
  const char *default_ivy_bus = "127.255.255.255";
#endif
  if (ivy_bus == NULL) {
    IvyStart(default_ivy_bus);
  } else {
    IvyStart(ivy_bus);
  }
}
Esempio n. 20
0
int main ( int argc, char** argv)
{
  if (argc < 2)
  {
    fprintf(stderr, "USE: mavlink-ivy-interface IP \n");
    return -1;
  }

  fprintf(stderr,"mavlink-ivy-interface forwarding to '%s' \n",argv[1]);

  udp_init(argv[1]);

  GMainLoop *ml =  g_main_loop_new(NULL, FALSE);

  IvyInit ("mavlink-ivy-interface", "mavlink-ivy-interface READY", NULL, NULL, NULL, NULL);
  IvyBindMsg(on_Attitude, NULL, "^(\\S*) ATTITUDE (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_Gps, NULL, "^(\\S*) GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");

  IvyStart("127.255.255.255");

  g_main_loop_run(ml);

  return 0;
}
Esempio n. 21
0
int main( int argc, char** argv)
{
    int srl_handle = config_port_serie();
    //pthread_t idthread;

    strcpy(num_avion, "+33640286564");

    //if(pthread_create(&idthread,NULL,Envoi_SMS_Uplink, (void*)srl_handle)!=0)// creation thread envoi_SMS_Uplink
    //{
    //	printf("Erreur creation du thread envoi_SMS_Uplink");
    //	exit(1);
    //}

    GMainLoop *ml =  g_main_loop_new(NULL, FALSE);

    //gtk_init(&argc, &argv);

    IvyInit ("SMS_GROUND", "SMS_GROUND READY", NULL, NULL, NULL, NULL);
    IvyStart("127.255.255.255");

    //IvyBindMsg(Jump_To_Block, NULL, "^(\\S*) JUMP_TO_BLOCK (\\S*) (\\S*)");

    g_timeout_add(300, lecture_port, (gpointer)srl_handle);

    g_timeout_add(400, init, (gpointer)srl_handle);


    g_main_loop_run(ml);


    //Clear(&MaPile);    /* Vider la pile avant de quitter. */

    //pthread_join(idthread,NULL);

    return 0;
}
Esempio n. 22
0
/// Main function
int main(int argc, char **argv) {
  // default values for options
  const char
    *defaultbus = "127.255.255.255:2010",
    *bus = defaultbus,
    *defaultdevice = "/dev/ttyUSB1";
  device = defaultdevice;
  long delay = 1000;

  // parse options
  char c;
  while ((c = getopt (argc, argv, "hab:d:i:s:")) != EOF) {
    switch (c) {
    case 'h':
      print_usage(argc, argv);
      exit(EXIT_SUCCESS);
      break;
    case 'a':
      want_alive_msg = TRUE;
      break;
    case 'b':
      bus = optarg;
      break;
    case 'd':
      device = optarg;
      break;
    case 'i':
      ac_id = atoi(optarg);
      break;
    case 's':
      delay = atoi(optarg)*1000;
      break;
    case '?':
      if (optopt == 'a' || optopt == 'b' || optopt == 'd' || optopt == 's')
        fprintf (stderr, "Option -%c requires an argument.\n", optopt);
      else if (isprint (optopt))
        fprintf (stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
      print_usage(argc, argv);
      exit(EXIT_FAILURE);
    default:
      abort ();
    }
  }


  // make Ctrl-C stop the main loop and clean up properly
  signal(SIGINT, sigint_handler);

  bzero (packet, PACKET_LENGTH);
  open_port(device);

  // setup Ivy communication
  IvyInit("davis2ivy", "READY", 0, 0, 0, 0);
  IvyStart(bus);

  // create timer
  tid = TimerRepeatAfter (0, delay, handle_timer, 0);

#if IVYMINOR_VERSION == 8
  IvyMainLoop (NULL,NULL);
#else
  IvyMainLoop ();
#endif

  return 0;
}
Esempio n. 23
0
/** Main function.
 */
int main(int argc, char **argv) {
  // default values for options
  const char
    *defaultbus = "127.255.255.255:2010",
    *bus = defaultbus,
    *defaultdevice = "/dev/rfcomm0";
  device = defaultdevice;
  long delay = 5000;

  // parse options
  char c;
  while ((c = getopt (argc, argv, "hamb:d:i:s:")) != EOF) {
    switch (c) {
    case 'h':
      print_usage(argc, argv);
      exit(EXIT_SUCCESS);
      break;
    case 'a':
      want_alive_msg = TRUE;
      break;
    case 'b':
      bus = optarg;
      break;
    case 'd':
      device = optarg;
      break;
    case 'i':
      ac_id = atoi(optarg);
      break;
    case 'm':
      metric_input = TRUE;
      break;
    case 's':
      delay = atoi(optarg)*1000;
      if (delay < 5000) {
        fprintf(stderr,"kestrel2ivy: Warning: Setting the sampling period less than 5 seconds\n"
          "may result in poor sampling performance!\n");
      }
      break;
    case '?':
      if (optopt == 'a' || optopt == 'b' || optopt == 'd' || optopt == 's')
        fprintf (stderr, "Option -%c requires an argument.\n", optopt);
      else if (isprint (optopt))
        fprintf (stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
      print_usage(argc, argv);
      exit(EXIT_FAILURE);
    default:
      abort ();
    }
  }

  // make Ctrl-C stop the main loop and clean up properly
  signal(SIGINT, sigint_handler);

  // zero out and initialize buffers
  int bufferSize = BUF_LENGTH;
  cbInit(&cb, bufferSize);

  bzero(packet, PACKET_LENGTH);
  msgState = UNINIT;
  open_port(device);

  // setup Ivy communication
  IvyInit("kestrel2ivy", "READY", 0, 0, 0, 0);
  IvyStart(bus);

  // create timer (Ivy)
  tid = TimerRepeatAfter (0, delay, handle_timer, 0);

	/* main loop */
#if IVYMINOR_VERSION == 8
        IvyMainLoop (NULL,NULL);
#else
        IvyMainLoop ();
#endif
  return 0;
}
Esempio n. 24
0
int main (int argc, char **argv)
{
	GtkWidget *window;
	GtkWidget *da;
	GdkGLConfig *glconfig;
	int xid=-1;

	/* handling of -b option */
	const char* bus = 0;
	char c;

	while ((c = getopt (argc, argv, "b:p:")) != EOF) {
		switch (c) {
		case 'b':
			bus = optarg;
			break;
		case 'p':
			xid = strtol(optarg,NULL,0);
			break;
		}
	}
	printf("xid %d \nbus %s \n",xid,bus);

	/* handling of environment variable */
	if (!bus) bus = getenv ("IVYBUS");



	gtk_init (&argc, &argv);
	gtk_gl_init (&argc, &argv);

	if (xid==-1){	
		window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
		gtk_window_set_default_size (GTK_WINDOW (window), 512, 400);		
 	}
	else {
		window = gtk_window_new(GTK_WINDOW_POPUP);
	}
	
		
	da = gtk_drawing_area_new ();


	gtk_container_add (GTK_CONTAINER (window), da);
	g_signal_connect_swapped (window, "destroy",
			G_CALLBACK (gtk_main_quit), NULL);
	gtk_widget_set_events (da, GDK_EXPOSURE_MASK);

	gtk_widget_show (window);

	if (xid!=-1){
		XReparentWindow(GDK_WINDOW_XDISPLAY(window->window), GDK_WINDOW_XWINDOW(window->window), xid, 0,0);
		gtk_widget_map(window); 
	}

	/* prepare GL */
	glconfig = gdk_gl_config_new_by_mode (
			GDK_GL_MODE_RGB |
			GDK_GL_MODE_DEPTH |
			GDK_GL_MODE_DOUBLE);

	if (!glconfig)
	{
		g_assert_not_reached ();
	}

	if (!gtk_widget_set_gl_capability (da, glconfig, NULL, TRUE,
				GDK_GL_RGBA_TYPE))
	{
		g_assert_not_reached ();
	}

	g_signal_connect (da, "configure-event",
			G_CALLBACK (configure), NULL);
	g_signal_connect (da, "expose-event",
			G_CALLBACK (expose), NULL);

	gtk_widget_show_all (window);

	g_timeout_add (1000 / 60, update, da);

	IvyInit ("pprzopengl", "pprzopengl READY", NULL, NULL, NULL, NULL);
 	IvyBindMsg(on_GPS_STATUS, NULL, "^\\S* GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
 	IvyBindMsg(on_ATTITUDE, NULL, "^\\S* ATTITUDE (\\S*) (\\S*) (\\S*)");
 	IvyStart(bus);

	gtk_main ();
	return(0);
}
Esempio n. 25
0
int main(int argc, char **argv) {
  int i;

  //Get process id
  ProcessID= getpid();
  // default password

  AppPass = defaultAppPass;

  // try environment variable first, set to default if failed
  IvyBus = getenv("IVYBUS");
  if (IvyBus == NULL) IvyBus = defaultIvyBus;

  // Parse options
  for (i = 1; i < argc; ++i) {
    if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
      print_help();
      exit(0);
    }
    else if (strcmp(argv[i], "-t") == 0) {
      tcp_port = atoi(argv[++i]);
    }
    else if (strcmp(argv[i], "-u") == 0) {
      udp_port = atoi(argv[++i]);
    }
    else if (strcmp(argv[i], "-b") == 0) {
      IvyBus = argv[++i];
    }
    else if (strcmp(argv[i], "-p") == 0) {
      AppPass = argv[++i];
    }
    else if (strcmp(argv[i], "-v") == 0) {
      verbose = 1;
    }
    else if (strcmp(argv[i], "-utcp") == 0) {
      uTCP = 1;
    }
    else {
      printf("App Server: Unknown option\n");
      print_help();
      exit(0);
    }
  }

  if (verbose) {
    printf("### Paparazzi App Server ###\n");
    printf("Server listen port (TCP)    : %d\n", tcp_port);
    if (uTCP) {
      printf("Server using TCP communication..\n");
    }else{
      printf("Server broadcast port (UDP) : %d\n", udp_port);
    }
    printf("Control Pass                : %s\n", AppPass);
    printf("Ivy Bus                     : %s\n", IvyBus);
    fflush(stdout);
  }


  //Create tcp listener
#if !GLIB_CHECK_VERSION (2, 35, 1)
  // init GLib type system (only for older version)
  g_type_init();
#endif
  GSocketService *service = g_socket_service_new();

  GInetAddress *address = g_inet_address_new_any(G_SOCKET_FAMILY_IPV6); //G_SOCKET_FAMILY_IPV4 could be used
  GSocketAddress *socket_address = g_inet_socket_address_new(address, tcp_port);
  //Add listener
  g_socket_listener_add_address(G_SOCKET_LISTENER(service), socket_address, G_SOCKET_TYPE_STREAM,
      G_SOCKET_PROTOCOL_TCP, NULL, NULL, NULL);

  g_object_unref(socket_address);
  g_object_unref(address);
  g_socket_service_start(service);

  //Connect listening signal
  g_signal_connect(service, "incoming", G_CALLBACK(new_connection), NULL);

  //Here comes the ivy bindings
  IvyInit ("PPRZ_App_Server", "Papparazzi App Server Ready!", NULL, NULL, NULL, NULL);

  IvyBindMsg(Ivy_All_Msgs, NULL, "(^ground (\\S*) (\\S*) .*)");
  IvyBindMsg(on_app_server_NEW_AC, NULL, "ground NEW_AIRCRAFT (\\S*)");
  IvyBindMsg(on_app_server_GET_CONFIG, NULL, "(\\S*) ground CONFIG (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)");
  IvyBindMsg(on_app_server_AIRCRAFTS, NULL, "(\\S*) ground AIRCRAFTS (\\S*)");
  IvyStart(IvyBus);

  GMainLoop *loop = g_main_loop_new(NULL, FALSE);

  if (verbose) {
    printf("Starting App Server\n");
    fflush(stdout);
  }
  IvySendMsg("app_server");

  g_timeout_add(100, request_ac_list, NULL);

  g_main_loop_run(loop);

  if (verbose) {
    printf("Stoping App Server\n");
    fflush(stdout);
  }
  return 0;
}
Esempio n. 26
0
int main ( int argc, char** argv) {
	
	//chaines de caracteres pour stocker les messages
	char bindMsgADC_GENERIC[32];
	char bindMsgCAMERA_SNAPSHOT[32];
	
	char bindMsgTOUT[32]; 
	char bindMsgGPS[32];
    char bindMsgNAV[32];
    char bindMsgATTITUDE[32];
	char bindMsgNAVREF[32];	
	
	char bindMsgon_Attitude[40];	
	
	
	//int id=1; //id de l'avion a monitorer par défaut, réglé avec GCS
	char sid[10]="."; //id de l'avion a monitorer par défaut, réglé avec GCS

	printf("usage: 	c_ivy_client_alarm id\nid is the identifier of the plane, for instance 3 for N3, . for any 1 caracter id(default)\n ");
		
	if (argc>=2)
		//sscanf(argv[1],"%d",&id);
		sscanf(argv[1],"%s",sid);
	printf("binding Ivy frame for id: %s \n",sid);
	
  GMainLoop *ml =  g_main_loop_new(NULL, FALSE);

  IvyInit ("c_ivy_client_alarm", "c_ivy_client_alarm READY", NULL, NULL, NULL, NULL);

//	IvyBindMsg(on_Attitude, NULL,"^(\\S*) ATTITUDE (\\S*) (\\S*) (\\S*)");	

/*	snprintf(bindMsgon_Attitude,40,"^(\\S*) ATTITUDE (\\S*) (\\S*) (\\S*)");
	IvyBindMsg(on_Attitude,0,bindMsgon_Attitude);
	printf(bindMsgon_Attitude);
	printf("\n"); 
*/	
	
	
	 
	
	
 /*
     snprintf(bindMsgTOUT,32,"(.*)");
	 IvyBindMsg(readTOUTIvyBus,0,bindMsgTOUT);
     printf(bindMsgTOUT);
	 printf("\n"); 
*/
	
    snprintf(bindMsgADC_GENERIC,32,"%s%s%s","(",sid," ADC_GENERIC .*)");
    IvyBindMsg(readADC_GENERICIvyBus,0,bindMsgADC_GENERIC);
    printf(bindMsgADC_GENERIC);
	printf("\n");
	 
	
	
	
    snprintf(bindMsgCAMERA_SNAPSHOT,32,"%s%s%s","(",sid," CAMERA_SNAPSHOT .*)");
    IvyBindMsg(readCAMERA_SNAPSHOTIvyBus,0,bindMsgCAMERA_SNAPSHOT);
    printf(bindMsgCAMERA_SNAPSHOT);
	printf("\n");
	
	
	/*
	 snprintf(bindMsgGPS,32,"%s%s%s","(",sid," GPS 3.*)");
	 IvyBindMsg(readGPSIvyBus,0,bindMsgGPS);
	 printf(bindMsgGPS);
	 printf("\n");
	  */
	
	/*
	snprintf(bindMsgGPS,32,"%s","(* GPS 3.*)");
	IvyBindMsg(readGPSIvyBus,0,bindMsgGPS);
	printf(bindMsgGPS);
	printf("\n");
	
	 /*
	 
	 snprintf(bindMsgNAV,32,"%s%s%s","(",sid," NAVIGATION .*)");
	 IvyBindMsg(readNAVIvyBus,0,bindMsgNAV);
	 printf(bindMsgNAV);
	 printf("\n"); 
	 
	 
	 snprintf(bindMsgATTITUDE,32,"%s%s%s","(",sid," ATTITUDE .*)");
	 IvyBindMsg(readATTITUDEIvyBus,0,bindMsgATTITUDE);
	 printf(bindMsgATTITUDE);
	 printf("\n");		
	 
	 
	 
	 snprintf(bindMsgNAVREF,32,"%s%s%s","(",sid," NAVIGATION_REF .*)");
	 IvyBindMsg(readNAVREFIvyBus,0,bindMsgNAVREF);
	 printf(bindMsgNAVREF);
	 printf("\n");  
*/
	 
	 
	 
//	 
#ifdef __APPLE__
	printf("Mac Os, network submask: 224.255.255.255\n");
	IvyStart("224.255.255.255");
#else
	printf("NO Mac Os, network submask: 127.255.255\n");
	IvyStart("127.255.255.255");
#endif
	
//	IvyStart("127.0.0.1");
	 	
  g_main_loop_run(ml);

  return 0;
}
Esempio n. 27
0
int main ( int argc, char** argv)
{
  int s = sizeof(local_uav);

  gtk_init(&argc, &argv);

  if (argc < 3)
  {
    printf("Use: ivy2serial ac_id serial_device\n");
    printf("or\n");
    printf("Use: ivy2serial ac_id serial_device xbee_power_level [0-4] to configure the xbee as broadcast, no retries\n");
    return -1;
  }

  if (argc == 4)
  {
    printf("Programming XBee Modem\n");
    power_level = (int) (argv[3][0]) - (int) '0';
    if (power_level < 0)
      power_level = 0;
    else if (power_level > 4)
      power_level = 4;
    printf("Set Power Level To: '%d'\n", power_level);
  }
  else
  {
    power_level = -1;
  }

  local_uav.ac_id = atoi(argv[1]);

  sprintf(status_str, "Listening to AC=%d, Serial Data Size = %d",local_uav.ac_id, s);
  sprintf(status_ivy_str, "---");
  sprintf(status_serial_str, "---");
  printf("%s\n",status_str);

  // Open Serial or Die
  port = argv[2];
  open_port(port);

  // Init UAV
  remote_uav.ac_id = 6;

  remote_uav.phi = 1000;
  remote_uav.theta = 200;
  remote_uav.psi = -3140;

  // Start IVY
  IvyInit ("IVY <-> Serial", "IVY <-> Serial READY", NULL, NULL, NULL, NULL);
  IvyBindMsg(on_Desired, NULL, "^%d DESIRED (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id);
  IvyBindMsg(on_Estimator, NULL, "^%d ESTIMATOR (\\S*) (\\S*)",local_uav.ac_id);
  IvyBindMsg(on_Navigation, NULL, "^%d NAVIGATION (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id);
  IvyBindMsg(on_Attitude, NULL, "^%d ATTITUDE (\\S*) (\\S*) (\\S*)", local_uav.ac_id);
  IvyBindMsg(on_Gps, NULL, "^%d GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id);
  IvyStart("127.255.255.255");

  // Add Timer
  gtk_timeout_add(delay / 4, timeout_callback, NULL);

  // GTK Window
  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "IVY_Serial_Bridge");

  gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                        GTK_SIGNAL_FUNC (delete_event), NULL);

  GtkWidget *box = gtk_vbox_new(TRUE, 1);
  gtk_container_add (GTK_CONTAINER (window), box);

  GtkWidget *hbox = gtk_hbox_new(FALSE, 1);
  gtk_container_add (GTK_CONTAINER (box), hbox);
  status = gtk_label_new( "Status:" );
  gtk_box_pack_start(GTK_BOX(hbox), status, FALSE, FALSE, 1);
  gtk_label_set_justify( (GtkLabel*) status, GTK_JUSTIFY_LEFT );
  status = gtk_label_new( status_str );
  gtk_box_pack_start(GTK_BOX(hbox), status, FALSE, FALSE, 1);
  gtk_label_set_justify( (GtkLabel*) status, GTK_JUSTIFY_LEFT );

  hbox = gtk_hbox_new(FALSE, 1);
  gtk_container_add (GTK_CONTAINER (box), hbox);
  status_ivy = gtk_label_new( "IVY->SERIAL:" );
  gtk_box_pack_start(GTK_BOX(hbox), status_ivy, FALSE, FALSE, 1);
  gtk_label_set_justify( (GtkLabel*) status_ivy, GTK_JUSTIFY_LEFT );
  status_ivy = gtk_label_new( status_ivy_str );
  gtk_box_pack_start(GTK_BOX(hbox), status_ivy, FALSE, FALSE, 1);
  gtk_label_set_justify( (GtkLabel*) status_ivy, GTK_JUSTIFY_LEFT );

  hbox = gtk_hbox_new(FALSE, 1);
  gtk_container_add (GTK_CONTAINER (box), hbox);
  status_serial = gtk_label_new( "SERIAL->IVY:" );
  gtk_box_pack_start(GTK_BOX(hbox), status_serial, FALSE, FALSE, 1);
  gtk_label_set_justify( (GtkLabel*) status_serial, GTK_JUSTIFY_LEFT );
  status_serial = gtk_label_new( status_serial_str );
  gtk_label_set_justify( GTK_LABEL(status_serial), GTK_JUSTIFY_LEFT );
  gtk_box_pack_start(GTK_BOX(hbox), status_serial, FALSE, FALSE, 1);


  gtk_widget_show_all(window);

  gtk_main();

  // Clean up
  fprintf(stderr,"Stopping\n");


  return 0;
}
Esempio n. 28
0
int main(int argc, char** argv) {
  currentPlayingTime = 0.0;
  startVideoAfter = 0.0;

  airframeID = 1;

  currentMode = MODE_REPLAY;
  replayMode = MANUAL_REPLAY;


  ml =  g_main_loop_new(NULL, FALSE);
  g_timeout_add(1000 , __timeout_func , ml);

  IvyInit("Video Synchronizer", "Video Synchronizer READY", NULL, NULL, NULL, NULL);
  IvyBindMsg(on_Message, NULL, "^time(\\S*) (\\S*)");
  IvyBindMsg(on_Message_Video, NULL, "^(\\S*) VIDEO_SYNC(\\S*) (\\S*)");
  IvyBindMsg(on_Airframe_ID, NULL, "^replay(\\S*) PONG(\\S*) (\\S*)");

#ifdef __APPLE__
  IvyStart("224.255.255.255");
#else
  IvyStart("127.255.255.255");
#endif

  /* Ugly because remove every possibility of translation.
   * But needed to prevent the use of the comma as float separator.
   */
  gtk_disable_setlocale();

  gtk_init(&argc, &argv);

  GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "Video synchronizer");
  g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(on_quit), NULL);


  GtkNotebook *tab = (GtkNotebook*)gtk_notebook_new();
  g_signal_connect(GTK_OBJECT(tab), "switch-page", G_CALLBACK(on_change_mode), NULL);


  GtkNotebook *tabReplay = (GtkNotebook*)gtk_notebook_new();
  g_signal_connect(GTK_OBJECT(tabReplay), "switch-page", G_CALLBACK(on_change_replay), NULL);

  //Manual mode
  //create a box to align the widgets
  //false -> unheaven sizes; 0 space between widgets
  GtkWidget *box = gtk_hbox_new(FALSE, 0);

  //add a label to explain the values to enter
  GtkWidget *label = gtk_label_new("How long the video must be started \nafter the log file (may be negative) : ");
  gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  //add a spinbutton (to enter the value of the video synchronisation)
  //startValue, lower, upper, step_increment, page_increment, page_size
  GtkAdjustment *adj = (GtkAdjustment *) gtk_adjustment_new(0.0, -999999999999.99, 999999999999.99, 0.1, 1.0, 0.0);
  spinButton = gtk_spin_button_new(adj, 0.1, 1);
  g_signal_connect(GTK_OBJECT(adj), "value_changed", G_CALLBACK(on_video_sync_changed), NULL);
  gtk_box_pack_start(GTK_BOX(box), spinButton, TRUE, TRUE, 0);
  gtk_widget_show(spinButton);

  //add the unit label at the end of the window
  label = gtk_label_new("s");
  gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  gtk_notebook_append_page(tabReplay, box, gtk_label_new("Manual"));


  //Auto mode
  //create a box to align the widgets
  //false -> unheaven sizes; 0 space between widgets
  GtkWidget *boxAuto = gtk_hbox_new(FALSE, 0);

  //add a label to explain the values to enter
  label = gtk_label_new("At what time is the clap in the video : ");
  gtk_box_pack_start(GTK_BOX(boxAuto), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  //add a spinbutton (to enter the value of the video synchronisation)
  //startValue, lower, upper, step_increment, page_increment, page_size
  GtkAdjustment *adjAuto = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.00, 999999999999.99, 0.1, 1.0, 0.0);
  spinButtonVideo = gtk_spin_button_new(adjAuto, 0.1, 1);
  g_signal_connect(GTK_OBJECT(adjAuto), "value_changed", G_CALLBACK(on_video_time_tag_changed), NULL);
  gtk_box_pack_start(GTK_BOX(boxAuto), spinButtonVideo, TRUE, TRUE, 0);
  gtk_widget_show(spinButtonVideo);

  //add the unit label at the end of the window
  label = gtk_label_new("s");
  gtk_box_pack_start(GTK_BOX(boxAuto), label, FALSE, FALSE, 0);
  gtk_widget_show(label);

  gtk_notebook_append_page(tabReplay, boxAuto, gtk_label_new("Auto"));


  //create the capture page
  GtkWidget *captureBox = gtk_hbox_new(FALSE, 0);

  GtkWidget *button = gtk_button_new_with_label("sync");
  gtk_box_pack_start(GTK_BOX(captureBox), button, FALSE, FALSE, 0);
  g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(on_sync_clicked), NULL);
  gtk_widget_show(button);


  gtk_notebook_append_page(tab, (GtkWidget*)tabReplay, gtk_label_new("Replay"));
  gtk_notebook_append_page(tab, (GtkWidget*)captureBox, gtk_label_new("Capture"));

  gtk_container_add(GTK_CONTAINER(window), (GtkWidget*)tab);
  gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("data/pictures/penguin_icon_vid.png"));

  gtk_widget_show_all(window);
  gtk_main();

  return 0;
}
Esempio n. 29
0
int main(int argc, char **argv) {
  int i;

  // default password
  AppPass = defaultAppPass;

  // try environment variable first, set to default if failed
  IvyBus = getenv("IVYBUS");
  if (IvyBus == NULL) IvyBus = defaultIvyBus;

  // Look for paparazzi folder (PAPARAZZI_HOME or assume local path by default)
  char* PprzFolder = getenv("PAPARAZZI_HOME");
  if (PprzFolder == NULL) PprzFolder = defaultPprzFolder;

  // Parse options
  for (i = 1; i < argc; ++i) {
    if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
      print_help();
      exit(0);
    }
    else if (strcmp(argv[i], "-t") == 0) {
      tcp_port = atoi(argv[++i]);
    }
    else if (strcmp(argv[i], "-u") == 0) {
      udp_port = atoi(argv[++i]);
    }
    else if (strcmp(argv[i], "-b") == 0) {
      IvyBus = argv[++i];
    }
    else if (strcmp(argv[i], "-p") == 0) {
      AppPass = argv[++i];
    }
    else if (strcmp(argv[i], "-v") == 0) {
      verbose = 1;
    }
    else {
      printf("App Server: Unknown option\n");
      print_help();
      exit(0);
    }
  }

  if (verbose) {
    printf("### Paparazzi App Server ###\n");
    printf("Using Paparazzi Folder      : %s\n", PprzFolder);
    printf("Server listen port (TCP)    : %d\n", tcp_port);
    printf("Server broadcast port (UDP) : %d\n", udp_port);
    printf("Control Pass                : %s\n", AppPass);
    printf("Ivy Bus                     : %s\n", IvyBus);
    fflush(stdout);
  }

  //Parse conf.xml
  parse_ac_data(PprzFolder);

  //Create tcp listener
#if !GLIB_CHECK_VERSION (2, 35, 1)
  // init GLib type system (only for older version)
  g_type_init();
#endif
  GSocketService *service = g_socket_service_new();

  GInetAddress *address = g_inet_address_new_any(G_SOCKET_FAMILY_IPV6); //G_SOCKET_FAMILY_IPV4 could be used
  GSocketAddress *socket_address = g_inet_socket_address_new(address, tcp_port);
  //Add listener
  g_socket_listener_add_address(G_SOCKET_LISTENER(service), socket_address, G_SOCKET_TYPE_STREAM,
      G_SOCKET_PROTOCOL_TCP, NULL, NULL, NULL);

  g_object_unref(socket_address);
  g_object_unref(address);
  g_socket_service_start(service);

  //Connect listening signal
  g_signal_connect(service, "incoming", G_CALLBACK(new_connection), NULL);

  //Here comes the ivy bindings
  IvyInit ("PPRZ_App_Server", "Papparazzi App Server Ready", NULL, NULL, NULL, NULL);

  IvyBindMsg(Ivy_All_Msgs, NULL, "(^ground .*)");
  IvyBindMsg(Ivy_All_Msgs, NULL, "(^\\S* AIRSPEED (\\S*) (\\S*) (\\S*) (\\S*))");
  IvyStart(IvyBus);

  GMainLoop *loop = g_main_loop_new(NULL, FALSE);

  if (verbose) {
    printf("Starting App Server\n");
    fflush(stdout);
  }

  g_main_loop_run(loop);

  if (verbose) {
    printf("Stoping App Server\n");
    fflush(stdout);
  }
  return 0;
}