예제 #1
0
/**************************************************************************
 * Lock and initialize the serial port.
 * This function is called by the LIRC daemon when the first client
 * registers itself.
 * Return 1 on success, 0 on error.
 **************************************************************************/
int mplay_init(void)
{
	int result = 1;
	LOGPRINTF(1, "Entering mplay_init()");
	/* Creation of a lock file for the port */
	if (!tty_create_lock(hw.device)) {
		logprintf(LOG_ERR, "Could not create the lock file");
		LOGPRINTF(1, "Could not create the lock file");
		result = 0;
	}
	/* Try to open serial port */
	else if ((hw.fd = open(hw.device, O_RDWR | O_NONBLOCK | O_NOCTTY)) < 0) {
		logprintf(LOG_ERR, "Could not open the serial port");
		LOGPRINTF(1, "Could not open the serial port");
		mplay_deinit();
		result = 0;
	}
	/* Serial port configuration */
	else if (!tty_reset(hw.fd) || !tty_setbaud(hw.fd, MPLAY_BAUD_RATE)) {
		logprintf(LOG_ERR, "could not configure the serial port for '%s'", hw.device);
		LOGPRINTF(1, "could not configure the serial port for '%s'", hw.device);
		mplay_deinit();
	}
	return result;
}
예제 #2
0
static char *uirt2_raw_rec(struct ir_remote *remotes)
{
	LOGPRINTF(1, "uirt2_raw_rec");
	LOGPRINTF(1, "uirt2_raw_rec: %p", remotes);

	if (!clear_rec_buffer())
		return (NULL);

	if (remotes) {
		char *res;
		res = decode_all(remotes);

		return res;
	} else {
		lirc_t data;

		queue_clear();
		data = uirt2_read_raw(dev, 1);
		if (data) {
			queue_put(data);
		}

		return NULL;
	}
}
예제 #3
0
파일: pmm_interval.c 프로젝트: robfr/pmm
//TODO failure? return 0 on success
int
remove_interval(struct pmm_interval_list *l, struct pmm_interval *i)
{

    LOGPRINTF("removing interval with type: %d\n", i->type);

    //if interval is at top or bottom, rewire top/bottom pointers
    if(l->top == i) {
        l->top = i->previous;
    }
    if(l->bottom == i) {
        l->bottom = i->next;
    }

    //rewire intervals that were previous/next intervals of the remove-ee
    if(i->next != NULL) {
        i->next->previous = i->previous;
    }
    if(i->previous != NULL) {
        i->previous->next = i->next;
    }


    //free interval
    free_interval(&i);
    l->size -= 1;

    LOGPRINTF("size: %d\n", l->size);

    return 1;
}
예제 #4
0
파일: serial.c 프로젝트: aldebaran/lirc
int tty_read(int fd,char *byte)
{
	fd_set fds;
	int ret;
	struct timeval tv;
	
	FD_ZERO(&fds);
	FD_SET(fd,&fds);
	
	tv.tv_sec=1;    /* timeout after 1 sec */
	tv.tv_usec=0;
	ret=select(fd+1,&fds,NULL,NULL,&tv);
	if(ret==0)
	{
		logprintf(LOG_ERR,"tty_read(): timeout");
		return(-1); /* received nothing, bad */
	}
	else if(ret!=1)
	{
		LOGPRINTF(1,"tty_read(): select() failed");
		LOGPERROR(1,"tty_read()");
		return(-1);
	}
	if(read(fd,byte,1)!=1)
	{
		LOGPRINTF(1,"tty_read(): read() failed");
		LOGPERROR(1,"tty_read()");
		return(-1);		
	}
	return(1);
}
예제 #5
0
파일: serial.c 프로젝트: aldebaran/lirc
int tty_setrtscts(int fd,int enable)
{
	struct termios options;

	if(tcgetattr(fd,&options)==-1)
	{
		LOGPRINTF(1,"%s: tcgetattr() failed", __FUNCTION__);
		LOGPERROR(1, __FUNCTION__);
		return(0);
	}
	if(enable)
	{
		options.c_cflag|=CRTSCTS;
	}
	else
	{
		options.c_cflag&=~CRTSCTS;
	}
	if(tcsetattr(fd,TCSAFLUSH,&options)==-1)
	{
		LOGPRINTF(1,"%s: tcsetattr() failed", __FUNCTION__);
		LOGPERROR(1, __FUNCTION__);
		return(0);
	}
	return(1);
}
예제 #6
0
파일: ipc.c 프로젝트: luite/zipbrowser
/* @brief Called after network connection state was requested, or the state has changed
 *
 */  
static void on_connection_status ( eripc_context_t          *context,
                                   const eripc_event_info_t *info,
                                   void                     *user_data )
{
    LOGPRINTF("entry");
    const eripc_arg_t *arg_array  = info->args;

    if ((arg_array[0].type == ERIPC_TYPE_BOOL) && 
        (arg_array[1].type == ERIPC_TYPE_STRING) && 
        (arg_array[2].type == ERIPC_TYPE_STRING) && 
        (arg_array[3].type == ERIPC_TYPE_STRING))
    {
        gboolean    is_connected = arg_array[0].value.b;
      //const gchar *medium      = arg_array[1].value.s;
      //const gchar *profile     = arg_array[2].value.s;
      //const gchar *reason      = arg_array[3].value.s;

        if (is_connected)
        {
            LOGPRINTF("Network connection established");
            g_connect_cb();
        }
        else
        {
            LOGPRINTF("Network connection terminated - reason [%s]", arg_array[3].value.s);
            g_disconnect_cb();
        }
    }
}
예제 #7
0
char *bte_readline()
{
	static char msg[PACKET_SIZE + 1];
	char c;
	static int n = 0;
	int ok = 1;

	LOGPRINTF(6, "bte_readline called");

	if (io_failed && !bte_connect())	// try to reestablish connection
		return (NULL);

	if ((ok = read(hw.fd, &c, 1)) <= 0) {
		io_failed = 1;
		logprintf(LOG_ERR, "bte_readline: read failed - %d: %s", errno, strerror(errno));
		return (NULL);
	}
	if (ok == 0 || c == '\r')
		return NULL;
	if (c == '\n') {
		if (n == 0)
			return NULL;
		msg[n] = 0;
		n = 0;
		LOGPRINTF(1, "bte_readline: %s", msg);
		return (msg);
	}
	msg[n++] = c;
	if (n >= PACKET_SIZE - 1)
		msg[--n] = '!';
	return NULL;
}
예제 #8
0
static int calc_data_bit(struct ir_remote *remote,
                         int table[], int table_len, int signal, int tUnit)
{
        int i;

        for (i = 0; i < table_len; i++)
        {
                if (table[i] == 0)
                {
                        table[i] = signal / tUnit;
                        
                        LOGPRINTF(2, "table[%d] = %d\n", i, table[i]);

                        return i;
                }

                if (expect(remote, signal, table[i] * tUnit))
                {
                        LOGPRINTF(2, "expect %d, table[%d] = %d\n",
                                  signal / tUnit, i, table[i]);
                        return i;
                }
        }

        LOGPRINTF(2, "Couldn't find %d\n", signal/tUnit);

        return -1;
}
예제 #9
0
int livedrive_decode(struct ir_remote *remote, ir_code * prep, ir_code * codep, ir_code * postp, int *repeat_flagp,
		     lirc_t * min_remaining_gapp, lirc_t * max_remaining_gapp)
{
	lirc_t gap;

	if (!map_code(remote, prep, codep, postp, 16, pre, 16, code, 0, 0))
		return (0);

	gap = 0;
	if (start.tv_sec - last.tv_sec >= 2)
		*repeat_flagp = 0;
	else {
		gap = time_elapsed(&last, &start);

		if (gap < 300000)
			*repeat_flagp = 1;
		else
			*repeat_flagp = 0;
	}

	LOGPRINTF(1, "repeat_flag: %d", *repeat_flagp);
	LOGPRINTF(1, "gap: %lu", (__u32) gap);

	return (1);
}
예제 #10
0
파일: ib.c 프로젝트: carriercomm/ix
void FreeBuff(char *buff1, char *buff2)
{
  VAPI_ret_t ret;

  if(s_mr_hndl != VAPI_INVAL_HNDL) {
    LOGPRINTF("Deregistering send buffer\n");
    ret = VAPI_deregister_mr(hca_hndl, s_mr_hndl);
    if(ret != VAPI_OK) {
      fprintf(stderr, "Error deregistering send mr: %s\n", VAPI_strerror(ret));
    } else {
      s_mr_hndl = VAPI_INVAL_HNDL;
    }
  }

  if(r_mr_hndl != VAPI_INVAL_HNDL) {
    LOGPRINTF("Deregistering recv buffer\n");
    ret = VAPI_deregister_mr(hca_hndl, r_mr_hndl);
    if(ret != VAPI_OK) {
      fprintf(stderr, "Error deregistering recv mr: %s\n", VAPI_strerror(ret));
    } else {
      r_mr_hndl = VAPI_INVAL_HNDL;
    }
  }

  if(buff1 != NULL)
    free(buff1);

  if(buff2 != NULL)
    free(buff2);
}
예제 #11
0
int init_device()
{
	char c;
	int fd;
	
	/* user overriding autoprobing */
	if ( hw.device ) {
		fd = open(hw.device,O_RDWR);
		if ( fd < 0 ) {
			LOGPRINTF(1, "Init: open of %s failed", hw.device);
			return 0;
		}
		/* open ok, test device */
		if ( is_my_device(fd,hw.device) ) {
			return fd;
		}
		return 0;
	}
	for(c = 'a';c < 'z';c++) {
		sprintf(dev_name,"/dev/sg%c",c);
		fd = open(dev_name,O_RDWR);
		if ( fd < 0 ) {
			LOGPRINTF(1, "Probing: open of %s failed", dev_name);
			continue;
		}
		/* open ok, test device */
		if ( is_my_device(fd,dev_name) ) {
			hw.device = dev_name;
			return fd;
		}
	}
	return 0;
}
예제 #12
0
struct ir_code_node *defineNode(struct ir_ncode *code, const char *val)
{
	struct ir_code_node *node;

	node=s_malloc(sizeof(*node));
	if(node==NULL) return NULL;

	node->code=s_strtocode(val);
	node->next=NULL;

#       ifdef LONG_IR_CODE
        LOGPRINTF(3,"                           0x%016llX", node->code);
#       else
        LOGPRINTF(3,"                           0x%016lX", node->code);
#       endif

	if(code->current==NULL)
	{
		code->next=node;
		code->current=node;
	}
	else
	{
		code->current->next=node;
		code->current=node;
	}
	return node;
}
예제 #13
0
파일: ibv.c 프로젝트: carriercomm/ix
/* De_register the allocated memory regions before exiting */
void FreeBuff(char *buff1, char *buff2)
{
  int ret;

  if(s_mr_hndl) {
    LOGPRINTF(("Deregistering send buffer"));
    ret = ibv_dereg_mr(s_mr_hndl);
    if(ret) {
      fprintf(stderr, "Error deregistering send mr\n");
    } else {
      s_mr_hndl = NULL;
    }
  }

  if(r_mr_hndl) {
    LOGPRINTF(("Deregistering recv buffer"));
    ret = ibv_dereg_mr(r_mr_hndl);
    if(ret) {
      fprintf(stderr, "Error deregistering recv mr\n");
    } else {
      r_mr_hndl = NULL;
    }
  }

  if(buff1 != NULL)
    free(buff1);

  if(buff2 != NULL)
    free(buff2);
}
예제 #14
0
int hiddev_decode(struct ir_remote *remote, ir_code * prep, ir_code * codep, ir_code * postp, int *repeat_flagp,
		  lirc_t * min_remaining_gapp, lirc_t * max_remaining_gapp)
{
	LOGPRINTF(1, "hiddev_decode");

	if (!map_code(remote, prep, codep, postp, pre_code_length, pre_code, main_code_length, main_code, 0, 0)) {
		return (0);
	}

	LOGPRINTF(1, "lirc code: 0x%X", *codep);

	map_gap(remote, &start, &last, 0, repeat_flagp, min_remaining_gapp, max_remaining_gapp);
	/* override repeat */
	switch (repeat_state) {
	case RPT_NO:
		*repeat_flagp = 0;
		break;
	case RPT_YES:
		*repeat_flagp = 1;
		break;
	default:
		break;
	}

	return 1;
}
예제 #15
0
int CCodecBase::EncodeBegin(utvf_t infmt, unsigned int width, unsigned int height, size_t cbGrossWidth)
{
	LOGPRINTF("%p CCodecBase::EncodeBegin(infmt=%08X, width=%u, height=%u, cbGrossWidth=%" PRIdSZT ")", this, infmt, width, height, cbGrossWidth);

	int ret = InternalEncodeBegin(infmt, width, height, cbGrossWidth);
	LOGPRINTF("%p CCodecBase::EncodeBegin return %d", this, ret);
	return ret;
}
예제 #16
0
int CCodecBase::EncodeQuery(utvf_t infmt, unsigned int width, unsigned int height)
{
	LOGPRINTF("%p CCodecBase::EncodeQuery(infmt=%08X, width=%u, height=%u)", this, infmt, width, height);

	int ret = InternalEncodeQuery(infmt, width, height);
	LOGPRINTF("%p CCodecBase::EncodeQuery return %d", this, ret);
	return ret;
}
예제 #17
0
파일: ib.c 프로젝트: carriercomm/ix
void AfterAlignmentInit(ArgStruct *p)
{
  int bytesRead;

  /* Exchange buffer pointers and remote infiniband keys if doing rdma. Do
   * the exchange in this function because this will happen after any
   * memory alignment is done, which is important for getting the 
   * correct remote address.
  */
  if( p->prot.commtype == NP_COMM_RDMAWRITE || 
      p->prot.commtype == NP_COMM_RDMAWRITE_WITH_IMM ) {
     
     /* Send my receive buffer address
      */
     if(write(p->commfd, (void *)&p->r_buff, sizeof(void*)) < 0) {
        perror("NetPIPE: write of buffer address failed in AfterAlignmentInit");
        exit(-1);
     }
     
     LOGPRINTF("Sent buffer address: %p\n", p->r_buff);
     
     /* Send my remote key for accessing
      * my remote buffer via IB RDMA
      */
     if(write(p->commfd, (void *)&r_mr_out.r_key, sizeof(VAPI_rkey_t)) < 0) {
        perror("NetPIPE: write of remote key failed in AfterAlignmentInit");
        exit(-1);
     }
  
     LOGPRINTF("Sent remote key: %d\n", r_mr_out.r_key);
     
     /* Read the sent data
      */
     bytesRead = readFully(p->commfd, (void *)&remote_address, sizeof(void*));
     if (bytesRead < 0) {
        perror("NetPIPE: read of buffer address failed in AfterAlignmentInit");
        exit(-1);
     } else if (bytesRead != sizeof(void*)) {
        perror("NetPIPE: partial read of buffer address in AfterAlignmentInit");
        exit(-1);
     }
     
     LOGPRINTF("Received remote address from other node: %p\n", remote_address);
     
     bytesRead = readFully(p->commfd, (void *)&remote_key, sizeof(VAPI_rkey_t));
     if (bytesRead < 0) {
        perror("NetPIPE: read of remote key failed in AfterAlignmentInit");
        exit(-1);
     } else if (bytesRead != sizeof(VAPI_rkey_t)) {
        perror("NetPIPE: partial read of remote key in AfterAlignmentInit");
        exit(-1);
     }
     
     LOGPRINTF("Received remote key from other node: %d\n", remote_key);

  }
}
예제 #18
0
파일: hw_tira.c 프로젝트: zenwheel/lirc
int tira_init(void)
{
	if (child_pid != -1) tira_deinit();

	LOGPRINTF (1, "Tira init");
	
	if(!tty_create_lock(hw.device))
	{
		logprintf(LOG_ERR,"could not create lock files");
		return 0;
	}
	if ( (hw.fd = open (hw.device, O_RDWR | O_NONBLOCK | O_NOCTTY)) < 0)
	{
		tty_delete_lock ();
		logprintf (LOG_ERR, "Could not open the '%s' device",
			   hw.device);
		return 0;
	}
	LOGPRINTF(1, "device '%s' opened", hw.device);

	/* We want 9600 8N1 with CTS/RTS handshaking, lets set that
	 * up. The specs state a baud rate of 100000, looking at the
	 * ftdi_sio driver it forces the issue so we can set to what
	 * we would like. And seeing as this is mapped to 9600 under
	 * windows should be a safe bet.
	 */

	/* Determine device type */
	device_type=0;
	if (check_tira()) device_type='t';else
	if (check_ira()) device_type='i';

#ifdef DEBUG
	const char *device_string;
	
	switch(device_type)
	{
	case 't':
		device_string = "Tira";
		break;
	case 'i':
		device_string = "Ira";
		break;
	default:
		device_string = "unknown";
	}
	LOGPRINTF(1, "device type %s", device_string);
#endif

	if (device_type == 0)
	{
		tira_deinit();
		return 0;
	}  

	return 1;
}
예제 #19
0
int is_my_device(int fd,char *name)
{
	sg_io_hdr_t io_hdr;
	int k;
	unsigned char inqCmdBlk [SCSI_INQ_CMD_LEN] = 
		{INQUIRY, 0, 0, 0, MAX_SCSI_REPLY_LEN, 0};
	unsigned char Buff[MAX_SCSI_REPLY_LEN];
	unsigned char sense_buffer[32];

	/* Just to be safe, check we have a sg device wigh version > 3 */
	if ((ioctl(fd, SG_GET_VERSION_NUM, &k) < 0) || (k < 30000)) {
		LOGPRINTF(LOG_ERR, "%s isn't sg device version > 3",name);
		return 0;
	} else {
		usleep(10);
		LOGPRINTF(1,"%s is valid sg device - checking what it is",
			  name);
	}

	/* Prepare INQUIRY command */
	memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
	io_hdr.interface_id = 'S';
	io_hdr.cmd_len = sizeof(inqCmdBlk);
	io_hdr.mx_sb_len = sizeof(sense_buffer);
	io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
	io_hdr.dxfer_len = MAX_SCSI_REPLY_LEN;
	io_hdr.dxferp = Buff;
	io_hdr.cmdp = inqCmdBlk;
	io_hdr.sbp = sense_buffer;
	io_hdr.timeout = 2000;

	if (ioctl(fd, SG_IO, &io_hdr) < 0) {
		LOGPRINTF(LOG_ERR, "INQUIRY SG_IO ioctl error");
		return 0;
	} else {
		usleep(10);
	}
	if ( (io_hdr.info & SG_INFO_OK_MASK) != SG_INFO_OK) {
		LOGPRINTF(LOG_ERR,
			  "INQUIRY: SCSI status=0x%x host_status=0x%x "
			  "driver_status=0x%x",io_hdr.status,
			  io_hdr.host_status,io_hdr.driver_status);
		return 0;
	}
	/* check INQUIRY returned string */
	if ( strncmp(Buff+8,"CREATIVE",8) > 0 ) {
		LOGPRINTF(LOG_ERR, "%s is %s (vendor isn't Creative)",
			  name,Buff+8);
	}

	/* now run sense_mode_10 for page 0 to see if this is really it */
	if ( test_device_command(fd) < 0 ) {
		return 0;
	}
	return 1;
}
예제 #20
0
int parseFlags(char *val)
{
        struct flaglist *flaglptr;
	int flags=0;
	char *flag,*help;

	flag=help=val;
	while(flag!=NULL)
	{
		while(*help!='|' && *help!=0) help++;
		if(*help=='|')
		{
			*help=0;help++;
		}
		else
		{
			help=NULL;
		}

		flaglptr=all_flags;
		while(flaglptr->name!=NULL){
			if(strcasecmp(flaglptr->name,flag)==0){
				if(flaglptr->flag&IR_PROTOCOL_MASK &&
				   flags&IR_PROTOCOL_MASK)
				{
					logprintf(LOG_ERR, "error in "
						  "configfile line %d:",
						  line);
					logprintf(LOG_ERR, "multiple "
						  "protocols given in flags: "
						  "\"%s\"",flag);
					parse_error=1;
					return(0);
				}
				flags=flags|flaglptr->flag;
				LOGPRINTF(3,"flag %s recognized",
					  flaglptr->name);
				break;
			}
			flaglptr++;
		}
		if(flaglptr->name==NULL)
		{
			logprintf(LOG_ERR,"error in configfile line %d:",
				  line);
			logprintf(LOG_ERR,"unknown flag: \"%s\"",flag);
			parse_error=1;
			return(0);
		}
		flag=help;
	}
	LOGPRINTF(2,"flags value: %d",flags);

        return(flags);
}
예제 #21
0
struct ir_ncode *defineCode(char *key, char *val, struct ir_ncode *code)
{
        code->name=s_strdup(key);
        code->code=s_strtocode(val);
#       ifdef LONG_IR_CODE
        LOGPRINTF(3,"      %-20s 0x%016llX",code->name, code->code);
#       else
        LOGPRINTF(3,"      %-20s 0x%016lX",code->name, code->code);
#       endif
        return(code);
}
예제 #22
0
int bte_decode(struct ir_remote *remote, ir_code * prep, ir_code * codep, ir_code * postp, int *repeat_flagp,
	       lirc_t * min_remaining_gapp, lirc_t * max_remaining_gapp)
{
	LOGPRINTF(3, "bte_decode called");
	*prep = pre;
	*codep = code;
	*postp = 0;

	LOGPRINTF(1, "bte_decode: %llx", (__u64) * codep);
	return (1);
}
예제 #23
0
파일: ibv.c 프로젝트: carriercomm/ix
/* SendData == Post a 'send' request to the (send)command queue */
void SendData(ArgStruct *p)
{
  int                ret;       /* Return code */
  struct ibv_send_wr sr;        /* Send request */
  struct ibv_send_wr *bad_wr;	/* Handle to any incomplete wr returned by ibv*/
  struct ibv_sge     sg_entry;  /* Scatter/Gather list - holds buff addr */

  /* Fill in send request struct */
    /* Set the send request's opcode based on run-time options */
  if(p->prot.commtype == NP_COMM_SENDRECV) {
     sr.opcode = IBV_WR_SEND;
     LOGPRINTF(("Doing regular send"));
  } else if(p->prot.commtype == NP_COMM_SENDRECV_WITH_IMM) {
     sr.opcode = IBV_WR_SEND_WITH_IMM;
     LOGPRINTF(("Doing regular send with imm"));
  } else if(p->prot.commtype == NP_COMM_RDMAWRITE) {
     sr.opcode = IBV_WR_RDMA_WRITE;	/* if RDMA, need to give more info */
     sr.wr.rdma.remote_addr = (uintptr_t)(((char *)remote_address) + (p->s_ptr - p->s_buff));
     sr.wr.rdma.rkey = remote_key;
     LOGPRINTF(("Doing RDMA write (raddr=%p)", sr.wr.rdma.remote_addr));
  } else if(p->prot.commtype == NP_COMM_RDMAWRITE_WITH_IMM) {
     sr.opcode = IBV_WR_RDMA_WRITE_WITH_IMM;	/* more info if RDMA */
     sr.wr.rdma.remote_addr = (uintptr_t)(((char *)remote_address) + (p->s_ptr - p->s_buff));
     sr.wr.rdma.rkey = remote_key;
     LOGPRINTF(("Doing RDMA write with imm (raddr=%p)", sr.wr.rdma.remote_addr));
  } else {
     fprintf(stderr, "Error, invalid communication type in SendData\n");
     exit(-1);
  }
  
  sr.send_flags = 0;	/* This needed due to a bug in Mellanox HW rel a-0 */

  sr.num_sge = 1;		    /* # entries in this request */
  sr.sg_list = &sg_entry;	    /* the list of other requests */
  sr.next = NULL;		    /* the next request in the list */

  sg_entry.lkey = s_mr_hndl->lkey;  /* Local memory region key */
  sg_entry.length = p->bufflen;	   /* buffer's size */
  sg_entry.addr = (uintptr_t)p->s_ptr;	/* buffer's location */


  
  /* Post the send request to the (send)command queue */

  /* ibv_post_send(...) is handled in same fashion ibv_post_recv(..) */
  ret = ibv_post_send(qp_hndl, &sr, &bad_wr);
  if(ret) {
    fprintf(stderr, "Error posting send request\n");
  } else {
    LOGPRINTF(("Posted send request"));
  }

}
예제 #24
0
char *mp3anywhere_rec(struct ir_remote *remotes)
{
	char *m;
	int i=0;
	b[0]=0x00;
	b[1]=0xd5;
	b[2]=0xaa;
	b[3]=0xee;
	b[5]=0xad;

	last=end;
	gettimeofday(&start,NULL);
	while(b[i] != 0xAD)
	{
		i++;
		if(i>=NUMBYTES)
		{
			LOGPRINTF(0,"buffer overflow at byte %d",i);
			break;
		}
		if(i>0)
		{
			if(!waitfordata(TIMEOUT))
			{
				LOGPRINTF(0,"timeout reading byte %d",i);
				return(NULL);
			}
		}
		if(read(hw.fd,&b[i],1)!=1)
		{
			logprintf(LOG_ERR,"reading of byte %d failed",i);
			logperror(LOG_ERR,NULL);
			return(NULL);
		}
		if(b[1]!= 0xd5 ||
		   b[2]!= 0xaa ||
		   b[3]!= 0xee ||
		   b[5]!= 0xad )
		{
			logprintf(LOG_ERR,"bad envelope");
			return(NULL);
		}
		LOGPRINTF(1,"byte %d: %02x",i,b[i]);
	}
	gettimeofday(&end,NULL);

	pre=0xD5AAEE;
	code=(ir_code) b[4];
	
	m=decode_all(remotes);
	return(m);
}
예제 #25
0
char *logitech_rec(struct ir_remote *remotes)
{
	char *m;
	int i=0;
	int repeat, mouse_event;
	b[i]=0x00;

	last=end;
	gettimeofday(&start,NULL);
	while(b[i] != 0xAA)
	{
		i++;
		if(i>=NUMBYTES)
		{
			LOGPRINTF(0,"buffer overflow at byte %d",i);
			break;
		}
		if(i>0)
		{
			if(!waitfordata(TIMEOUT))
			{
				LOGPRINTF(0,"timeout reading byte %d",i);
				return(NULL);
			}
		}
		if(read(hw.fd,&b[i],1)!=1)
		{
			logprintf(LOG_ERR,"reading of byte %d failed",i);
			logperror(LOG_ERR,NULL);
			return(NULL);
		}
		LOGPRINTF(1,"byte %d: %02x",i,b[i]);
		if(b[i] >= 0x40 && b[i] <= 0x6F)
		{
			mouse_event=b[i];
			b[1]=0xA0;
			b[2]=mouse_event;
			LOGPRINTF(1,"mouse event: %02x",mouse_event);
			break;
		}
	}
	gettimeofday(&end,NULL);

	if(b[1] == 0xA0) repeat=0;
	else repeat=1;
	if(!repeat) pre=(ir_code) b[1];
	else pre=0xA0;
	code=(ir_code) b[2];
	
	m=decode_all(remotes);
	return(m);
}
예제 #26
0
/* initialize driver -- returns 1 on success, 0 on error */
static int dfc_init()
{
	struct usb_device *usb_dev;
	int pipe_fd[2] = { -1, -1 };

	LOGPRINTF(1, "initializing USB receiver");

	init_rec_buffer();

	usb_dev = find_usb_device();
	if (usb_dev == NULL) {
		logprintf(LOG_ERR, "couldn't find a compatible USB device");
		return 0;
	}

	/* A separate process will be forked to read data from the USB
	 * receiver and write it to a pipe. hw.fd is set to the readable
	 * end of this pipe. */
	if (pipe(pipe_fd) != 0) {
		logperror(LOG_ERR, "couldn't open pipe");
		return 0;
	}
	hw.fd = pipe_fd[0];

	dev_handle = usb_open(usb_dev);
	if (dev_handle == NULL) {
		logperror(LOG_ERR, "couldn't open USB receiver");
		goto fail;
	}

	child = fork();
	if (child == -1) {
		logperror(LOG_ERR, "couldn't fork child process");
		goto fail;
	} else if (child == 0) {
		usb_read_loop(pipe_fd[1]);
	}

	LOGPRINTF(1, "USB receiver initialized");
	return 1;

fail:
	if (dev_handle) {
		usb_close(dev_handle);
		dev_handle = NULL;
	}
	if (pipe_fd[0] >= 0)
		close(pipe_fd[0]);
	if (pipe_fd[1] >= 0)
		close(pipe_fd[1]);
	return 0;
}
예제 #27
0
파일: utv_vcm.cpp 프로젝트: hdezela/utvideo
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
	if (dwReason == DLL_PROCESS_ATTACH)
	{
		LOGPRINTF("DllMain(hModule=%p, dwReason=DLL_PROCESS_ATTACH, lpReserved=%p)", hModule, lpReserved);
	}
	else if (dwReason == DLL_PROCESS_DETACH)
	{
		LOGPRINTF("DllMain(hModule=%p, dwReason=DLL_PROCESS_DETACH, lpReserved=%p)", hModule, lpReserved);
	}

	return TRUE;
}
예제 #28
0
static int uirt2_raw_decode(struct ir_remote *remote, ir_code * prep, ir_code * codep, ir_code * postp,
			    int *repeat_flagp, lirc_t * min_remaining_gapp, lirc_t * max_remaining_gapp)
{
	int res;

	LOGPRINTF(1, "uirt2_raw_decode: enter");

	res = receive_decode(remote, prep, codep, postp, repeat_flagp, min_remaining_gapp, max_remaining_gapp);

	LOGPRINTF(1, "uirt2_raw_decode: %d", res);

	return res;
}
예제 #29
0
int CCodecBase::InternalSetStateWrapper(const void *pState, size_t cb)
{
	if (IsLogWriterInitializedOrDebugBuild())
	{
		char buf[256];
		FormatBinary(buf, pState, cb, GetStateSize());
		LOGPRINTF("%p CCodecBase::InternalSetStateWrapper(pState=%s, cb=%" PRIuSZT ")", this, buf, cb);
	}

	int ret = InternalSetState(pState, cb);
	LOGPRINTF("%p CCodecBase::InternalSetStateWrapper return %d", this, ret);
	return ret;
}
예제 #30
0
int CCodecBase::DecodeQuery(utvf_t outfmt, unsigned int width, unsigned int height, const void *pExtraData, size_t cbExtraData)
{
	if (IsLogWriterInitializedOrDebugBuild())
	{
		char buf[256];
		FormatBinary(buf, pExtraData, cbExtraData, EncodeGetExtraDataSize());
		LOGPRINTF("%p CCodecBase::DecodeQuery(outfmt=%08X, width=%u, height=%u, pExtraData=%s, cbExtraData=%" PRIuSZT ")", this, outfmt, width, height, buf, cbExtraData);
	}

	int ret = InternalDecodeQuery(outfmt, width, height, pExtraData, cbExtraData);
	LOGPRINTF("%p CCodecBase::DecodeQuery return %d", this, ret);
	return ret;
}