Ejemplo n.º 1
0
/**
 * @param void
 *
 * @brief Open at command socket.
 *
 * @DESCRIPTION
 *
 *******************************************************************/
ATCODEC_RET ardrone_at_open ( void )
{
   if ( !at_init )
      return ATCODEC_FALSE;

   return host_open()==AT_CODEC_OPEN_OK?ATCODEC_TRUE:ATCODEC_FALSE;
}
Ejemplo n.º 2
0
static void set_control(struct sscape_info *devc, int ctrl, int value)
{
	host_open(devc);
	host_command3(devc, CMD_SET_CONTROL, ctrl, value);
	if (host_read(devc) != CMD_ACK)
	{
		/* printk( "SNDSCAPE: Setting control (%d) failed\n",  ctrl); */
	}
	host_close(devc);
}
Ejemplo n.º 3
0
static void set_mt32(struct sscape_info *devc, int value)
{
	host_open(devc);
	host_command2(devc, CMD_SET_MT32, value ? 1 : 0);
	if (host_read(devc) != CMD_ACK)
	{
		/* printk( "SNDSCAPE: Setting MT32 mode failed\n"); */
	}
	host_close(devc);
}
Ejemplo n.º 4
0
//Copy file operation
int copy_file() {
    int in_fd;
    FILE* out_fd;
    int fsize = 0;
    char file_name[MAX_BUFFER_SIZE];

    /* Get the file name to copy to 
     * This will activate our hook on the invalid opcode in the python script.
     */

    host_get_file_name(agent_buffer, sizeof(agent_buffer));
    strncpy(file_name,agent_buffer,sizeof(file_name));

    /* Open file on the host. */

    if ((in_fd = host_open(file_name)) == -1){
        fprintf(stderr, "Error opening file on host\n");
        return 2;
    }

    /* Read file from the host and output it on stdout. */
    if ((out_fd = fopen(file_name, "wb")) == NULL){
        fprintf(stderr, "Error opening file %s on guest for writing\n", file_name);
        return 3;
    }
     
    /* Data read loop */
    while (1) {
        int ret = host_read(in_fd, agent_buffer, sizeof(agent_buffer));
        if (ret == -1) {
            fprintf(stderr, "Error reading from host file\n");
            return 4;
        }
        else if (ret == 0) {
            break;
        }

        if (fwrite(agent_buffer, 1, ret, out_fd) != ret) {
            fprintf(stderr, "Error writing to file on guest\n");
            return 5;
        }

        fsize += ret;
    }

    /* Don't forget to close the file on the host. */
    host_close(in_fd);
    fclose(out_fd);

    fprintf(stderr, "File %s of size %d was successfully transferred\n", file_name, fsize);
    return 0;

}
Ejemplo n.º 5
0
static int
get_board_type (struct sscape_info *devc)
{
  int             tmp;

  host_open (devc);
  if (!host_command1 (devc, CMD_GET_BOARD_TYPE))
    tmp = -1;
  else
    tmp = host_read (devc);
  host_close (devc);
  return tmp;
}
Ejemplo n.º 6
0
static int
named_pipe_alloc(const char *path)
{
	int fd;

	if (mkfifo(path, NUSE_DEFAULT_PIPE_PRIV) < 0) {
		perror ("mkfifo");
		return -1;
	}

	if ((fd = host_open(path, O_RDWR)) < 0) {
		perror ("open");
		return -1;
	}

	return fd;
}