Ejemplo n.º 1
0
static int
do_cmd_ready(Camera *camera, GPContext *context)
{
	int r;
	struct tf_packet reply;

	r = send_cmd_ready(camera,context);
	if(r < 0)
		return r;

	r = get_tf_packet(camera, &reply, context);
	if(r < 0)
		return r;

	switch (get_u32(&reply.cmd)) {
	case SUCCESS:
		gp_log (GP_LOG_DEBUG, "topfield", "Device reports ready.\n");
		return GP_OK;

	case FAIL:
		gp_log (GP_LOG_ERROR, "topfield", "ERROR: Device reports %s\n", decode_error(&reply));
		break;

	default:
		gp_log (GP_LOG_ERROR, "topfield", "ERROR: Unhandled packet\n");
		return GP_ERROR_IO;
	}
	return GP_OK;
}
Ejemplo n.º 2
0
int do_cmd_ready(int fd)
{
    int r;

    r = send_cmd_ready(fd);
    if(r < 0)
    {
        return -EPROTO;
    }

    r = get_tf_packet(fd, &reply);
    if(r < 0)
    {
        return -EPROTO;
    }

    switch (get_u32(&reply.cmd))
    {
        case SUCCESS:
            printf("Device reports ready.\n");
            return 0;
            break;

        case FAIL:
            fprintf(stderr, "ERROR: Device reports %s\n",
                    decode_error(&reply));
            get_u32(&reply.data);
            break;

        default:
            fprintf(stderr, "ERROR: Unhandled packet\n");
            return -1;
    }
    return -EPROTO;
}