예제 #1
0
파일: ide_sim.c 프로젝트: HTshandou/newos
static void scan_bus( ide_bus_info *bus, CCB_HEADER *ccb )
{
	int i;
	
	SHOW_FLOW0( 3, "" );
	
	for( i = 0; i < bus->controller_params.max_devices; ++i ) {
		scan_device( bus, i );
	}
	
	ccb->cam_status = CAM_REQ_CMP;
	xpt->done( ccb );
}
예제 #2
0
int main()
{
  if( general_basic_tests() != 0 ) {
    printf("\nDIAGNOSTIC_FAILED\n");
    return 1;
  }
  if( scan_device() != 0 ){
    printf("\nDIAGNOSTIC_FAILED\n");
    return 1;
  }

  printf("\nDIAGNOSTIC_PASSED\n");
  return 0;
}
예제 #3
0
static
void scan_card(scan_t *scan)
{
    int device = -1;
    int err;

    while ((err = snd_ctl_rawmidi_next_device(scan->ctl, &device))>=0 && device >=0) {
        snd_rawmidi_info_set_device(scan->info, device);

        snd_rawmidi_info_set_stream(scan->info, SND_RAWMIDI_STREAM_INPUT);
        snd_rawmidi_info_set_subdevice(scan->info, 0);
        if ((err = snd_ctl_rawmidi_info(scan->ctl, scan->info))>=0)
            scan_device(scan);
        else if (err != -ENOENT)
            alsa_error("scan: snd_ctl_rawmidi_info on device", err);

        snd_rawmidi_info_set_stream(scan->info, SND_RAWMIDI_STREAM_OUTPUT);
        snd_rawmidi_info_set_subdevice(scan->info, 0);
        if ((err = snd_ctl_rawmidi_info(scan->ctl, scan->info))>=0)
            scan_device(scan);
        else if (err != -ENOENT)
            alsa_error("scan: snd_ctl_rawmidi_info on device", err);
    }
}
예제 #4
0
int main(int argc, char **argv)
{
	int ch;
	off_t startBlock = 0LL;
	off_t endBlock = INT64_MAX;
	outputFile = stdout;
	if (argc < 2)
		return usage(1);

	while ((ch = getopt(argc, argv, "b:c:hsv?")) != -1) {
		switch (ch) {
		case 'b':
			blockSize = atoi(optarg);
			//fprintf(stderr, "bs %d\n", blockSize);
			break;
		case 'c':
			group = atoi(optarg);
			//fprintf(stderr, "g %d\n", group);
			break;
		case 's':
			progress = 1;
			break;
		case 'v':
			verbose = 1;
			break;
		case 'h':
		case '?':
			return usage(0);
		default:
			return usage(1);
		}
	}
	argc -= optind;
	argv += optind;

	if (argc > 2)
		startBlock = atoll(argv[2]);
	if (argc > 1)
		endBlock = atoll(argv[1]);

	return scan_device(argv[0], startBlock, endBlock);
}
예제 #5
0
int scan_usb()
{
  int dev_cnt = 0;

  usb_init();
  usb_find_busses();
  usb_find_devices();

  struct usb_bus *bus = NULL;
  struct usb_device *dev = NULL;
  for(bus = usb_get_busses(); bus; bus = bus->next)
  {
    for(dev = bus->devices; dev; dev=dev->next)
    {
      scan_device(dev, &dev_cnt);
      if(dev_cnt==MAX_DEVICES) return dev_cnt;
    }
  }

  return dev_cnt;
}
예제 #6
0
파일: pci.c 프로젝트: mohamed-anwar/Aquila
static void scan_bus(uint8_t bus)
{
    for (uint8_t dev = 0; dev < 32; ++dev) {
        scan_device(bus, dev);
    }
}
예제 #7
0
int parse_request(char *request)
{
	char action[MAX_ACTION],arg[MAX_ARG_N][MAX_ARG],buf[MAX_BUF];
	char path[MAX_PATH];
	//time_t time_start,time_stop;
	struct tm tm1,tm2;//start & stop time
	time_t t1,t2;
	float max_temp,min_temp,ave_temp;
	float t;
	FT_HANDLE fthandle;
	if(!request)
	{
		return -1;
	}
	sscanf(request,"%*[^=]=%[^&]",action);
	if(strcmp(action,"queryTemperature")==0)
	{
		fthandle=scan_device();
		if(fthandle)
		{
			query_temperature(fthandle,&t);
			printf("[%ld,%g]",time(NULL),t);
		}
		else
		{
			return -1;
		}
	}
	else if(strcmp(action,"get_extrema_temp")==0)
	{
		sscanf(request,"%*[^&]&%*[^=]=%[^&]&%*[^=]=%[^&]%*[^=]=%s",arg[0],arg[1],arg[2]);
		sprintf(path,"%s.log",arg[0]);
		strncpy(buf,arg[0],4);
		buf[4]='\0';
		tm1.tm_year=tm2.tm_year=atoi(buf)-1900;
		strncpy(buf,arg[0]+5,2);
		buf[2]='\0';
		tm1.tm_mon=tm2.tm_mon=atoi(buf)-1;
		strncpy(buf,arg[0]+8,2);
		buf[2]='\0';
		tm1.tm_mday=tm2.tm_mday=atoi(buf);
		strncpy(buf,arg[1],2);
		buf[2]='\0';
		tm1.tm_hour=atoi(buf);
		strncpy(buf,arg[2],2);
		buf[2]='\0';
		tm2.tm_hour=atoi(buf);
		strncpy(buf,arg[1]+3,2);
		buf[2]='\0';
		tm1.tm_min=atoi(buf);
		strncpy(buf,arg[2]+3,2);
		buf[2]='\0';
		tm2.tm_min=atoi(buf);
		tm1.tm_sec=0;
		tm2.tm_sec=0;
		tm1.tm_isdst=tm2.tm_isdst=0;
		t1=mktime(&tm1);
		t2=mktime(&tm2);
#if DEBUG
		printf("%ld",t1);
		printf("%ld",t2);
#endif
		sprintf(path,"%s.log",arg[0]);
		if(get_extrema_temp(path,t1,t2,&max_temp,&min_temp,&ave_temp)==0)
		{
			printf("[%g,%g,%g]",max_temp,min_temp,ave_temp);
		}
		else
		{
			printf("[\"ERROR\",\"ERROR\",\"ERROR\"]");
		}
	}
	return 0;
}
예제 #8
0
int main(int argc, char** argv) {
    int j, nowrite, rfds, fdrr = 0;
    int in[INPUT_DEVICE_COUNT]; /* fds */
    struct pollfd pin[INPUT_DEVICE_COUNT];
    struct input_event e, je;
    struct uinput_user_dev uidev;


    (void)argc;
    (void)argv;

    (void)get_key_num;

    /* Open required input devices */
    #define H_CONFIGURE_EVENTS
    #include "config.h"

    /* Now setup poll structure */
    for (j = 0; j < INPUT_DEVICE_COUNT; j++)
    {
        pin[j].fd = in[j];
        pin[j].events = POLLIN;
    }

    if(signal(SIGINT, free_js) == SIG_ERR) {
        printf("SIGINT handler registration failed\n");
        return 1;
    }

    for(j = 0; j < JOYCOUNT; j++) {
        /* Memset because we are already setting the absmax/absmin */
        memset(&uidev, '\0', sizeof(struct uinput_user_dev));
        js[j] = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
        if (js[j] < 0) {
            perror("(NOT FATAL YET) Could not open: /dev/uinput");
            js[j] = open("/dev/input/uinput", O_WRONLY | O_NONBLOCK);
            if (js[j] < 0) {
                perror("(FATAL) Could not open: /dev/input/uinput");
                return 1;
            }
        }


        printf("js[j] %d\n", js[j]);
        #define H_CONFIGURE_JOYSTICKS
        #include "config.h"
        scan_device("/dev/input/event8", js[j]);

        /* Allocate device info */
        snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "key2joy:%d", j);

        uidev.id.bustype = BUS_USB;
        uidev.id.vendor  = 0x42;
        uidev.id.product = 0xbebe;
        uidev.id.version = 1;

        if (write(js[j], &uidev, sizeof(uidev)) < 0) {
            perror("write");
            return EXIT_FAILURE;
        }

        if (ioctl(js[j], UI_DEV_CREATE)) {
            perror("ioctl create");
            return EXIT_FAILURE;
        }
    }

    /* Do it! */
    while (1) {
        printf("Entering poll..\n");
        /* Any data available? */
        if ((rfds = poll(pin, INPUT_DEVICE_COUNT, -1)) < 0) {
            /* Interrupted by signal */
            if (errno == EINTR)
                continue;
            perror("poll");
            return EXIT_FAILURE;
        }
        printf("Leaving poll..\n");

        /* Round-robin check readers */
        while (rfds) {
            if (pin[fdrr].revents & POLLIN) {
                printf("Device %d has input\n", fdrr);
                /* XXX: Need checking for complete read? */
                if (read(in[fdrr], &e, sizeof(struct input_event)) < 0) {
                    /* Interrupted by singal? Retry */
                    if (errno == EINTR)
                        continue;

#if 0
                    if (errno == EWOULDBLOCK || errno == EAGAIN) {
                        printf("poll tells us device %d is readable.. it is not\n", fdrr);
                        rfds -= 1;
                        fdrr = (fdrr + 1) % INPUT_DEVICE_COUNT;
                        continue;
                    }
#endif

                    err(EXIT_FAILURE, "reading input device nr. %d failed", fdrr);
                }

                printf("Event: (Type: %d, Code: %d, Value %d)\n", e.type, e.code, e.value);
            } else {
                /* Update poll read mechanism */
                fdrr = (fdrr + 1) % INPUT_DEVICE_COUNT;
                continue;
            }

            /* Now handle received event */
            memset(&je, '\0', sizeof(struct input_event));
            nowrite = 1;
            j = 0;

            je.type = e.type;
            je.code = e.code;
            je.value = e.value;
            nowrite = 0;
            /*
            #define H_JOYMAP
            #include "config.h"
            */

            /* Update poll read mechanism */
            fdrr = (fdrr + 1) % INPUT_DEVICE_COUNT;
            rfds -= 1;

            if (nowrite == 0) {
                printf("Writing %d to %d\n", e.code, j);
                if(write(js[j], &je, sizeof(struct input_event)) < 0) {
                    perror("Event write event");
                    return EXIT_FAILURE;
                }
            }

            /* Synchronisation events */
            if (e.type == EV_SYN) {
                memset(&je, '\0', sizeof(struct input_event));
                printf("SYN event\n");

                je.type = EV_SYN;
                je.code = 0;
                je.value = 0;

                if (write(js[j], &je, sizeof(struct input_event)) < 0) {
                    perror("SYN write event");
                    return EXIT_FAILURE;
                }
            }

        } /* End reader check loop */

    } /* End main loop */

    return 0;
}