示例#1
0
文件: DLL_Test.cpp 项目: CCJY/ACE
int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("DLL_Test"));

  int retval = 0;

// Protection against this test being run on platforms not supporting Dlls.
#if defined(ACE_HAS_DYNAMIC_LINKING)

  ACE_DLL dll;

  retval += basic_test (dll);

  retval += dynamic_cast_test (dll);

  retval += handle_test (dll);

  // Call close here so that any errors make it into the log.
  dll.close ();

#else
  ACE_ERROR ((LM_INFO,
              ACE_TEXT ("Dynamically Linkable Libraries not supported on this platform\n")));
#endif /* ACE_HAS_DYNAMIC_LINKING */

  ACE_END_TEST;
  return retval == 0 ? 0 : 1;
}
示例#2
0
static int pseudo_device_ioctl(struct inode *inode, struct file *file,
                               unsigned int cmd, unsigned long arg)
{

    switch (cmd)
    {

    case RD_INIT:
        down_interruptible(&mutex);
        handle_init();
        up(&mutex);
        break;
    case RD_CREAT:
        down_interruptible(&mutex);
        handle_creat_call(arg);
        up(&mutex);
        break;

    case RD_MKDIR:
        down_interruptible(&mutex);
        handle_mkdir_call(arg);
        up(&mutex);
        break;

    case RD_OPEN:
        down_interruptible(&mutex);
        handle_open_call(arg);
        up(&mutex);
        break;

    case RD_CLOSE:
        down_interruptible(&mutex);
        handle_close_call(arg);
        up(&mutex);
        break;

    case RD_READ:
        down_interruptible(&mutex);
        handle_read_call(arg);
        up(&mutex);
        break;

    case RD_WRITE:
        down_interruptible(&mutex);
        handle_write_call(arg);
        up(&mutex);
        break;

    case RD_SEEK:
        down_interruptible(&mutex);
        handle_seek_call(arg);
        up(&mutex);
        break;

    case RD_READDIR:
        down_interruptible(&mutex);
        handle_readdir_call(arg);
        up(&mutex);
        break;

    case RD_UNLINK:
        down_interruptible(&mutex);
        handle_unlink_call(arg);
        up(&mutex);
        break;

    case RD_TEST:
        down_interruptible(&mutex);
        handle_test(arg);
        up(&mutex);        

    default:
        return -EINVAL;
        break;
    }

    return 0;
}
示例#3
0
int main ( int argc, char **argv )
{
    char *dev_serial = getenv("BC_DEV");
    if(dev_serial == NULL) {
        dev_serial = "/dev/ttyACM0";
    }

    fd = open ( dev_serial, O_RDWR | O_NOCTTY );
    if ( fd < 0 )
    {
        // TODO: THROW error
        fprintf(stderr, "Failed to open device: %s\n", dev_serial);
        return EXIT_FAILURE;
    }
    // save status port settings.
    tcgetattr ( fd, &oldtio );

    // Setup the serial port.
    struct termios newtio = { 0, };
    newtio.c_cflag     = baudrate | CS8 | CREAD | PARODD;
    newtio.c_iflag     = 0;
    newtio.c_oflag     = 0;
    newtio.c_lflag     = 0;       //ICANON;
    newtio.c_cc[VMIN]  = 1;
    newtio.c_cc[VTIME] = 0;
    tcflush ( fd, TCIFLUSH | TCIOFLUSH );
    tcsetattr ( fd, TCSANOW, &newtio );

    if( argc == 1) {
        printf_information();

    } else if (argc > 1 ) {
        const char *command = argv[1]; 
        // Alarm 
        if(strcasecmp(command, "alarm")  == 0 ) {
           handle_alarm( argc-2, &argv[2]); 
        // Initialize
        } else if (strcasecmp(command, "init") == 0) {
            handle_init();
        }
        else if(strcasecmp(command, "temperature")  == 0 ) {
            handle_temperature();
        }
        else if(strcasecmp(command, "drift")  == 0 ) {
            handle_drift();
        }
        else if ( strcasecmp(command, "brightness") == 0) {
            handle_brightness(argc-2, &argv[2]);
        } else if ( strcasecmp(command, "test") == 0){
            handle_test();
        }

    }






    sync(fd);
   // tcsetattr ( fd, TCSANOW, &oldtio );
    close(fd);
    return EXIT_SUCCESS;
}