Exemplo n.º 1
0
double
PHEMCEP::GetMaxAccel(double v, double a, double gradient) const {
    UNUSED_PARAMETER(a);
    const double pMaxForAcc = GetPMaxNorm(v) * _ratedPower - PHEMCEP::CalcPower(v, 0, gradient);
    return (pMaxForAcc * 1000) / ((_massVehicle * GetRotationalCoeffecient(v) + _massRot + _vehicleLoading) * v);
}
Exemplo n.º 2
0
static const char *obs_qsv_getname(void *type_data)
{
	UNUSED_PARAMETER(type_data);
	return "QuickSync H.264";
}
Exemplo n.º 3
0
/**
 * The x server was changed
 */
static bool xshm_server_changed(obs_properties_t *props,
		obs_property_t *p, obs_data_t *settings)
{
	UNUSED_PARAMETER(p);

	bool advanced           = obs_data_get_bool(settings, "advanced");
	int_fast32_t old_screen = obs_data_get_int(settings, "screen");
	const char *server      = obs_data_get_string(settings, "server");
	obs_property_t *screens = obs_properties_get(props, "screen");

	/* we want a real NULL here in case there is no string here */
	server = (advanced && *server) ? server : NULL;

	obs_property_list_clear(screens);

	xcb_connection_t *xcb = xcb_connect(server, NULL);
	if (!xcb || xcb_connection_has_error(xcb)) {
		obs_property_set_enabled(screens, false);
		return true;
	}

	struct dstr screen_info;
	dstr_init(&screen_info);
	bool xinerama = xinerama_is_active(xcb);
	int_fast32_t count = (xinerama) ?
			xinerama_screen_count(xcb) :
			xcb_setup_roots_length(xcb_get_setup(xcb));

	for (int_fast32_t i = 0; i < count; ++i) {
		int_fast32_t x, y, w, h;
		x = y = w = h = 0;

		if (xinerama)
			xinerama_screen_geo(xcb, i, &x, &y, &w, &h);
		else
			x11_screen_geo(xcb, i, &w, &h);

		dstr_printf(&screen_info, "Screen %"PRIuFAST32" (%"PRIuFAST32
				"x%"PRIuFAST32" @ %"PRIuFAST32
				",%"PRIuFAST32")", i, w, h, x, y);

		obs_property_list_add_int(screens, screen_info.array, i);
	}

	/* handle missing screen */
	if (old_screen + 1 > count) {
		dstr_printf(&screen_info, "Screen %"PRIuFAST32" (not found)",
				old_screen);
		size_t index = obs_property_list_add_int(screens,
				screen_info.array, old_screen);
		obs_property_list_item_disable(screens, index, true);

	}

	dstr_free(&screen_info);

	xcb_disconnect(xcb);
	obs_property_set_enabled(screens, true);

	return true;
}
Exemplo n.º 4
0
	int getWindowPid(Window win)
	{
		UNUSED_PARAMETER(win);
		return 1234; //TODO
	}
Exemplo n.º 5
0
static obs_properties_t *ffmpeg_source_getproperties(void *data)
{
	struct ffmpeg_source *s = data;
	struct dstr filter = {0};
	struct dstr path = {0};
	UNUSED_PARAMETER(data);

	obs_properties_t *props = obs_properties_create();

	obs_properties_set_flags(props, OBS_PROPERTIES_DEFER_UPDATE);

	obs_property_t *prop;
	// use this when obs allows non-readonly paths
	prop = obs_properties_add_bool(props, "is_local_file",
			obs_module_text("LocalFile"));

	obs_property_set_modified_callback(prop, is_local_file_modified);

	dstr_copy(&filter, obs_module_text("MediaFileFilter.AllMediaFiles"));
	dstr_cat(&filter, media_filter);
	dstr_cat(&filter, obs_module_text("MediaFileFilter.VideoFiles"));
	dstr_cat(&filter, video_filter);
	dstr_cat(&filter, obs_module_text("MediaFileFilter.AudioFiles"));
	dstr_cat(&filter, audio_filter);
	dstr_cat(&filter, obs_module_text("MediaFileFilter.AllFiles"));
	dstr_cat(&filter, " (*.*)");

	if (s && s->input && *s->input) {
		const char *slash;

		dstr_copy(&path, s->input);
		dstr_replace(&path, "\\", "/");
		slash = strrchr(path.array, '/');
		if (slash)
			dstr_resize(&path, slash - path.array + 1);
	}

	obs_properties_add_path(props, "local_file",
			obs_module_text("LocalFile"), OBS_PATH_FILE,
			filter.array, path.array);
	dstr_free(&filter);
	dstr_free(&path);

	obs_properties_add_bool(props, "looping", obs_module_text("Looping"));

	obs_properties_add_bool(props, "restart_on_activate",
			obs_module_text("RestartWhenActivated"));

	obs_properties_add_text(props, "input",
			obs_module_text("Input"), OBS_TEXT_DEFAULT);

	obs_properties_add_text(props, "input_format",
			obs_module_text("InputFormat"), OBS_TEXT_DEFAULT);

	obs_properties_add_bool(props, "hw_decode",
			obs_module_text("HardwareDecode"));

	obs_properties_add_bool(props, "clear_on_media_end",
			obs_module_text("ClearOnMediaEnd"));

	prop = obs_properties_add_bool(props, "advanced",
			obs_module_text("Advanced"));

	obs_property_set_modified_callback(prop, is_advanced_modified);

	obs_properties_add_bool(props, "force_scale",
			obs_module_text("ForceFormat"));

	prop = obs_properties_add_int(props, "audio_buffer_size",
			obs_module_text("AudioBufferSize"), 1, 9999, 1);

	obs_property_set_visible(prop, false);

	prop = obs_properties_add_int(props, "video_buffer_size",
			obs_module_text("VideoBufferSize"), 1, 9999, 1);

	obs_property_set_visible(prop, false);

	prop = obs_properties_add_list(props, "frame_drop",
			obs_module_text("FrameDropping"), OBS_COMBO_TYPE_LIST,
			OBS_COMBO_FORMAT_INT);

	obs_property_list_add_int(prop, obs_module_text("DiscardNone"),
			AVDISCARD_NONE);
	obs_property_list_add_int(prop, obs_module_text("DiscardDefault"),
			AVDISCARD_DEFAULT);
	obs_property_list_add_int(prop, obs_module_text("DiscardNonRef"),
			AVDISCARD_NONREF);
	obs_property_list_add_int(prop, obs_module_text("DiscardBiDir"),
			AVDISCARD_BIDIR);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 67, 100)
	obs_property_list_add_int(prop, obs_module_text("DiscardNonIntra"),
			AVDISCARD_NONINTRA);
#endif
	obs_property_list_add_int(prop, obs_module_text("DiscardNonKey"),
			AVDISCARD_NONKEY);
	obs_property_list_add_int(prop, obs_module_text("DiscardAll"),
			AVDISCARD_ALL);

	obs_property_set_visible(prop, false);

	prop = obs_properties_add_list(props, "color_range",
			obs_module_text("ColorRange"), OBS_COMBO_TYPE_LIST,
			OBS_COMBO_FORMAT_INT);
	obs_property_list_add_int(prop, obs_module_text("ColorRange.Auto"),
			VIDEO_RANGE_DEFAULT);
	obs_property_list_add_int(prop, obs_module_text("ColorRange.Partial"),
			VIDEO_RANGE_PARTIAL);
	obs_property_list_add_int(prop, obs_module_text("ColorRange.Full"),
			VIDEO_RANGE_FULL);

	obs_property_set_visible(prop, false);

	return props;
}
static int
rwl_open_serial(int remote_type, char *port)
{
	struct termios tio;
	int fCom, speed;
	long BAUD, DATABITS, STOPBITS, PARITYON;
	speed_t baud_rate;

	DPRINT_DBG(OUTPUT, "\n rwl_open_serial:%s\n", port);
	if (remote_type == REMOTE_DONGLE)
		fCom = open(port, O_RDWR | O_NOCTTY | O_NDELAY);
	else
		fCom = open(port, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC);
	if (fCom < 0) {
		DPRINT_ERR(ERR, "open COM failed with error %d.\n", errno);
		return fCom;
	} else {
		/* To make the read as a blocking operation */
		fcntl(fCom, F_SETFL, 0);
	}

	bzero(&tio, sizeof(tio));
	/* Get the current option for the port... */
	tcgetattr(fCom, &tio);
	/* Set the baud rate */
	cfsetispeed(&tio, B115200);
	cfsetospeed(&tio, B115200);
	if (remote_type == REMOTE_DONGLE) {
		if (tcsetattr(fCom, TCSANOW, &tio) < 0) {
			perror("tcsetattr:setspeed");
			return FAIL;
		}

		baud_rate = cfgetospeed(&tio);
		if (baud_rate == B115200)
			speed = BAUD_RATE_115200;
		DPRINT_DBG(OUTPUT, "Baud_rate set is:%d\n", speed);

		BAUD = B115200;
		DATABITS = CS8;
		STOPBITS = 1;
		PARITYON = 0;

		tio.c_cflag = BAUD |  DATABITS | STOPBITS | PARITYON | CLOCAL | CREAD;
		tio.c_iflag = IGNPAR;
		tio.c_oflag = 0;
		tio.c_lflag = 0;
		tio.c_cc[VMIN] = VMIN_VAL;
		tio.c_cc[VTIME] = VTIME_VAL;

		tcflush(fCom, TCIOFLUSH);
		if (tcsetattr(fCom, TCSANOW, &tio) < 0) {
			perror("tcsetattr:");
			return FAIL;
		}

		if (tcgetattr(fCom, &tio) < 0) {
			perror("tcgetattr:");
			return FAIL;
		}

		DPRINT_DBG(OUTPUT, "tcgetattr:VMIN is:%d\n", tio.c_cc[VMIN]);
		DPRINT_DBG(OUTPUT, "tcgetattr:VTIME is:%d\n", tio.c_cc[VTIME]);
		tcflush(fCom, TCIOFLUSH);
	}
	else {
		UNUSED_PARAMETER(PARITYON);
		UNUSED_PARAMETER(STOPBITS);
		UNUSED_PARAMETER(DATABITS);
		UNUSED_PARAMETER(BAUD);
		UNUSED_PARAMETER(baud_rate);
		UNUSED_PARAMETER(speed);

		/* Enable the receiver and set local mode  */
		tio.c_cflag |= (CLOCAL | CREAD);

		tio.c_cflag &= ~PARENB;
		tio.c_cflag &= ~CSTOPB;
		tio.c_cflag &= ~CSIZE;
		tio.c_cflag |= CS8;
		tio.c_cc[VTIME] = 255;
		tio.c_cc[VMIN] = 1;

		tio.c_iflag = 0;
		tio.c_iflag  |= IGNBRK;

		tio.c_oflag  &= ~OPOST;
		tio.c_oflag  &= ~OLCUC;
		tio.c_oflag  &= ~ONLCR;
		tio.c_oflag  &= ~OCRNL;
		tio.c_oflag  &= ~ONOCR;
		tio.c_oflag  &= ~ONLRET;
		tio.c_oflag  &= ~OFILL;

		tio.c_lflag &= ~ICANON;
		tio.c_lflag &= ~ISIG;
		tio.c_lflag &= ~XCASE;
		tio.c_lflag &= ~ECHO;
		tio.c_lflag &= ~FLUSHO;
		tio.c_lflag &= ~IEXTEN;
		tio.c_lflag |= NOFLSH;
		/* Set the new tio for the port... */
		tcsetattr(fCom, TCSANOW, &tio);
		tcflush(fCom, TCIOFLUSH);
	}
	return (fCom);
}
static const char *opus_getname(void *unused)
{
	UNUSED_PARAMETER(unused);
	return obs_module_text("FFmpegOpus");
}
Exemplo n.º 8
0
uint32_t obstudio_infowriter_get_height(void *data)
{
   UNUSED_PARAMETER(data);

   return 0;
}
Exemplo n.º 9
0
const char *obstudio_infowriter_get_name(void *type_data)
{
   UNUSED_PARAMETER(type_data);

   return infowriter_idname;
}
Exemplo n.º 10
0
/**
 * Returns the name of the plugin
 */
static const char* xshm_getname(void *unused)
{
	UNUSED_PARAMETER(unused);
	return obs_module_text("X11SharedMemoryScreenInput");
}
Exemplo n.º 11
0
/* This function is used by SQL generated to implement the
** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER 
** statement. The second is a table name. The table name in the CREATE 
** TRIGGER statement is replaced with the third argument and the result 
** returned. This is analagous to renameTableFunc() above, except for CREATE
** TRIGGER, not CREATE INDEX and CREATE TABLE.
*/
static void renameTriggerFunc(
  sqlite3_context *context,
  int NotUsed,
  sqlite3_value **argv
){
  unsigned char const *zSql = sqlite3_value_text(argv[0]);
  unsigned char const *zTableName = sqlite3_value_text(argv[1]);

  int token;
  Token tname;
  int dist = 3;
  unsigned char const *zCsr = zSql;
  int len = 0;
  char *zRet;
  sqlite3 *db = sqlite3_context_db_handle(context);

  UNUSED_PARAMETER(NotUsed);

  /* The principle used to locate the table name in the CREATE TRIGGER 
  ** statement is that the table name is the first token that is immediatedly
  ** preceded by either TK_ON or TK_DOT and immediatedly followed by one
  ** of TK_WHEN, TK_BEGIN or TK_FOR.
  */
  if( zSql ){
    do {

      if( !*zCsr ){
        /* Ran out of input before finding the table name. Return NULL. */
        return;
      }

      /* Store the token that zCsr points to in tname. */
      tname.z = zCsr;
      tname.n = len;

      /* Advance zCsr to the next token. Store that token type in 'token',
      ** and its length in 'len' (to be used next iteration of this loop).
      */
      do {
        zCsr += len;
        len = sqlite3GetToken(zCsr, &token);
      }while( token==TK_SPACE );
      assert( len>0 );

      /* Variable 'dist' stores the number of tokens read since the most
      ** recent TK_DOT or TK_ON. This means that when a WHEN, FOR or BEGIN 
      ** token is read and 'dist' equals 2, the condition stated above
      ** to be met.
      **
      ** Note that ON cannot be a database, table or column name, so
      ** there is no need to worry about syntax like 
      ** "CREATE TRIGGER ... ON ON.ON BEGIN ..." etc.
      */
      dist++;
      if( token==TK_DOT || token==TK_ON ){
        dist = 0;
      }
    } while( dist!=2 || (token!=TK_WHEN && token!=TK_FOR && token!=TK_BEGIN) );

    /* Variable tname now contains the token that is the old table-name
    ** in the CREATE TRIGGER statement.
    */
    zRet = sqlite3MPrintf(db, "%.*s\"%w\"%s", tname.z - zSql, zSql, 
       zTableName, tname.z+tname.n);
    sqlite3_result_text(context, zRet, -1, SQLITE_DYNAMIC);
  }
}
Exemplo n.º 12
0
static void on_disconnect(ble_rcmon_t * p_rcmon, ble_evt_t * p_ble_evt) {
    UNUSED_PARAMETER(p_ble_evt);
    p_rcmon->conn_handle = BLE_CONN_HANDLE_INVALID;
    app_trace_log("on_disconnect\r\n");
}
Exemplo n.º 13
0
/*
** Deinitialize this module.
*/
static void sqlite3MemShutdown(void *NotUsed){
  UNUSED_PARAMETER(NotUsed);
  return;
}
Exemplo n.º 14
0
/*
** Initialize this module.
*/
static int sqlite3MemInit(void *NotUsed){
  UNUSED_PARAMETER(NotUsed);
  return SQLITE_OK;
}
Exemplo n.º 15
0
int
main(int argc, char **argv)
{
	struct ifreq ifr;
	cmd_t *cmd = NULL;
	int err = 0;
	char *ifname = NULL;
	int help = 0;
	int status = CMD_DHD;

	UNUSED_PARAMETER(argc);

	dhdu_av0 = argv[0];

	memset(&ifr, 0, sizeof(ifr));

	for (++argv; *argv;) {

		/* command option */
		if ((status = dhd_option(&argv, &ifname, &help)) == CMD_OPT) {
			if (help)
				break;
			if (ifname) {
				if (strlen(ifname) > IFNAMSIZ) {
					fprintf(stderr, "%s: interface name too long\n", dhdu_av0);
					break;
				}
				strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
			}
			continue;
		}

		/* parse error */
		else if (status == CMD_ERR)
			break;

		/* use default if no interface specified */
		if (!*ifr.ifr_name)
			dhd_find(&ifr);
		/* validate the interface */
		if (!*ifr.ifr_name || dhd_check((void *)&ifr)) {
			fprintf(stderr, "%s: dhd driver adapter not found\n", dhdu_av0);
			exit(1);
		}

		/* search for command */
		for (cmd = dhd_cmds; cmd->name && strcmp(cmd->name, *argv); cmd++);

		/* defaults to using the set_var and get_var commands */
		if (cmd->name == NULL)
			cmd = &dhd_varcmd;

		/* do command */
		if (cmd->name)
			err = (*cmd->func)((void *)&ifr, cmd, argv);
		break;
	}

	/* In case of COMMAND_ERROR, command has already printed an error message */
	if (!cmd)
		dhd_usage(NULL);
	else if (err == USAGE_ERROR)
		dhd_cmd_usage(cmd);
	else if (err == IOCTL_ERROR)
		dhd_printlasterror((void *)&ifr);

	return err;
}
Exemplo n.º 16
0
//------------------------------------------------------------------------------
tOplkError dllknode_cleanupLocalNode(tNmtState oldNmtState_p)
{
    tOplkError      ret = kErrorOk;
    BYTE            aMulticastMac[6];
#if NMT_MAX_NODE_ID > 0
    UINT            index;
#endif

#if defined(CONFIG_INCLUDE_NMT_MN)
    UINT            handle;
#else
    UNUSED_PARAMETER(oldNmtState_p);
#endif

    // remove all filters from Edrv
    ret = edrv_changeRxFilter(NULL, 0, 0, 0);

    // delete timer
#if CONFIG_TIMER_USE_HIGHRES != FALSE
    if ((ret = hrestimer_deleteTimer(&dllkInstance_g.timerHdlCycle)) != kErrorOk)
        return ret;

#if defined(CONFIG_INCLUDE_NMT_RMN)
    if ((ret = hrestimer_deleteTimer(&dllkInstance_g.timerHdlSwitchOver)) != kErrorOk)
        return ret;
#endif
#endif

#if defined(CONFIG_INCLUDE_NMT_MN)
    if ((ret = edrvcyclic_stopCycle(FALSE)) != kErrorOk)
        return ret;

    if ((ret = edrvcyclic_regSyncHandler(NULL)) != kErrorOk)
        return ret;
#endif

#if (CONFIG_DLL_PROCESS_SYNC == DLL_PROCESS_SYNC_ON_TIMER)
    if ((ret = synctimer_stopSync()) != kErrorOk)
        return ret;
#endif

#if defined(CONFIG_INCLUDE_NMT_MN)
    // destroy all data structures
    OPLK_FREE(dllkInstance_g.ppTxBufferList);
    dllkInstance_g.ppTxBufferList = NULL;
#endif

    // delete Tx frames
    if ((ret = dllkframe_deleteTxFrame(DLLK_TXFRAME_IDENTRES)) != kErrorOk)
        return ret;

    if ((ret = dllkframe_deleteTxFrame(DLLK_TXFRAME_STATUSRES)) != kErrorOk)
        return ret;

    if ((ret = dllkframe_deleteTxFrame(DLLK_TXFRAME_PRES)) != kErrorOk)
        return ret;

#if defined(CONFIG_INCLUDE_NMT_RMN)
    if (dllkInstance_g.fRedundancy)
    {
      if ((ret = dllkframe_deleteTxFrame(DLLK_TXFRAME_AMNI)) != kErrorOk)
        return ret;
    }
#endif

    dllkInstance_g.aTxBufferStateNmtReq[0] = kDllkTxBufEmpty;
    dllkInstance_g.aTxBufferStateNmtReq[1] = kDllkTxBufEmpty;
    if ((ret = dllkframe_deleteTxFrame(DLLK_TXFRAME_NMTREQ)) != kErrorOk)
        return ret;

#if CONFIG_DLL_PRES_CHAINING_CN != FALSE
    if ((ret = dllkframe_deleteTxFrame(DLLK_TXFRAME_SYNCRES)) != kErrorOk)
        return ret;
#endif

    dllkInstance_g.aTxBufferStateNonPlk[0] = kDllkTxBufEmpty;
    dllkInstance_g.aTxBufferStateNonPlk[1] = kDllkTxBufEmpty;
    if ((ret = dllkframe_deleteTxFrame(DLLK_TXFRAME_NONPLK)) != kErrorOk)
        return ret;

#if defined(CONFIG_INCLUDE_NMT_MN)
#if !defined(CONFIG_INCLUDE_NMT_RMN)
    if (NMT_IF_MN_OR_RMN(oldNmtState_p))
#else
    if (NMT_IF_MN_OR_RMN(oldNmtState_p) || (dllkInstance_g.fRedundancy))
#endif
    {   // local node was MN
        if ((ret = dllkframe_deleteTxFrame(DLLK_TXFRAME_SOC)) != kErrorOk)
            return ret;

        if ((ret = dllkframe_deleteTxFrame(DLLK_TXFRAME_SOA)) != kErrorOk)
            return ret;

        for (index = 0; index < tabentries (dllkInstance_g.aNodeInfo); index++)
        {
            if (dllkInstance_g.aNodeInfo[index].pPreqTxBuffer != NULL)
            {
                handle = (UINT)(dllkInstance_g.aNodeInfo[index].pPreqTxBuffer - dllkInstance_g.pTxBuffer);
                dllkInstance_g.aNodeInfo[index].pPreqTxBuffer = NULL;
                if (handle != DLLK_TXFRAME_PRES)
                {
                    if ((ret = dllkframe_deleteTxFrame(handle)) != kErrorOk)
                        return ret;
                }
            }
            // disable PReq and PRes for this node
            dllkInstance_g.aNodeInfo[index].preqPayloadLimit = 0;
            dllkInstance_g.aNodeInfo[index].presPayloadLimit = 0;
        }
    }
    else
    {   // local node was CN
        for (index = 0; index < tabentries(dllkInstance_g.aNodeInfo); index++)
        {
            // disable PReq and PRes for this node
            dllkInstance_g.aNodeInfo[index].presPayloadLimit = 0;
            dllkInstance_g.aNodeInfo[index].preqPayloadLimit = 0;
        }
    }
#else
    // must be CN, because MN part is not compiled!
#if NMT_MAX_NODE_ID > 0
    for (index = 0; index < tabentries(dllkInstance_g.aNodeInfo); index++)
    {
        // disable PRes for this node
        dllkInstance_g.aNodeInfo[index].presPayloadLimit = 0;
    }
#endif

#endif

    // de-register multicast MACs in Ethernet driver
    ami_setUint48Be(&aMulticastMac[0], C_DLL_MULTICAST_SOC);
    ret = edrv_clearRxMulticastMacAddr(aMulticastMac);
    ami_setUint48Be(&aMulticastMac[0], C_DLL_MULTICAST_SOA);
    ret = edrv_clearRxMulticastMacAddr(aMulticastMac);
    ami_setUint48Be(&aMulticastMac[0], C_DLL_MULTICAST_PRES);
    ret = edrv_clearRxMulticastMacAddr(aMulticastMac);
    ami_setUint48Be(&aMulticastMac[0], C_DLL_MULTICAST_ASND);
    ret = edrv_clearRxMulticastMacAddr(aMulticastMac);

    return ret;
}
//------------------------------------------------------------------------------
void sdoudp_criticalSection(BOOL fEnable_p)
{
    UNUSED_PARAMETER(fEnable_p);

    //TODO: Do we need critical section handling here?
}
Exemplo n.º 18
0
//------------------------------------------------------------------------------
tOplkError dllknode_setupLocalNode(tNmtState nmtState_p)
{
    tOplkError      ret = kErrorOk;
    UINT            handle;
    UINT            frameSize;
    UINT8           aMulticastMac[6];

#if !defined(CONFIG_INCLUDE_NMT_MN)
    UNUSED_PARAMETER(nmtState_p);
#endif

    // initialize flags for PRes and StatusRes (leave Flag 1 unchanged)
    dllkInstance_g.mnFlag1 = 0;
    dllkInstance_g.flag2 = 0;

#if defined(CONFIG_INCLUDE_NMT_MN)
    // initialize linked node list
    dllkInstance_g.pFirstNodeInfo = NULL;
    dllkInstance_g.pFirstPrcNodeInfo = NULL;
#endif
#if defined(CONFIG_INCLUDE_NMT_RMN)
    if (nmtState_p == kNmtRmsNotActive)
        dllkInstance_g.fRedundancy = TRUE;
    else
        dllkInstance_g.fRedundancy = FALSE;

    // AMNI
    if (dllkInstance_g.fRedundancy)
    {
        frameSize = C_DLL_MINSIZE_AMNI;
        ret = dllkframe_createTxFrame(&handle, &frameSize, kMsgTypeAmni, kDllAsndNotDefined);
        if (ret != kErrorOk)
        {   // error occurred while registering Tx frame
            return ret;
        }
    }
#endif

    /*-----------------------------------------------------------------------*/
    /* register TxFrames in Edrv */
    // IdentResponse
    frameSize = C_DLL_MINSIZE_IDENTRES;
    ret = dllkframe_createTxFrame(&handle, &frameSize, kMsgTypeAsnd, kDllAsndIdentResponse);
    if (ret != kErrorOk)
        return ret;

    // StatusResponse
    frameSize = C_DLL_MINSIZE_STATUSRES;
    ret = dllkframe_createTxFrame(&handle, &frameSize, kMsgTypeAsnd, kDllAsndStatusResponse);
    if (ret != kErrorOk)
        return ret;

#if CONFIG_DLL_PRES_CHAINING_CN != FALSE
    // SyncResponse
    frameSize = C_DLL_MINSIZE_SYNCRES;
    ret = dllkframe_createTxFrame(&handle, &frameSize, kMsgTypeAsnd, kDllAsndSyncResponse);
    if (ret != kErrorOk)
        return ret;
#endif

    // PRes
    if ((dllkInstance_g.dllConfigParam.fAsyncOnly == FALSE) &&
        (dllkInstance_g.dllConfigParam.presActPayloadLimit >= 36))
    {   // it is not configured as async-only CN,
        // so take part in isochronous phase and register PRes frame
        frameSize = dllkInstance_g.dllConfigParam.presActPayloadLimit + PLK_FRAME_OFFSET_PDO_PAYLOAD;
        ret = dllkframe_createTxFrame(&handle, &frameSize, kMsgTypePres, kDllAsndNotDefined);
        if (ret != kErrorOk)
            return ret;

        // reset cycle counter
        dllkInstance_g.cycleCount = 0;
        dllkInstance_g.prescaleCycleCount = 0;
    }
    else
    {   // it is an async-only CN -> fool changeState() to think that PRes was not expected
        dllkInstance_g.cycleCount = 1;
    }

    // NMT request
    frameSize = C_IP_MAX_MTU;
    ret = dllkframe_createTxFrame(&handle, &frameSize, kMsgTypeAsnd, kDllAsndNmtRequest);
    if (ret != kErrorOk)
        return ret;
    // mark Tx buffer as empty
    dllkInstance_g.aTxBufferStateNmtReq[0] = kDllkTxBufEmpty;
    dllkInstance_g.pTxBuffer[handle].txFrameSize = 0;
    dllkInstance_g.pTxBuffer[handle].pfnTxHandler = dllkframe_processTransmittedNmtReq;
    handle++;
    dllkInstance_g.aTxBufferStateNmtReq[1] = kDllkTxBufEmpty;
    dllkInstance_g.pTxBuffer[handle].txFrameSize = 0;
    dllkInstance_g.pTxBuffer[handle].pfnTxHandler = dllkframe_processTransmittedNmtReq;

    // non-POWERLINK frame
    frameSize = C_IP_MAX_MTU;
    ret = dllkframe_createTxFrame(&handle, &frameSize, kMsgTypeNonPowerlink, kDllAsndNotDefined);
    if (ret != kErrorOk)
        return ret;
    // mark Tx buffer as empty
    dllkInstance_g.aTxBufferStateNonPlk[0] = kDllkTxBufEmpty;
    dllkInstance_g.pTxBuffer[handle].txFrameSize = 0;
    dllkInstance_g.pTxBuffer[handle].pfnTxHandler = dllkframe_processTransmittedNonPlk;
    handle++;
    dllkInstance_g.aTxBufferStateNonPlk[1] = kDllkTxBufEmpty;
    dllkInstance_g.pTxBuffer[handle].txFrameSize = 0;
    dllkInstance_g.pTxBuffer[handle].pfnTxHandler = dllkframe_processTransmittedNonPlk;

    /*------------------------------------------------------------------------*/
    /* setup filter structure for Edrv */
    dllkfilter_setupFilters();

    // register multicast MACs in ethernet driver
    ami_setUint48Be(&aMulticastMac[0], C_DLL_MULTICAST_SOC);
    ret = edrv_setRxMulticastMacAddr(aMulticastMac);
    ami_setUint48Be(&aMulticastMac[0], C_DLL_MULTICAST_SOA);
    ret = edrv_setRxMulticastMacAddr(aMulticastMac);
    ami_setUint48Be(&aMulticastMac[0], C_DLL_MULTICAST_PRES);
    ret = edrv_setRxMulticastMacAddr(aMulticastMac);
    ami_setUint48Be(&aMulticastMac[0], C_DLL_MULTICAST_ASND);
    ret = edrv_setRxMulticastMacAddr(aMulticastMac);

#if defined(CONFIG_INCLUDE_NMT_RMN)
    if (dllkInstance_g.fRedundancy)
    {
        ami_setUint48Be(&aMulticastMac[0], C_DLL_MULTICAST_AMNI);
        ret = edrv_setRxMulticastMacAddr(aMulticastMac);
    }
#endif

#if defined(CONFIG_INCLUDE_NMT_MN)
    if (NMT_IF_MN_OR_RMN(nmtState_p))
    {
        if ((ret = setupLocalNodeMn()) != kErrorOk)
            return ret;

#if defined(CONFIG_INCLUDE_NMT_RMN)
        if (nmtState_p == kNmtRmsNotActive)
        {
            if ((ret = setupLocalNodeCn()) != kErrorOk)
                return ret;
        }
#endif
    }
    else
    {
        if ((ret = setupLocalNodeCn()) != kErrorOk)
            return ret;
    }
#else
    if ((ret = setupLocalNodeCn()) != kErrorOk)
        return ret;
#endif

    // clear all asynchronous buffers
    ret = dllkcal_clearAsyncBuffer();
    if (ret != kErrorOk)
        return ret;

    // set filters in Edrv
    ret = edrv_changeRxFilter(dllkInstance_g.aFilter, DLLK_FILTER_COUNT, DLLK_FILTER_COUNT, 0);

    return ret;
}
Exemplo n.º 19
0
// Function for handling the Disconnec event
static void on_disconnect(ble_lc_t * p_lc, ble_evt_t * p_ble_evt)
{
		UNUSED_PARAMETER(p_ble_evt);
		p_lc->conn_handle = BLE_CONN_HANDLE_INVALID;
}
Exemplo n.º 20
0
//  This function currently does nothing for IP.
void 
OTIPEndpoint::ResetAddressForUnreliableTransport(OTAddress *inAddress)
{
	UNUSED_PARAMETER(inAddress);
}
Exemplo n.º 21
0
tEplKernel PUBLIC AppCbEvent(
    tEplApiEventType        EventType_p,   // IN: event type (enum)
    tEplApiEventArg*        pEventArg_p,   // IN: event argument (union)
    void GENERIC*           pUserArg_p)
{
    tEplKernel          EplRet = kEplSuccessful;

    UNUSED_PARAMETER(pUserArg_p);

    // check if NMT_GS_OFF is reached
    switch (EventType_p)
    {
    case kEplApiEventNmtStateChange:
    {
        switch (pEventArg_p->m_NmtStateChange.m_NewNmtState)
        {
        case kEplNmtGsOff:
        {   // NMT state machine was shut down,
            // because of user signal (CTRL-C) or critical EPL stack error
            // -> also shut down EplApiProcess() and main()
            EplRet = kEplShutdown;

            PRINTF("%s(kEplNmtGsOff) originating event = 0x%X\n", __func__, pEventArg_p->m_NmtStateChange.m_NmtEvent);

            // wake up EplLinExit()
            atomic_set(&AtomicShutdown_g, TRUE);
            wake_up_interruptible(&WaitQueueShutdown_g);
            break;
        }

        case kEplNmtGsResetCommunication:
        {
            // continue
        }

        case kEplNmtGsResetConfiguration:
        {
            if (uiCycleLen_g != 0)
            {
                EplRet = EplApiWriteLocalObject(0x1006, 0x00, &uiCycleLen_g, sizeof (uiCycleLen_g));
            }
            // continue
        }

        case kEplNmtMsPreOperational1:
        {
            PRINTF("%s(0x%X -> 0x%X) originating event = 0x%X\n",
                   __func__,
                   pEventArg_p->m_NmtStateChange.m_OldNmtState,
                   pEventArg_p->m_NmtStateChange.m_NewNmtState,
                   pEventArg_p->m_NmtStateChange.m_NmtEvent);

            // continue
        }

        case kEplNmtGsInitialising:
        case kEplNmtGsResetApplication:
        case kEplNmtMsNotActive:
        case kEplNmtCsNotActive:
        case kEplNmtCsPreOperational1:
        {
            break;
        }

        case kEplNmtCsOperational:
        case kEplNmtMsOperational:
        {
            break;
        }

        default:
        {
            break;
        }
        }

        break;
    }

    case kEplApiEventCriticalError:
    case kEplApiEventWarning:
    {   // error or warning occurred within the stack or the application
        // on error the API layer stops the NMT state machine

        PRINTF("%s(Err/Warn): Source=%02X EplError=0x%03X",
               __func__,
               pEventArg_p->m_InternalError.m_EventSource,
               pEventArg_p->m_InternalError.m_EplError);
        // check additional argument
        switch (pEventArg_p->m_InternalError.m_EventSource)
        {
        case kEplEventSourceEventk:
        case kEplEventSourceEventu:
        {   // error occurred within event processing
            // either in kernel or in user part
            PRINTF(" OrgSource=%02X\n", pEventArg_p->m_InternalError.m_Arg.m_EventSource);
            break;
        }

        case kEplEventSourceDllk:
        {   // error occurred within the data link layer (e.g. interrupt processing)
            // the DWORD argument contains the DLL state and the NMT event
            PRINTF(" val=%lX\n", (ULONG) pEventArg_p->m_InternalError.m_Arg.m_dwArg);
            break;
        }

        case kEplEventSourceObdk:
        case kEplEventSourceObdu:
        {   // error occurred within OBD module
            // either in kernel or in user part
            PRINTF(" Object=0x%04X/%u\n", pEventArg_p->m_InternalError.m_Arg.m_ObdError.m_uiIndex, pEventArg_p->m_InternalError.m_Arg.m_ObdError.m_uiSubIndex);
            break;
        }

        default:
        {
            PRINTF("\n");
            break;
        }
        }
        break;
    }

    case kEplApiEventHistoryEntry:
    {   // new history entry

        if ((pEventArg_p->m_ErrHistoryEntry.m_wErrorCode == EPL_E_DLL_CYCLE_EXCEED_TH)
                && (IS_FD_VALID(hAppFdTracingEnabled_g)))
        {
            mm_segment_t    old_fs;
            loff_t          pos;
            ssize_t         iRet;

            old_fs = get_fs();
            set_fs(KERNEL_DS);

            pos = hAppFdTracingEnabled_g->f_pos;
            iRet = vfs_write(hAppFdTracingEnabled_g, "0", 1, &pos);
            hAppFdTracingEnabled_g->f_pos = pos;
        }

        PRINTF("%s(HistoryEntry): Type=0x%04X Code=0x%04X (0x%02X %02X %02X %02X %02X %02X %02X %02X)\n",
               __func__,
               pEventArg_p->m_ErrHistoryEntry.m_wEntryType,
               pEventArg_p->m_ErrHistoryEntry.m_wErrorCode,
               (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[0],
               (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[1],
               (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[2],
               (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[3],
               (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[4],
               (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[5],
               (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[6],
               (WORD) pEventArg_p->m_ErrHistoryEntry.m_abAddInfo[7]);
        break;
    }

    case kEplApiEventNode:
    {
        // check additional argument
        switch (pEventArg_p->m_Node.m_NodeEvent)
        {
        case kEplNmtNodeEventCheckConf:
        {
            PRINTF("%s(Node=0x%X, CheckConf)\n", __func__, pEventArg_p->m_Node.m_uiNodeId);
            break;
        }

        case kEplNmtNodeEventUpdateConf:
        {
            PRINTF("%s(Node=0x%X, UpdateConf)\n", __func__, pEventArg_p->m_Node.m_uiNodeId);
            break;
        }

        case kEplNmtNodeEventNmtState:
        {
            PRINTF("%s(Node=0x%X, NmtState=0x%X)\n", __func__, pEventArg_p->m_Node.m_uiNodeId, pEventArg_p->m_Node.m_NmtState);
            break;
        }

        case kEplNmtNodeEventError:
        {
            PRINTF("%s (Node=0x%X): Error = %s (0x%.4X)\n", __func__,
                   pEventArg_p->m_Node.m_uiNodeId,
                   EplGetEmergErrCodeStr(pEventArg_p->m_Node.m_wErrorCode),
                   pEventArg_p->m_Node.m_wErrorCode);
            break;
        }

        case kEplNmtNodeEventFound:
        {
            PRINTF("%s(Node=0x%X, Found)\n", __func__, pEventArg_p->m_Node.m_uiNodeId);
            break;
        }

        default:
        {
            break;
        }
        }
        break;
    }

#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFM)) != 0)
    case kEplApiEventCfmProgress:
    {
        PRINTF("%s(Node=0x%X, CFM-Progress: Object 0x%X/%u, ", __func__, pEventArg_p->m_CfmProgress.m_uiNodeId, pEventArg_p->m_CfmProgress.m_uiObjectIndex, pEventArg_p->m_CfmProgress.m_uiObjectSubIndex);
        PRINTF("%lu/%lu Bytes", (ULONG) pEventArg_p->m_CfmProgress.m_dwBytesDownloaded, (ULONG) pEventArg_p->m_CfmProgress.m_dwTotalNumberOfBytes);
        if ((pEventArg_p->m_CfmProgress.m_dwSdoAbortCode != 0)
                || (pEventArg_p->m_CfmProgress.m_EplError != kEplSuccessful))
        {
            PRINTF(" -> SDO Abort=0x%lX, Error=0x%X)\n", (unsigned long) pEventArg_p->m_CfmProgress.m_dwSdoAbortCode,
                   pEventArg_p->m_CfmProgress.m_EplError);
        }
        else
        {
            PRINTF(")\n");
        }
        break;
    }

    case kEplApiEventCfmResult:
    {
        switch (pEventArg_p->m_CfmResult.m_NodeCommand)
        {
        case kEplNmtNodeCommandConfOk:
        {
            PRINTF("%s(Node=0x%X, ConfOk)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
            break;
        }

        case kEplNmtNodeCommandConfErr:
        {
            PRINTF("%s(Node=0x%X, ConfErr)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
            break;
        }

        case kEplNmtNodeCommandConfReset:
        {
            PRINTF("%s(Node=0x%X, ConfReset)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
            break;
        }

        case kEplNmtNodeCommandConfRestored:
        {
            PRINTF("%s(Node=0x%X, ConfRestored)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId);
            break;
        }

        default:
        {
            PRINTF("%s(Node=0x%X, CfmResult=0x%X)\n", __func__, pEventArg_p->m_CfmResult.m_uiNodeId, pEventArg_p->m_CfmResult.m_NodeCommand);
            break;
        }
        }
        break;
    }
#endif

    default:
        break;
    }

    return EplRet;
}
Exemplo n.º 22
0
//------------------------------------------------------------------------------
tOplkError ProcessThread::processStateChangeEvent(tOplkApiEventType eventType_p,
                                                  tOplkApiEventArg* pEventArg_p,
                                                  void* pUserArg_p)
{
    tOplkError                  ret = kErrorOk;
    tEventNmtStateChange*       pNmtStateChange = &pEventArg_p->nmtStateChange;
#if !defined(CONFIG_INCLUDE_CFM)
    UINT                        varLen;
#endif
    QString                     str;

    UNUSED_PARAMETER(eventType_p);
    UNUSED_PARAMETER(pUserArg_p);

    sigNmtState(pNmtStateChange->newNmtState);

    sigPrintLog(QString("StateChangeEvent %1: %2 -> %3")
                        .arg(debugstr_getNmtEventStr(pNmtStateChange->nmtEvent))
                        .arg(debugstr_getNmtStateStr(pNmtStateChange->oldNmtState))
                        .arg(debugstr_getNmtStateStr(pNmtStateChange->newNmtState)));

    switch (pNmtStateChange->newNmtState)
    {
        case kNmtGsOff:
            pProcessThread_g->sigOplkStatus(0);

            // NMT state machine was shut down,
            // because of user signal (CTRL-C) or critical POWERLINK stack error
            // -> also shut down oplk_process()
            ret = kErrorShutdown;
            // and unblock DataInDataOutThread
            oplk_freeProcessImage(); //jba do we need it here?

            reachedNmtStateOff();
            break;

        case kNmtGsResetCommunication:
#if !defined(CONFIG_INCLUDE_CFM)
            ret = setDefaultNodeAssignment();
#endif
            pProcessThread_g->sigOplkStatus(1);
            break;

        case kNmtGsResetConfiguration:
#if !defined(CONFIG_INCLUDE_CFM)
        // Configuration Manager is not available,
        // so fetch object 0x1006 NMT_CycleLen_U32 from local OD
        // (in little endian byte order)
        // for configuration of remote CN
            varLen = sizeof(UINT32);
            ret = oplk_readObject(NULL, 0, 0x1006, 0x00, &cycleLen_g,
                                  &varLen, kSdoTypeAsnd, NULL);
            if (ret != kErrorOk)
            {
                sigPrintLog(QString("  oplk_readObject() failed with 0x%1\n\"2\"")
                                    .arg(ret)
                                    .arg(debugstr_getRetValStr(ret)));
                break;
            }
#endif
            sigOplkStatus(1);
            break;

        case kNmtCsNotActive:
        case kNmtMsNotActive:
        case kNmtRmsNotActive:
        case kNmtGsInitialising:
        case kNmtGsResetApplication:
        case kNmtCsPreOperational1:
        case kNmtMsPreOperational1:
        case kNmtCsPreOperational2:
        case kNmtMsPreOperational2:
        case kNmtCsReadyToOperate:
        case kNmtMsReadyToOperate:
        case kNmtCsBasicEthernet:
        case kNmtMsBasicEthernet:
            sigOplkStatus(1);
            break;

        case kNmtCsOperational:
        case kNmtMsOperational:
            sigOplkStatus(2);
            break;


        default:
            sigOplkStatus(-1);
            break;
    }

    return ret;
}
Exemplo n.º 23
0
	static void getAllWindows(Window parent, std::list<Window>& windows)
	{
		UNUSED_PARAMETER(parent);
		UNUSED_PARAMETER(windows);
	}
Exemplo n.º 24
0
//------------------------------------------------------------------------------
tOplkError ProcessThread::processNodeEvent(tOplkApiEventType eventType_p,
                                           tOplkApiEventArg* pEventArg_p,
                                           void* pUserArg_p)
{
    tOplkApiEventNode*   pNode = &pEventArg_p->nodeEvent;
    tOplkError           ret = kErrorOk;

    UNUSED_PARAMETER(eventType_p);
    UNUSED_PARAMETER(pUserArg_p);
    // printf("AppCbEvent(Node): NodeId=%u Event=0x%02X\n",
    //        pEventArg_p->nodeEvent.nodeId, pEventArg_p->nodeEvent.nodeEvent);
    // check additional argument
    switch (pEventArg_p->nodeEvent.nodeEvent)
    {
        case kNmtNodeEventCheckConf:
#if !defined(CONFIG_INCLUDE_CFM)
            // Configuration Manager is not available,
            // so configure CycleLen (object 0x1006) on CN
            tSdoComConHdl SdoComConHdl;

            // update object 0x1006 on CN
            ret = oplk_writeObject(&SdoComConHdl, pEventArg_p->nodeEvent.nodeId,
                                   0x1006, 0x00, &cycleLen_g, 4,
                                   kSdoTypeAsnd, NULL);
            if (ret == kErrorApiTaskDeferred)
            {   // SDO transfer started
                ret = kErrorReject;
            }
            else if (ret == kErrorOk)
            {   // local OD access (should not occur)
                printf("AppCbEvent(Node) write to local OD\n");
            }
            else
            {   // error occured

                ret = oplk_freeSdoChannel(SdoComConHdl);
                SdoComConHdl = 0;

                ret = oplk_writeObject(&SdoComConHdl, pEventArg_p->nodeEvent.nodeId,
                                       0x1006, 0x00, &cycleLen_g, 4,
                                       kSdoTypeAsnd, NULL);
                if (ret == kErrorApiTaskDeferred)
                {   // SDO transfer started
                    ret = kErrorReject;
                }
                else
                {
                    printf("AppCbEvent(Node): oplk_writeObject() returned 0x%03X", ret);
                }
            }
#endif

            sigPrintLog(QString("Node Event: (Node=%2, CheckConf)")
                                .arg(pEventArg_p->nodeEvent.nodeId, 0, 10));
            break;

        case kNmtNodeEventUpdateConf:
            sigPrintLog(QString("Node Event: (Node=%1, UpdateConf)")
                                .arg(pEventArg_p->nodeEvent.nodeId, 0, 10));
            break;

        case kNmtNodeEventFound:
            pProcessThread_g->sigNodeAppeared(pEventArg_p->nodeEvent.nodeId);
            break;

        case kNmtNodeEventNmtState:
            switch (pEventArg_p->nodeEvent.nmtState)
            {
                case kNmtGsOff:
                case kNmtGsInitialising:
                case kNmtGsResetApplication:
                case kNmtGsResetCommunication:
                case kNmtGsResetConfiguration:
                case kNmtCsNotActive:
                    pProcessThread_g->sigNodeDisappeared(pEventArg_p->nodeEvent.nodeId);
                    break;

                case kNmtCsPreOperational1:
                case kNmtCsPreOperational2:
                case kNmtCsReadyToOperate:
                    pProcessThread_g->sigNodeAppeared(pEventArg_p->nodeEvent.nodeId);
                    pProcessThread_g->sigNodeStatus(pEventArg_p->nodeEvent.nodeId, 1);
                    break;

                case kNmtCsOperational:
                    pProcessThread_g->sigNodeAppeared(pEventArg_p->nodeEvent.nodeId);
                    pProcessThread_g->sigNodeStatus(pEventArg_p->nodeEvent.nodeId, 2);
                    break;

                case kNmtCsBasicEthernet:
                case kNmtCsStopped:
                default:
                    pProcessThread_g->sigNodeStatus(pEventArg_p->nodeEvent.nodeId, -1);
                    break;
            }
            break;

        case kNmtNodeEventError:
            pProcessThread_g->sigNodeStatus(pEventArg_p->nodeEvent.nodeId, -1);
            sigPrintLog(QString("AppCbEvent (Node=%1): Error = %2 (0x%3)")
                                .arg(pEventArg_p->nodeEvent.nodeId, 0, 10)
                                .arg(debugstr_getEmergErrCodeStr(pEventArg_p->nodeEvent.errorCode))
                                .arg(pEventArg_p->nodeEvent.errorCode, 4, 16, QLatin1Char('0')));
            break;

        case kNmtNodeEventAmniReceived:
            sigPrintLog(QString("AppCbEvent (Node=%1): received ActiveManagingNodeIndication")
                                .arg(pEventArg_p->nodeEvent.nodeId, 0, 10));
            break;

        default:
            break;
    }
    return kErrorOk;
}
Exemplo n.º 25
0
static const char *ffmpeg_source_getname(void *unused)
{
	UNUSED_PARAMETER(unused);
	return obs_module_text("FFMpegSource");
}
Exemplo n.º 26
0
static const char *rtmp_common_getname(void *unused)
{
	UNUSED_PARAMETER(unused);
	return obs_module_text("StreamingServices");
}
Exemplo n.º 27
0
OSStatus mico_rtos_deinit_mutex( mico_mutex_t* mutex )
{
    UNUSED_PARAMETER( mutex );
    return kNoErr;
}
Exemplo n.º 28
0
/*
** An SQL user-function registered to do the work of an ATTACH statement. The
** three arguments to the function come directly from an attach statement:
**
**     ATTACH DATABASE x AS y KEY z
**
**     SELECT sqlite_attach(x, y, z)
**
** If the optional "KEY z" syntax is omitted, an SQL NULL is passed as the
** third argument.
*/
static void attachFunc(
  sqlite3_context *context,
  int NotUsed,
  sqlite3_value **argv
){
  int i;
  int rc = 0;
  sqlite3 *db = sqlite3_context_db_handle(context);
  const char *zName;
  const char *zFile;
  Db *aNew;
  char *zErrDyn = 0;

  UNUSED_PARAMETER(NotUsed);

  zFile = (const char *)sqlite3_value_text(argv[0]);
  zName = (const char *)sqlite3_value_text(argv[1]);
  if( zFile==0 ) zFile = "";
  if( zName==0 ) zName = "";

  /* Check for the following errors:
  **
  **     * Too many attached databases,
  **     * Transaction currently open
  **     * Specified database name already being used.
  */
  if( db->nDb>=db->aLimit[SQLITE_LIMIT_ATTACHED]+2 ){
    zErrDyn = sqlite3MPrintf(db, "too many attached databases - max %d", 
      db->aLimit[SQLITE_LIMIT_ATTACHED]
    );
    goto attach_error;
  }
  if( !db->autoCommit ){
    zErrDyn = sqlite3MPrintf(db, "cannot ATTACH database within transaction");
    goto attach_error;
  }
  for(i=0; i<db->nDb; i++){
    char *z = db->aDb[i].zName;
    assert( z && zName );
    if( sqlite3StrICmp(z, zName)==0 ){
      zErrDyn = sqlite3MPrintf(db, "database %s is already in use", zName);
      goto attach_error;
    }
  }

  /* Allocate the new entry in the db->aDb[] array and initialise the schema
  ** hash tables.
  */
  if( db->aDb==db->aDbStatic ){
    aNew = sqlite3DbMallocRaw(db, sizeof(db->aDb[0])*3 );
    if( aNew==0 ) return;
    memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);
  }else{
    aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
    if( aNew==0 ) return;
  }
  db->aDb = aNew;
  aNew = &db->aDb[db->nDb];
  memset(aNew, 0, sizeof(*aNew));

  /* Open the database file. If the btree is successfully opened, use
  ** it to obtain the database schema. At this point the schema may
  ** or may not be initialised.
  */
  rc = sqlite3BtreeFactory(db, zFile, 0, SQLITE_DEFAULT_CACHE_SIZE,
                           db->openFlags | SQLITE_OPEN_MAIN_DB,
                           &aNew->pBt);
  db->nDb++;
  if( rc==SQLITE_CONSTRAINT ){
    rc = SQLITE_ERROR;
    zErrDyn = sqlite3MPrintf(db, "database is already attached");
  }else if( rc==SQLITE_OK ){
    Pager *pPager;
    aNew->pSchema = sqlite3SchemaGet(db, aNew->pBt);
    if( !aNew->pSchema ){
      rc = SQLITE_NOMEM;
    }else if( aNew->pSchema->file_format && aNew->pSchema->enc!=ENC(db) ){
      zErrDyn = sqlite3MPrintf(db, 
        "attached databases must use the same text encoding as main database");
      rc = SQLITE_ERROR;
    }
    pPager = sqlite3BtreePager(aNew->pBt);
    sqlite3PagerLockingMode(pPager, db->dfltLockMode);
    sqlite3PagerJournalMode(pPager, db->dfltJournalMode);
  }
  aNew->zName = sqlite3DbStrDup(db, zName);
  aNew->safety_level = 3;

#if SQLITE_HAS_CODEC
  if( rc==SQLITE_OK ){
    extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);
    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
    int nKey;
    char *zKey;
    int t = sqlite3_value_type(argv[2]);
    switch( t ){
      case SQLITE_INTEGER:
      case SQLITE_FLOAT:
        zErrDyn = sqlite3DbStrDup(db, "Invalid key value");
        rc = SQLITE_ERROR;
        break;
        
      case SQLITE_TEXT:
      case SQLITE_BLOB:
        nKey = sqlite3_value_bytes(argv[2]);
        zKey = (char *)sqlite3_value_blob(argv[2]);
        rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
        break;

      case SQLITE_NULL:
        /* No key specified.  Use the key from the main database */
        sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
        rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
        break;
    }
  }
#endif

  /* If the file was opened successfully, read the schema for the new database.
  ** If this fails, or if opening the file failed, then close the file and 
  ** remove the entry from the db->aDb[] array. i.e. put everything back the way
  ** we found it.
  */
  if( rc==SQLITE_OK ){
    (void)sqlite3SafetyOn(db);
    sqlite3BtreeEnterAll(db);
    rc = sqlite3Init(db, &zErrDyn);
    sqlite3BtreeLeaveAll(db);
    (void)sqlite3SafetyOff(db);
  }
  if( rc ){
    int iDb = db->nDb - 1;
    assert( iDb>=2 );
    if( db->aDb[iDb].pBt ){
      sqlite3BtreeClose(db->aDb[iDb].pBt);
      db->aDb[iDb].pBt = 0;
      db->aDb[iDb].pSchema = 0;
    }
    sqlite3ResetInternalSchema(db, 0);
    db->nDb = iDb;
    if( rc==SQLITE_NOMEM || rc==SQLITE_IOERR_NOMEM ){
      db->mallocFailed = 1;
      sqlite3DbFree(db, zErrDyn);
      zErrDyn = sqlite3MPrintf(db, "out of memory");
    }else if( zErrDyn==0 ){
      zErrDyn = sqlite3MPrintf(db, "unable to open database: %s", zFile);
    }
    goto attach_error;
  }
  
  return;

attach_error:
  /* Return an error if we get here */
  if( zErrDyn ){
    sqlite3_result_error(context, zErrDyn, -1);
    sqlite3DbFree(db, zErrDyn);
  }
  if( rc ) sqlite3_result_error_code(context, rc);
}
Exemplo n.º 29
0
/**@brief Battery measurement timer timeout handler.
 *
 * @details This function will be called each time the battery level measurement timer expires.
 *
 * @param[in]   p_context   Pointer used for passing some arbitrary information (context) from the
 *                          app_start_timer() call to the timeout handler.
 */
static void battery_level_meas_timeout_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
    battery_level_update();
}
Exemplo n.º 30
0
static BOOL DENC_NullPointersTest(STTST_Parse_t *pars_p, char *result_sym_p)
{
    U32 Error = 0;
    ST_ErrorCode_t ErrorCode;
    STDENC_InitParams_t InitParams;
    STDENC_OpenParams_t OpenParams;
    STDENC_TermParams_t TermParams;

    UNUSED_PARAMETER(pars_p);
    UNUSED_PARAMETER(result_sym_p);

    /* Init params NULL */
    ErrorCode = STDENC_Init(STDENC_DEVICE_NAME, NULL);
    if(ErrorCode != ST_ERROR_BAD_PARAMETER){
        Error += 1;
        STTST_Print(("\tInit params NULL : Failed !!!!\n"));
    }

    /* Init device type unknown */
    InitParams.DeviceType = -1;
    ErrorCode = STDENC_Init(STDENC_DEVICE_NAME, &InitParams);
    if(ErrorCode != ST_ERROR_BAD_PARAMETER){
        Error += 1;
        STTST_Print(("\tInit device type unknown : Failed !!!!\n"));
    }

    /* Init access type unknown */
    InitParams.DeviceType = DENC_DEVICE_TYPE;
    InitParams.AccessType = -1;
    ErrorCode = STDENC_Init(STDENC_DEVICE_NAME, &InitParams);
    if(ErrorCode != ST_ERROR_BAD_PARAMETER){
        Error += 1;
        STTST_Print(("\tInit access type unknown : Failed !!!!\n"));
    }

    /* Init access Address null for RBUS only */
    InitParams.AccessType = DENC_DEVICE_ACCESS;
    if(InitParams.AccessType == STDENC_ACCESS_TYPE_EMI)
    {
        InitParams.STDENC_Access.EMI.BaseAddress_p = (void*)NULL;
        ErrorCode = STDENC_Init(STDENC_DEVICE_NAME, &InitParams);
        if(ErrorCode != ST_ERROR_BAD_PARAMETER){
            Error += 1;
            STTST_Print(("\tInit base address null: Failed !!!!\n"));
        }
        InitParams.STDENC_Access.EMI.BaseAddress_p       = (void*)DNC_BASE_ADDRESS;
        InitParams.STDENC_Access.EMI.DeviceBaseAddress_p = (void*)DNC_DEVICE_BASE_ADDRESS;
        InitParams.STDENC_Access.EMI.Width               = -1;
        ErrorCode = STDENC_Init(STDENC_DEVICE_NAME, &InitParams);
        if(ErrorCode != ST_ERROR_BAD_PARAMETER){
            Error += 1;
            STTST_Print(("\tInit width unknown : Failed !!!!\n"));
        }
        InitParams.STDENC_Access.EMI.Width = DENC_DEVICE_ACCESS_WIDTH;
    }
    else
    {
#if defined (USE_I2C) && defined (USE_STDENC_I2C)
        sprintf(InitParams.STDENC_Access.I2C.DeviceName, STI2C_BACK_DEVICE_NAME);
        InitParams.STDENC_Access.I2C.OpenParams.I2cAddress = I2C_STV119_ADDRESS;
        InitParams.STDENC_Access.I2C.OpenParams.AddressType = STI2C_ADDRESS_7_BITS;
        InitParams.STDENC_Access.I2C.OpenParams.BusAccessTimeOut = STI2C_TIMEOUT_INFINITY;
#endif /* USE_I2C USE_STDENC_I2C */
    }

    /* Init Normaly */
    InitParams.MaxOpen = 1;
    ErrorCode = STDENC_Init(STDENC_DEVICE_NAME, &InitParams);
    if(ErrorCode != ST_NO_ERROR){
        Error += 1;
        STTST_Print(("\tInit Normaly : Failed !!!!\n"));
    }

    /* Open open params null */
    ErrorCode = STDENC_Open(STDENC_DEVICE_NAME, NULL, &DENCHandle);
    if(ErrorCode != ST_ERROR_BAD_PARAMETER){
        Error += 1;
        STTST_Print(("\tOpen open params null : Failed !!!!\n"));
    }

    /* Open handle address null */
    ErrorCode = STDENC_Open(STDENC_DEVICE_NAME, &OpenParams, NULL);
    if(ErrorCode != ST_ERROR_BAD_PARAMETER){
        Error += 1;
        STTST_Print(("\tOpen handle address null : Failed !!!!\n"));
    }

    /* Open normaly */
    ErrorCode = STDENC_Open(STDENC_DEVICE_NAME, &OpenParams, &DENCHandle);
    if(ErrorCode != ST_NO_ERROR){
        Error += 1;
        STTST_Print(("\tOpen normaly : Failed !!!!\n"));
    }

    /* Set mode params null */
    ErrorCode = STDENC_SetEncodingMode(DENCHandle, NULL);
    if(ErrorCode != ST_ERROR_BAD_PARAMETER){
        Error += 1;
        STTST_Print(("\tSet mode params null : Failed !!!!\n"));
    }

    /* Get mode params null */
    ErrorCode = STDENC_GetEncodingMode(DENCHandle, NULL);
    if(ErrorCode != ST_ERROR_BAD_PARAMETER){
        Error += 1;
        STTST_Print(("\tGet mode params null : Failed !!!!\n"));
    }

    /* Get Capability params null */
    ErrorCode = STDENC_GetCapability(STDENC_DEVICE_NAME, NULL);
    if(ErrorCode != ST_ERROR_BAD_PARAMETER){
        Error += 1;
        STTST_Print(("\tGet Capability params null : Failed !!!!\n"));
    }

    /* Close normaly */
    ErrorCode = STDENC_Close(DENCHandle);
    if(ErrorCode != ST_NO_ERROR){
        Error += 1;
        STTST_Print(("\tClose normaly : Failed !!!!\n"));
    }

    /* Term params null */
    ErrorCode = STDENC_Term(STDENC_DEVICE_NAME, NULL);
    if(ErrorCode != ST_ERROR_BAD_PARAMETER){
        Error += 1;
        STTST_Print(("\tTerm params null : Failed !!!!\n"));
    }

    /* Term normally */
    TermParams.ForceTerminate = FALSE;
    ErrorCode = STDENC_Term(STDENC_DEVICE_NAME, &TermParams);
    if(ErrorCode != ST_NO_ERROR){
        Error += 1;
        STTST_Print(("\tTerm normally : Failed !!!!\n"));
    }

    /* Report */
    if(Error == 0)
        STTST_Print(("DENC_NullPointersTest() : Ok\n"));
    else
        STTST_Print(("DENC_NullPointersTest() : Failed !!!!\n"));


    STTST_AssignInteger("ERRORCODE", Error, FALSE);

    return(API_EnableError ? Error : FALSE);
} /* end of DENC_NullPointersTest() */