Example #1
0
static GObject *
odccm_device_manager_constructor (GType type, guint n_props,
                                  GObjectConstructParam *props)
{
  GObject *obj;
  OdccmDeviceManagerPrivate *priv;

  obj = G_OBJECT_CLASS (odccm_device_manager_parent_class)->
    constructor (type, n_props, props);

  priv = ODCCM_DEVICE_MANAGER_GET_PRIVATE (obj);

  priv->server = gnet_server_new (NULL, 990, client_connected_cb, obj);
#ifdef ENABLE_LEGACY_SUPPORT
  priv->legacy_server = gnet_server_new (NULL, 5679, client_connected_cb, obj);
#endif

  dbus_g_connection_register_g_object (_odccm_get_dbus_conn (),
                                       DEVICE_MANAGER_OBJECT_PATH, obj);

  init_hal (ODCCM_DEVICE_MANAGER (obj));
  init_udev (ODCCM_DEVICE_MANAGER (obj));

  return obj;
}
Example #2
0
void init_driver() {
	init_hal();
	init_timer();
	init_tty();
	init_ide();
	init_ramdisk();

	hal_list();
}
Example #3
0
File: uhvm.c Project: mjessome/uhvm
static int
init_uhvm(void)
{
    DBusError error;

    dbus_error_init(&error);
    if (init_dbus(&error) < 0) {
        if (dbus_error_is_set(&error)) {
            syslog(LOG_ERR, "%s:%d: %s:%s", __FILE__, __LINE__,
                   error.name, error.message);
            dbus_error_free(&error);
            return -1;
        }
    }

    return init_hal();
}
Example #4
0
File: eject.c Project: pzanoni/tray
int main(int argc, char **argv)
{
	bindtextdomain("tray_eject", LOCALE_DIR);
        textdomain("tray_eject");

	gtk_init(&argc, &argv);

	count = 0;
	dev = g_hash_table_new_full(g_str_hash, g_str_equal, key_destroy,
							value_destroy);

	icon = (GtkStatusIcon *)
                        gtk_status_icon_new_from_file(ICON_PATH "dev1.png");
	update_status();

	menu = gtk_menu_new();

	item = gtk_menu_item_new_with_label(_("Safely remove all"));
	gtk_widget_show(item);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
	g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(eject), NULL);

	sep = gtk_separator_menu_item_new();
	gtk_widget_show(sep);
	gtk_menu_shell_append(GTK_MENU_SHELL(menu), sep);

	g_signal_connect(G_OBJECT(icon), "popup-menu",
						G_CALLBACK(popup), NULL);

	if (init_hal() < 0)
		return 1;

	dialog = gtk_dialog_new_with_buttons("Error", NULL,
			GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_OK, NULL);
	gtk_window_set_icon_from_file(GTK_WINDOW(dialog), ICON_PATH "error.png", NULL);

	msg = gtk_label_new(_("Unable to unmount this device. Some\napplication is likely to be using it.\nPlease close the offending application\nand try again."));
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), msg, TRUE, TRUE, 10);
        gtk_widget_show(msg);

	gtk_main();

	return 0;
}
Example #5
0
/* The function called at load/unload. */
static int
event_handler(module_t module, int event, void *arg) 
{
	struct visibility_plugin *plugin;
	int e = 0; /* Error, 0 for normal return status */

	switch (event) {
	case MOD_LOAD:
		sdev = make_dev(&wtap_cdevsw,0,UID_ROOT,
		    GID_WHEEL,0600,(const char *)"wtapctl");
		hal = (struct wtap_hal *)malloc(sizeof(struct wtap_hal),
		    M_WTAP, M_NOWAIT | M_ZERO);
		bzero(hal, sizeof(struct wtap_hal));

		init_hal(hal);

		/* Setting up a simple plugin */
		plugin = (struct visibility_plugin *)malloc
		    (sizeof(struct visibility_plugin), M_WTAP_PLUGIN,
		    M_NOWAIT | M_ZERO);
		plugin->base.wp_hal  = hal;
		plugin->base.init = visibility_init;
		plugin->base.deinit = visibility_deinit;
		plugin->base.work = visibility_work;
		register_plugin(hal, (struct wtap_plugin *)plugin);

                printf("Loaded wtap wireless simulator\n");
                break;
	case MOD_UNLOAD:
		destroy_dev(sdev);
		deregister_plugin(hal);
		deinit_hal(hal);
		free(hal, M_WTAP);
		printf("Unloading wtap wireless simulator\n");
		break;
	default:
		e = EOPNOTSUPP; /* Error, Operation Not Supported */
		break;
	}

	return(e);
}
Example #6
0
static void
plugin_init(OhmPlugin * plugin)
{
    DBusConnection *c = ohm_plugin_dbus_get_connection();

    (void) plugin;

    if (!OHM_DEBUG_INIT(hal))
        g_warning("Failed to initialize HAL plugin debugging.");
    OHM_DEBUG(DBG_HAL, "> HAL plugin init");
    /* should we ref the connection? */
    hal_plugin_p = init_hal(c, DBG_HAL, DBG_FACTS);

    if ((sys_conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL)) == NULL) {
        OHM_ERROR("Failed to get connection to system D-BUS.");
        return;
    }

    watch_dbus_addr(HALD_DBUS_NAME, TRUE, hald_change, NULL);

    OHM_DEBUG(DBG_HAL, "< HAL plugin init");
    return;
}
Example #7
0
int main(void)
{
   // Relocate interrupt vectors
   //
   extern void *g_pfnVectors;
   SCB->VTOR = (uint32_t)&g_pfnVectors;

   float period = 0.0;
   int last_start = 0;
   int start = 0;
   int end = 0;

   setup();
   init_hal();

   set_comp_type("foo"); // default pin for mem errors
   HAL_PIN(bar) = 0.0;

   //feedback comps
   #include "comps/adc.comp"
   #include "comps/res.comp"
   #include "comps/enc_fb.comp"
   #include "comps/encm.comp"
   #include "comps/encs.comp"
   #include "comps/yaskawa.comp"
   //TODO: hyperface

   //command comps
   #include "comps/sserial.comp"
   #include "comps/sim.comp"
   #include "comps/enc_cmd.comp"
   #include "comps/en.comp"

   //PID
   #include "comps/stp.comp"
   #include "comps/rev.comp"
   #include "comps/rev.comp"
   #include "comps/vel.comp"
   #include "comps/vel.comp"
   #include "comps/cauto.comp"
   #include "comps/pid.comp"
   #include "comps/pmsm_t2c.comp"
   #include "comps/curpid.comp"
   #include "comps/pmsm.comp"
   #include "comps/pmsm_limits.comp"
   #include "comps/idq.comp"
   #include "comps/dq.comp"
   #include "comps/hv.comp"

   //other comps
   #include "comps/fault.comp"
   #include "comps/term.comp"
   #include "comps/io.comp"


   set_comp_type("net");
   HAL_PIN(enable) = 0.0;
   HAL_PIN(cmd) = 0.0;
   HAL_PIN(fb) = 0.0;
   HAL_PIN(fb_error) = 0.0;
   HAL_PIN(cmd_d) = 0.0;
   HAL_PIN(fb_d) = 0.0;
   HAL_PIN(core_temp0) = 0.0;
   HAL_PIN(core_temp1) = 0.0;
   HAL_PIN(motor_temp) = 0.0;
   HAL_PIN(rt_calc_time) = 0.0;
   HAL_PIN(frt_calc_time) = 0.0;
   HAL_PIN(nrt_calc_time) = 0.0;
   HAL_PIN(rt_period) = 0.0;
   HAL_PIN(frt_period) = 0.0;
   HAL_PIN(nrt_period) = 0.0;

   set_comp_type("conf");
   HAL_PIN(r) = 1.0;
   HAL_PIN(l) = 0.01;
   HAL_PIN(j) = KGCM2(0.26);
   HAL_PIN(psi) = 0.05;
   HAL_PIN(polecount) = 4.0;
   HAL_PIN(mot_type) = 0.0;//ac sync,async/dc,2phase
   HAL_PIN(out_rev) = 0.0;
   HAL_PIN(high_motor_temp) = 80.0;
   HAL_PIN(max_motor_temp) = 100.0;
   HAL_PIN(phase_time) = 0.5;
   HAL_PIN(phase_cur) = 1.0;

   HAL_PIN(max_vel) = RPM(1000.0);
   HAL_PIN(max_acc) = RPM(1000.0)/0.01;
   HAL_PIN(max_force) = 1.0;
   HAL_PIN(max_dc_cur) = 1.0;
   HAL_PIN(max_ac_cur) = 2.0;

   HAL_PIN(fb_type) = RES;
   HAL_PIN(fb_polecount) = 1.0;
   HAL_PIN(fb_offset) = 0.0;
   HAL_PIN(fb_rev) = 0.0;
   HAL_PIN(fb_res) = 1000.0;
   HAL_PIN(autophase) = 1.0;//constant,cauto,hfi

   HAL_PIN(cmd_type) = ENC;
   HAL_PIN(cmd_unit) = 0.0;//pos,vel,torque
   HAL_PIN(cmd_rev) = 0.0;
   HAL_PIN(cmd_res) = 2000.0;
   HAL_PIN(en_condition) = 0.0;
   HAL_PIN(error_out) = 0.0;
   HAL_PIN(pos_static) = 0.0;//track pos in disabled and error condition

   HAL_PIN(sin_offset) = 0.0;
   HAL_PIN(cos_offset) = 0.0;
   HAL_PIN(sin_gain) = 1.0;
   HAL_PIN(cos_gain) = 1.0;
   HAL_PIN(max_dc_volt) = 370.0;
   HAL_PIN(max_hv_temp) = 90.0;
   HAL_PIN(max_core_temp) = 55.0;
   HAL_PIN(max_pos_error) = M_PI / 2.0;
   HAL_PIN(high_dc_volt) = 350.0;
   HAL_PIN(low_dc_volt) = 12.0;
   HAL_PIN(high_hv_temp) = 70.0;
   HAL_PIN(fan_hv_temp) = 60.0;
   HAL_PIN(fan_core_temp) = 450.0;
   HAL_PIN(fan_motor_temp) = 60.0;

   HAL_PIN(p) = 0.99;
   HAL_PIN(pos_p) = 100.0;
   HAL_PIN(vel_p) = 1.0;
   HAL_PIN(acc_p) = 0.3;
   HAL_PIN(acc_pi) = 50.0;
   HAL_PIN(cur_p) = 0.0;
   HAL_PIN(cur_i) = 0.0;
   HAL_PIN(cur_ff) = 1.0;
   HAL_PIN(cur_ind) = 0.0;
   HAL_PIN(max_sat) = 0.2;

   rt_time_hal_pin = map_hal_pin("net0.rt_calc_time");
   frt_time_hal_pin = map_hal_pin("net0.frt_calc_time");
   rt_period_time_hal_pin = map_hal_pin("net0.rt_period");
   frt_period_time_hal_pin = map_hal_pin("net0.frt_period");

   for(int i = 0; i < hal.nrt_init_func_count; i++){ // run nrt init
      hal.nrt_init[i]();
   }

   link_pid();


   if(hal.pin_errors + hal.comp_errors == 0){
      start_hal();
   }
   else{
      hal.hal_state = MEM_ERROR;
   }

   while(1)//run non realtime stuff
   {
      start = SysTick->VAL;

      if(last_start < start){
        last_start += SysTick->LOAD;
      }

      period = ((float)(last_start - start)) / RCC_Clocks.HCLK_Frequency;
      last_start = start;

      for(hal.active_nrt_func = 0; hal.active_nrt_func < hal.nrt_func_count; hal.active_nrt_func++){//run all non realtime hal functions
         hal.nrt[hal.active_nrt_func](period);
      }
      hal.active_nrt_func = -1;

      end = SysTick->VAL;
      if(start < end){
        start += SysTick->LOAD;
      }
      PIN(nrt_calc_time) = ((float)(start - end)) / RCC_Clocks.HCLK_Frequency;
      PIN(nrt_period) = period;
      Wait(2);
   }
}