예제 #1
0
int tuntap_close(struct net_device *net_dev)
{
	shutdownDevice(net_dev);
	if(net_dev->priv) LocalFree(net_dev->priv);
	net_dev->priv = NULL;
	return 0;
}
예제 #2
0
파일: rfs.c 프로젝트: karajrish/OS
//============= TESTING APPLICATION USING THESE FS CALLS ==============
// Menu driven testing application for creation of fs, 
// and all file and directory related operations
int main(int argc, char** argv){
	int fd = openDevice(0);
	init_FS(fd);
	makeDir(fd, "Folder 1", 1, 1, 1);
	makeDir(fd, "Folder 2", 1, 1, 1);
	makeDir(fd, "Folder 3", 1, 1, 1);
	removeDir(fd, "Folder 2");
	int dirhandle = openDir(fd, "Folder 1");
	closeDir(dirhandle);
	shutdownDevice(0);
}
예제 #3
0
////////////////////////////////////////////////////////////////////////////////
///
/// @fn main(int argc, char **argv)
///
///  Main entry point for program execution
///
/// @param argc Count of input arguments
/// @param argv Pointer to array of argument arrays
///
/// @return 0 on success
///
////////////////////////////////////////////////////////////////////////////////
int main(int argc, char **argv) {
  // Video parameters
  char videoDevice[] = "/dev/video0";
  int frameWidth = 320;
  int frameHeight = 240;
  float frameRate = 30.0f;
  char format[] = FORMAT_H264;

  // Configure getopt parameters
  int arg = 0;
  int argumentIndex = 0;
  const char abbreviations[] = "dhfs";
  const struct option full[] = {
    {"device", required_argument, NULL, 'd'},
    {"help", no_argument, NULL, 'h'},
    {"format", no_argument, NULL, 'f'},
    {"frame-size", no_argument, NULL, 's'},
    {"available", no_argument, NULL, 'a'}
  };

  // Register signal handler for interrupts
  signal(SIGINT, signalHandler);

  for(;;) {
    arg = getopt_long(argc, argv, abbreviations, full, &argumentIndex);

    // Getopt returns -1 when there are no more arguments left to parse
    if (arg == -1) {
      break;
    }

    switch(arg) {
      case 'd':
        printf("Using device %s\n", optarg);
        break;

      case 'h':
        printHelp();
        break;

      case 'f':
        printf("Using format %s\n", optarg);
        break;

      case 's':
        printf("Using frame size %s\n", optarg);
        break;

      case 'a':
        printf("Available video formats\n");
        printf("Available video sizes\n");
        return 0;

      default:
        break;
    }
  }

  // Begin camera capture
  fprintf(stdout, "Initializing camera capture.\n"
      "Capture Device: %s\n"
      "Video Format: %s\n"
      "Video Size: %i x %i\n"
      "Frame Rate: %0.2f\n",
      videoDevice, format, frameWidth, frameHeight, frameRate);

  // Step 1: Open the device for capture and test for its existence
  int fileDescriptor = openDevice(videoDevice);
  if (fileDescriptor == -1) {
    return EXIT_FAILURE;
  }

  // Step 2: Configure device image format
  if (configureDevice(fileDescriptor, format, frameWidth, frameHeight) == -1 ) {
    return EXIT_FAILURE;
  }

  // Step 3: Capture frames from the device until SIGINT is received
  fprintf(stdout, "\nBeginning frame capture. Press `ctrl+c` to exit.\n\n");
  if (captureFrames(fileDescriptor) == -1) {
    return EXIT_FAILURE;
  }

  // Step 4: Cleanup and exit
  if (shutdownDevice(fileDescriptor) == -1) {
    return EXIT_FAILURE;
  }

  fprintf(stdout, "Successfully Exiting.\n");
  return EXIT_SUCCESS;
}