コード例 #1
0
ファイル: handler.c プロジェクト: okeuday/sillymud
/* Remove an affected_type structure from a char (called when duration
   reaches zero). Pointer *af must never be NIL! Frees mem and calls 
   affect_location_apply                                                */
void affect_remove( struct char_data *ch, struct affected_type *af )
{
  struct affected_type *hjp;
  
  if (!ch->affected) {
    logE("affect removed from char without affect");
    logE(GET_NAME(ch));
    return;
  }
  
  affect_modify(ch, af->location, (int) af->modifier,
		af->bitvector, FALSE);
  
  
  /* remove structure *af from linked list */
  
  if (ch->affected == af) {
    /* remove head of list */
    ch->affected = af->next;
  } else {
    
    for(hjp = ch->affected; (hjp->next) && (hjp->next != af); hjp = hjp->next);
    
    if (hjp->next != af) {
      logE("Could not locate affected_type in ch->affected. (handler.c, affect_remove)");
      return;
    }
    hjp->next = af->next; /* skip the af element */
  }
  
  free ( af );
  
  affect_total(ch);
}
コード例 #2
0
ファイル: handler.c プロジェクト: okeuday/sillymud
/* remove an object from an object */
void obj_from_obj(struct obj_data *obj)
{
  struct obj_data *tmp, *obj_from;
  char buf[100];

  if (obj->carried_by) {
    sprintf(buf, "%s carried by %s in obj_from_obj\n", obj->name,
	    obj->carried_by->player.name);
    logE(buf);
  }
  if (obj->equipped_by) {
    sprintf(buf, "%s equipped by %s in obj_from_obj\n", obj->name,
	    obj->equipped_by->player.name);
    logE(buf);
  }
  if (obj->in_room != NOWHERE) {
    sprintf(buf, "%s in room %d in obj_from_obj\n", obj->name,
	    obj->in_room);
    logE(buf);
  }

  assert(!obj->carried_by && !obj->equipped_by && obj->in_room == NOWHERE);
  
  if (obj->in_obj) {
    obj_from = obj->in_obj;
    if (obj == obj_from->contains)   /* head of list */
      obj_from->contains = obj->next_content;
    else {
      for (tmp = obj_from->contains; 
	   tmp && (tmp->next_content != obj);
	   tmp = tmp->next_content); /* locate previous */
      
      if (!tmp) {
	perror("Fatal error in object structures.");
	assert(0);
      }
      
      tmp->next_content = obj->next_content;
    }
        
    /* Subtract weight from containers container */
    for(tmp = obj->in_obj; tmp->in_obj; tmp = tmp->in_obj)
      GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);
    
    GET_OBJ_WEIGHT(tmp) -= GET_OBJ_WEIGHT(obj);
    
    /* Subtract weight from char that carries the object */
    if (tmp->carried_by)
      IS_CARRYING_W(tmp->carried_by) -= GET_OBJ_WEIGHT(obj);
    
    obj->in_obj = 0;
    obj->next_content = 0;
  } else {
    perror("Trying to object from object when in no object.");
    assert(0);
  }
  if(obj_from->in_room != NOWHERE)
      if(IS_SET(real_roomp(obj_from->in_room)->room_flags, SAVE_ROOM))
         save_room(obj_from->in_room);  
}
コード例 #3
0
ファイル: data_analyse.c プロジェクト: xidian-hgj/FunPower
/**
 * find the count most near the time, and before it
 * count is start in zero
 */
long findPowerDataCountByTime(long long time, PowerDataSet *set)
{
	long begin, end, mid, ret;
	PowerData * data_begin, *data_end, *data_mid;

	begin = 0;
	end = getPowerSetNum(set) - 1;

	data_begin = getPowerData(set, begin);
	data_end = getPowerData(set, end);

	if (time < data_begin->time || time > data_end->time) {
		logE("time is out range");
		return -1;
	}

	while (begin < end) {
		mid = (begin + end) / 2;
		data_mid = getPowerData(set, mid);
		if (data_mid->time < time) {
			begin = mid + 1;
		} else if (data_mid->time > time) {
			end = mid - 1;
		} else {
			ret = mid;
			break;
		}
	}

	if (begin == end) {
		ret = begin < mid ? begin : mid;
	}
	return ret;
}
コード例 #4
0
MINT32 default_flashlight_ioctl(unsigned int cmd, unsigned long arg) {
    int i4RetValue = 0;
    int iFlashType = (int)FLASHLIGHT_NONE;
    kdStrobeDrvArg kdArg;
	unsigned long copyRet;
    copyRet = copy_from_user(&kdArg , (void *)arg , sizeof(kdStrobeDrvArg));


    switch(cmd)
    {
        case FLASHLIGHTIOC_G_FLASHTYPE:
            iFlashType = FLASHLIGHT_NONE;
            kdArg.arg = iFlashType;
            if(copy_to_user((void __user *) arg , (void*)&kdArg , sizeof(kdStrobeDrvArg)))
			{
				logE("[FLASHLIGHTIOC_G_FLASHTYPE] ioctl copy to user failed ~");
				return -EFAULT;
			}
            break;
    	default :
    		logI("[default_flashlight_ioctl] ~");
    		break;
    }
    return i4RetValue;
}
コード例 #5
0
static void handleSerialEvent(struct VeSerialPortS *port, VeSerialEvent event, char const *descr)
{
	if (event == VE_SERIAL_EV_ERROR) {
		logE("serial", "%s, bailing out", descr);
		pltExit(1);
	}
}
コード例 #6
0
int getStrobeIndex(int strobeId)
{
	if(strobeId<1 ||  strobeId>2)
	{
		logE("strobeId=%d is wrong",strobeId);
		return -1;
	}
	return strobeId-1;
}
コード例 #7
0
int getPartIndex(int partId)
{
	if(partId<1 ||  partId>2)
	{
		logE("partId=%d is wrong",partId);
		return -1;
	}
	return partId-1;
}
コード例 #8
0
ファイル: handler.c プロジェクト: okeuday/sillymud
/* move a player out of a room */
void char_from_room(struct char_data *ch)
{
  char buf[MAX_INPUT_LENGTH];
  struct char_data *i;
  struct room_data *rp;
  
  if (ch->in_room == NOWHERE) {
    logE("NOWHERE extracting char from room (handler.c, char_from_room)");
    return;
  }
  
  if (ch->equipment[WEAR_LIGHT])
    if (ch->equipment[WEAR_LIGHT]->obj_flags.type_flag == ITEM_LIGHT)
      if (ch->equipment[WEAR_LIGHT]->obj_flags.value[2]) /* Light is ON */
	real_roomp(ch->in_room)->light--;
  
  rp = real_roomp(ch->in_room);
  if (rp==NULL) {
    sprintf(buf, "ERROR: char_from_room: %s was not in a valid room (%d)",
	    (!IS_NPC(ch) ? (ch)->player.name : (ch)->player.short_descr),
	    ch->in_room);
    logE(buf);
    return;
  }
  
  if (ch == rp->people)  /* head of list */
    rp->people = ch->next_in_room;
  
  else {   /* locate the previous element */
    for (i = rp->people; i && i->next_in_room != ch; i = i->next_in_room)
      ;
    if (i)
      i->next_in_room = ch->next_in_room;
    else {
      sprintf(buf, "SHIT, %s was not in people list of his room %d!",
	      (!IS_NPC(ch) ? (ch)->player.name : (ch)->player.short_descr),
	      ch->in_room);
      logE(buf);
    }
  }
  
  ch->in_room = NOWHERE;
  ch->next_in_room = 0;
}
コード例 #9
0
ファイル: data_analyse.c プロジェクト: xidian-hgj/FunPower
void addPowerDataGroup(PowerDataGroup * group, PowerData * data)
{
	if (group == NULL || data == NULL) {
		logE("addPowerDataGroup : group or data is null");
		return;
	}

	group->datas[group->size] = *data;
	group->size++;
}
コード例 #10
0
/** 50ms tick to invalidate items if there are not received in time */
void valuesTick(void)
{
	gpsTick();
	veItemTick(&root);

	if (timeout && --timeout == 0) {
		logE(MODULE, "timeout connecting device");
		pltExit(129);
	}
}
コード例 #11
0
int getSensorDevIndex(int sensorDev)
{
	if(sensorDev==e_CAMERA_MAIN_SENSOR)
		return 0;
	else if(sensorDev==e_CAMERA_SUB_SENSOR)
		return 1;
	else if(sensorDev==e_CAMERA_MAIN_2_SENSOR)
		return 2;
	else
	{
		logE("sensorDev=%d is wrong",sensorDev);
		return -1;
	}
}
コード例 #12
0
ファイル: reception.c プロジェクト: okeuday/sillymud
/* Puts object in store, at first item which has no -1 */
void put_obj_in_store(struct obj_data *obj, struct obj_file_u *st)
{
  int j;
  struct obj_file_elem *oe;
  char buf[256];

  if (st->number>=MAX_OBJ_SAVE) {
    printf("holy shit, you want to rent more than %d items?!\n", st->number);
    return;
  }

  oe = st->objects + st->number;
  
  oe->item_number = obj_index[obj->item_number].virtual;
  oe->value[0] = obj->obj_flags.value[0];
  oe->value[1] = obj->obj_flags.value[1];
  oe->value[2] = obj->obj_flags.value[2];
  oe->value[3] = obj->obj_flags.value[3];
  
  oe->extra_flags = obj->obj_flags.extra_flags;
  oe->weight  = obj->obj_flags.weight;
  oe->timer  = obj->obj_flags.timer;
  oe->bitvector  = obj->obj_flags.bitvector;

/*  new, saving names and descrips stuff */
      if (obj->name)
         strcpy(oe->name, obj->name);
      else {
	sprintf(buf, "object %d has no name!", obj_index[obj->item_number].virtual);
	logE(buf);
	
      }
	
      if (obj->short_description)
         strcpy(oe->sd, obj->short_description);
      else
	*oe->sd = '\0';
      if (obj->description)
         strcpy(oe->desc, obj->description);
      else 
	*oe->desc = '\0';

/* end of new, possibly buggy stuff */


  for(j=0; j<MAX_OBJ_AFFECT; j++)
    oe->affected[j] = obj->affected[j];

  st->number++;
}
コード例 #13
0
int StrobeGlobalDriver::init(int sensorDev, int strobeId)
{
    logI("init dev=%d id=%d", sensorDev, strobeId);
    Mutex::Autolock lock(mLock);
    openkd_nolock();
	int err;
	err = sendCommand_nolock(FLASHLIGHTIOC_X_SET_DRIVER, sensorDev, strobeId, 0);
	if(err!=0)
	{
        logE("FLASHLIGHTIOC_X_SET_DRIVER kd_err=%d", err);
		return StrobeDrv::STROBE_UNKNOWN_ERROR;
    }
	return 0;
}
コード例 #14
0
int StrobeGlobalDriver::sendCommand_nolock(int cmd, int sensorDev, int strobeId, int arg)
{
    logI("sendCommand_nolock()");
	if (mStrobeHandle <= 0)
	{
	    logE("sendCommand() mStrobeHandle <= 0 ~");
	    return StrobeDrv::STROBE_UNKNOWN_ERROR;
	}
	kdStrobeDrvArg stbArg;
    stbArg.sensorDev=sensorDev;
    stbArg.strobeId = strobeId;
    stbArg.arg=arg;
    return ioctl(mStrobeHandle, cmd, &stbArg);
}
コード例 #15
0
ファイル: console.c プロジェクト: idaohang/dbus_gps
veBool consoleOption(int flag)
{
	switch(flag)
	{
	case 't':
		errno = 0;
		devReg.timeOut = veArgInt(optarg);
		if (errno == EINVAL) {
			logE(MODULE, "wrong timeout argument");
			pltExit(128);
		}
		break;
	case 'b':
		errno = 0;
		devReg.baudRate = veArgInt(optarg);
		if (errno == EINVAL) {
			logE(MODULE, "wrong baud rate argument");
			pltExit(128);
		}
	}

	return veTrue;
}
コード例 #16
0
ファイル: handler.c プロジェクト: okeuday/sillymud
/* Take an object from a room */
void obj_from_room(struct obj_data *object)
{
  struct obj_data *i;
  
  /* remove object from room */

  if (object->in_room <= NOWHERE) {
    if (object->carried_by || object->equipped_by) {
       logE("Eek.. an object was just taken from a char, instead of a room");
       assert(0);
    }
    return;  /* its not in a room */
  }
  
  if (object == real_roomp(object->in_room)->contents)  /* head of list */
    real_roomp(object->in_room)->contents = object->next_content;
  
  else     /* locate previous element in list */
    {
      for (i = real_roomp(object->in_room)->contents; i && 
	   (i->next_content != object); i = i->next_content);
      
      if (i) {
         i->next_content = object->next_content;
      } else {
	logE("Couldn't find object in room");
	assert(0);
      }
    }

  if(IS_SET(real_roomp(object->in_room)->room_flags, SAVE_ROOM))
    save_room(object->in_room);  

  object->in_room = NOWHERE;
  object->next_content = 0;
}
コード例 #17
0
void sortOemItemDres()
{
    int maxTest=500;
    int whileTestCnt=0;
	int i;
	int j;
	//test
	for(i=0;i<CAMERA_DATA_TYPE_NUM;i++)
	{
		if(gOemItemDres[i].id<0 || gOemItemDres[i].id>=CAMERA_DATA_TYPE_NUM)
			logE("gOemItemDres[i].id is not correct!!! (<0 || > max)");

	    for(j=i+1;j<CAMERA_DATA_TYPE_NUM;j++)
		{
			if(gOemItemDres[i].id == gOemItemDres[j].id)
			{
				logE("gOemItemDres[i].id is not correct!!! (duplicated)");
			}
		}
    }
	OemItemDres tmp;
	for(i=0;i<CAMERA_DATA_TYPE_NUM;i++)
	{
		while(gOemItemDres[i].id != i)
		{
			int pos2;
			pos2 = gOemItemDres[i].id;
			tmp = gOemItemDres[pos2];
			gOemItemDres[pos2] = gOemItemDres[i];
			gOemItemDres[i] =tmp;
			whileTestCnt++;
			if(whileTestCnt>maxTest)
			    break;
		}
	}
}
コード例 #18
0
int StrobeGlobalDriver::openkd_nolock()
{
    if(mUsers==0)
	{
		mStrobeHandle = open(STROBE_DEV_NAME, O_RDWR);
		logI("open flash driver kd=%d", mStrobeHandle);
	}

	if (mStrobeHandle <= 0)
    {
        logE("error openkd_nolock %s: %s", STROBE_DEV_NAME, strerror(errno));
		return StrobeDrv::STROBE_UNKNOWN_ERROR;
    }
	android_atomic_inc(&mUsers);
	return 0;
}
コード例 #19
0
ファイル: tg_context.c プロジェクト: jiangzhen1984/tgserver
int getCurrentClientCounts()
{
	if(g_clients==NULL)
	{
		logE(TAG,"clients array isn't initialized!");
		return 0;
	}	
	int count=0;
	TGClient * pT=NULL;
	TGClient ** pHead=g_clients;
	while((pT=*pHead++)!=NULL)
	{
		count++;
	}
	return count;
}
コード例 #20
0
ファイル: spec_assign.c プロジェクト: okeuday/sillymud
/* assign special procedures to rooms */
void assign_rooms()
{
  static struct special_proc_entry specials[] = {

    {   99,  Donation},
    { 500,   druid_challenge_prep_room},
    { 501,   druid_challenge_room},
    { 550,   monk_challenge_prep_room},
    { 551,   monk_challenge_room},
    { 3030,  dump },
    { 13547, dump },
    { 3054,  pray_for_items },

    { 2188,  Magic_Fountain},
    { 2189,  Magic_Fountain},

    { 13518, Fountain},
    { 11014, Fountain},
    { 5234,  Fountain},
    { 3141,  Fountain},
    { 13406,  Fountain},
    { 22642,  Fountain},
    { 22644,  Fountain},
    { 22646,  Fountain},
    { 22648,  Fountain},
    { 13530, pet_shops },

    { 2500, entering_turbo_lift },
    { 2639, turbo_lift },

    { 2000,  bank },
    { 13521, bank },
    { -1, NULL},
  };
  int i;
  struct room_data *rp;
  char buf[80];
  
  for (i=0; specials[i].vnum>=0; i++) {
    rp = real_roomp(specials[i].vnum);
    if (rp==NULL) {
      sprintf(buf,"assign_rooms: room %d unknown",specials[i].vnum);
      logE(buf);
    } else
      rp->funct = specials[i].proc;
  }
}
コード例 #21
0
ファイル: handler.c プロジェクト: okeuday/sillymud
/* take an object from a char */
void obj_from_char(struct obj_data *object)
{
  struct obj_data *tmp;
  
  if (!object) {
    logE("No object to be take from char.");
    assert(0);
  }
  
  
  if (!object->carried_by) {
    logE("this object is not carried by anyone");
    assert(0);
  }
  
  if (!object->carried_by->carrying) {
    logE("No one is carrying this object");
    assert(0);
  }

  if (object->in_obj) {
    logE("Obj in more than one place.");
    assert(0);
  }

  if (object->equipped_by) {
    logE("Obj in more than one place.");
    assert(0);
  }
  
  if (object->carried_by->carrying == object)   /* head of list */
    object->carried_by->carrying = object->next_content;
  
  else
    {
      for (tmp = object->carried_by->carrying; 
	   tmp && (tmp->next_content != object); 
	   tmp = tmp->next_content); /* locate previous */
      
      if (!tmp) {
	logE("Couldn't find object on character");
	assert(0);
      }
      
      tmp->next_content = object->next_content;
    }
  
  IS_CARRYING_W(object->carried_by) -= GET_OBJ_WEIGHT(object);
  IS_CARRYING_N(object->carried_by)--;
  object->carried_by = 0;
  object->equipped_by = 0; /* should be unnecessary, but, why risk it */
  object->next_content = 0;
  object->in_obj = 0;
}
コード例 #22
0
ファイル: tg_service.c プロジェクト: jiangzhen1984/tgserver
// check library 
// check some functions  exist in library or not
// if it doesn't exist in library return -1 
// else if it's correct return 0 and fill functions address into ppService
static int checkLib(void * dlHandler,struct TGService ** ppService)
{
	static int sID=0;
	struct TGService * pService=(struct TGService *) malloc(sizeof(struct TGService));
	memset(pService,0,sizeof(struct TGService));

	SERVICE_CREATE_FUNCTION fpC=NULL;
	SERVICE_INIT_FUNCTION fpI=NULL;
	SERVICE_DO_REQUEST_FUNCTION fpDo=NULL;
	SERVICE_RELEASE_FUNCTION fpR=NULL;
	SERVICE_DESTROY_FUNCTION fpD=NULL;
	
#ifdef LINUX
	fpC=dlsym(dlHandler,SERVICE_CREATE_FUNCTION_NAME);
	fpI=dlsym(dlHandler,SERVICE_INIT_FUNCTION_NAME);
	fpDo=dlsym(dlHandler,SERVICE_DO_REQUEST_FUNCTION_NAME);
	fpR=dlsym(dlHandler,SERVICE_RELEASE_FUNCTION_NAME);
	fpD=dlsym(dlHandler,SERVICE_DESTROY_FUNCTION_NAME);
#elif WIN32
#endif

	int flag;
	if(fpC!=NULL && fpI!=NULL && fpDo!=NULL && fpR!=NULL && fpD!=NULL)
	{
		pService->sID=sID++;	
		pService->do_create=fpC;
		pService->do_init=fpI;
		pService->do_request=fpDo;
		pService->do_release=fpR;
		pService->do_destroy=fpD;
		flag=0;
		*ppService=pService;
		logI(TAG," checked successfully flag:%d create:%s init:%s request:%s release:%s desotry:%s",flag,(long)&fpC,(long)&fpI,(long)&fpDo,(long)&fpR,(long)&fpD);
	}
	else
	{
		flag=-1;
		logE(TAG," checked library error:%s %s %s %s %s",fpC,fpI,fpDo,fpR,fpD);
		free(pService);
	}
	

	return flag;
}
コード例 #23
0
ファイル: tg_context.c プロジェクト: jiangzhen1984/tgserver
// send signal to client
// return 0 send successfully
// return -1 send error client pipe closed
int sendSignalToClient(TGClient * pCli,char * msg)
{
	if(pCli==NULL || msg==NULL || pCli->writePipe<0)
	{
		return -1;
	}
	int n=write(pCli->writePipe,msg,strlen(msg));
	if(n==-1)
	{
#ifdef LINUX
		logE(TAG," send signal to sub process failed:%s",strerror(errno));
#elif WIN32
#endif

		return -1;
	}
	return 0;
	
}
コード例 #24
0
ファイル: data_analyse.c プロジェクト: xidian-hgj/FunPower
void addPowerDataSet(PowerDataSet * set, PowerData * data)
{
	if (set == NULL || data == NULL) {
		logE("addPowerDataSet : set or data is null");
		return;
	}

	if (set->size == 0) {
		newGroupInSet(set);
	}

	PowerDataGroup * group = set->dataGroups[set->size - 1];

	if (isPowerGroupFull(group)) {
		group = newGroupInSet(set);
	}

	addPowerDataGroup(group, data);
}
コード例 #25
0
ファイル: tg_service.c プロジェクト: jiangzhen1984/tgserver
static void addService(struct TGService * pSer)
{
	if(pSer==NULL)
	{
		return;
	}
	//FIXME linked list or array?
	if(g_services==NULL)
	{
		logI(TAG," create new space for service array");
		appendGServiceArrayCount();
		g_services[0]=pSer;
		return;
	}
	else
	{
		int i=0;
		for(i=0;i<g_services_counts;i++)
		{
			struct TGService * pS=g_services[i];
			if(pS==NULL)
			{
				g_services[i]=pSer;
				logI(TAG,"load library: id:%d name:%s",pSer->sID,pSer->serviceName);
				return;
			}
		}
		
		//if still not return, means the array is full.
		// we need append space,
		if(appendGServiceArrayCount()==0)
		{
			g_services[i]=pSer;
			logI(TAG,"load library: id:%d name:%s",pSer->sID,pSer->serviceName);
		}
		else
		{
			logE(TAG,"can not push service in to array. cause by: malloc space error");
		}
	}
}
コード例 #26
0
ファイル: data_analyse.c プロジェクト: xidian-hgj/FunPower
double getPower(int cpu_index, PowerDataSet * set, long long timeStart, long long timeEnd)
{
	long count_start, count_end;
	double power_sum, power_over_s, power_over_e;
	PowerData * data_start_u, *data_start_d, *data_end_u, *data_end_d;

	long begin, end;
	PowerData * data_begin, *data_end;

	begin = 0;
	end = getPowerSetNum(set) - 1;

	data_begin = getPowerData(set, begin);
	data_end = getPowerData(set, end);

	if (timeStart < data_begin->time) {
		timeStart = data_begin->time;
	}
	if (timeEnd > data_end->time) {
		timeEnd = data_end->time;
	}

	count_start = findPowerDataCountByTime(timeStart, set);
	count_end = findPowerDataCountByTime(timeEnd, set);

	if (count_start == -1 || count_end == -1) {
		logE("timeStart or timeEnd is out range");
		return 0.0;
	}

	data_start_u = getPowerData(set, count_start);
	data_start_d = getPowerData(set, count_start + 1);
	data_end_u = getPowerData(set, count_end);
	data_end_d = getPowerData(set, count_end + 1);

	power_sum = data_end_d->core_power[cpu_index] - data_start_u->core_power[cpu_index];
	power_over_s = ((timeStart - data_start_u->time) / ((double) (data_start_d->time - data_start_u->time))) * (data_start_d->core_power[cpu_index]-data_start_u->core_power[cpu_index]);
	power_over_e = ((data_end_d->time - timeEnd) / ((double) (data_end_d->time - data_end_u->time))) * (data_end_d->core_power[cpu_index]-data_end_u->core_power[cpu_index]);

	return power_sum - power_over_s - power_over_e;
}
コード例 #27
0
static int getSensorID(CAMERA_DUAL_CAMERA_SENSOR_ENUM i4SensorDev, int& sensorId)
{
    MUINT32 u4SensorID;
    SensorHal*const pSensorHal = SensorHal::createInstance();
    switch  ( i4SensorDev )
    {
    case DUAL_CAMERA_MAIN_SENSOR:
        pSensorHal->sendCommand(SENSOR_DEV_MAIN, SENSOR_CMD_GET_SENSOR_ID, reinterpret_cast<MINT32>(&u4SensorID), 0, 0);
        break;
    case DUAL_CAMERA_SUB_SENSOR:
        pSensorHal->sendCommand(SENSOR_DEV_SUB, SENSOR_CMD_GET_SENSOR_ID, reinterpret_cast<MINT32>(&u4SensorID), 0, 0);
        break;
    case DUAL_CAMERA_MAIN_2_SENSOR:
        pSensorHal->sendCommand(SENSOR_DEV_MAIN_2, SENSOR_CMD_GET_SENSOR_ID, reinterpret_cast<MINT32>(&u4SensorID), 0, 0);
        break;
    default:    //  Shouldn't happen.
        logE("Invalid sensor device: %d", i4SensorDev);
        break;
    }
    sensorId = u4SensorID;
    return 0;
}
コード例 #28
0
void gpsConnectedEvent(void)
{
	VeVariant variant;

	dbus = veDbusGetDefaultBus();

	if (!dbus) {
		logE(MODULE, "dbus connect failed");
		pltExit(1);
	}

	/* Device found */
	timeout = 0;

	veDbusItemInit(dbus, &root);
	veDbusChangeName(dbus, SERVICE_NAME);

	logI(MODULE, "connected to dbus");

	veItemOwnerSet(&processName, veVariantStr(&variant, pltProgramName()));
	veItemOwnerSet(&processVersion, veVariantStr(&variant, pltProgramVersion()));
	veItemOwnerSet(&connection, veVariantStr(&variant, interface()));
}
コード例 #29
0
// read data from main process pipe
// return 0 handle successfully
// return -1 read data  failed 
// return 1 read data successfully but content that client sent is error 
// pData is used to malloc function to allocate
int  read_data_from_main_process(TGClient *pClient,int *pType, char** ppData)
{
	if(pClient==NULL || pClient->readPipe<0)
	{
		return -1;
	}
	char buf[255];
	memset(buf,0,sizeof(buf));
	//FIXME shoule be check pipe
	int n=read(pClient->readPipe,buf,sizeof(buf));
	if(n==0)
	{
		logE(TAG,"main pipe[%d] closed",pClient->readPipe);
		return -1;
	}
	else if(n==-1)
	{
		char * msg="";
		GET_ERR_MSG(msg)
		//FIXME error
		//logE(TAG," read from pipe error:%s",msg);
		return -1;
	}
コード例 #30
0
ファイル: tg_service.c プロジェクト: jiangzhen1984/tgserver
// copy parameters to pSer
void setServiceCreateParameters(struct TGService * pSer,const char * para)
{
	if(pSer==NULL)
	{
		logE(TAG," service not exist");
		return;
	}

	if(pSer->parameters==NULL)
	{
		pSer->parCounts=0;
		int size=SERVICE_DEFAULT_PARA_COUNTS*sizeof(char *);
		pSer->parameters=(char **)malloc(size);
		memset(pSer->parameters,0,size);
	}
	// parameters is out of array need create new 
	else if(pSer->parCounts!=0 && (pSer->parCounts)%SERVICE_DEFAULT_PARA_COUNTS==0)
	{
		int size=(pSer->parCounts+SERVICE_DEFAULT_PARA_COUNTS)*sizeof(char *);
		logI(TAG," create new parameters for id:%d parCounts:%d", pSer->sID,pSer->parCounts);
		char ** pOld=pSer->parameters;
		pSer->parameters=(char **)malloc(size);
		memset(pSer->parameters,0,size);
		memcpy(pSer->parameters,pOld,pSer->parCounts*sizeof(char *));
		free(pOld);
	}

	char *pBuf=NULL;
	int bufSize=strlen(para)+1;
	pBuf=(char *)malloc(bufSize);
	memset(pBuf,0,bufSize);
	strncpy(pBuf,para,bufSize-1);
	pBuf[bufSize-1]='\0';
	pSer->parameters[pSer->parCounts++]=pBuf;
	logD(TAG,"  parameters:%d,  %s",pSer->parCounts,pSer->parameters);
	
}