Tiny IIO Daemon Library

Dependents:  

tinyiiod.h

Committer:
mahphalke
Date:
11 months ago
Revision:
2:2119a523fbbc
Parent:
1:6cb62c8c58d6

File content as of revision 2:2119a523fbbc:

/***************************************************************************//**
 *   @file    tinyiiod.h
 *   @brief   Tiny IIO Daemon Library headers
 *   @author  Paul Cercueil <paul.cercueil@analog.com>
********************************************************************************
 * Copyright (c) 2016, 2020 Analog Devices, Inc.
 *
 * All rights reserved.
 *
 * This software is proprietary to Analog Devices, Inc. and its licensors.
 * By using this software you agree to the terms of the associated
 * Analog Devices Software License Agreement.
*******************************************************************************/

#ifndef TINYIIOD_H
#define TINYIIOD_H

#include "compat.h"

#define TINYIIOD_VERSION_MAJOR 0
#define TINYIIOD_VERSION_MINOR 0
#define TINYIIOD_VERSION_PATCH 1
#define TINYIIOD_VERSION_GIT "v0.1"

#define IIOD_BUFFER_SIZE 0x1000

struct tinyiiod;

struct tinyiiod_ops {
	/* Read from the input stream */
	ssize_t (*read)(char *buf, size_t len);

	/* Write to the output stream */
	ssize_t (*write)(const char *buf, size_t len);
	ssize_t (*read_line)(char *buf, size_t len);

	ssize_t (*open_instance)();

	ssize_t (*close_instance)();

	ssize_t (*read_attr)(const char *device, const char *attr,
			     char *buf, size_t len, bool debug);
	ssize_t (*write_attr)(const char *device, const char *attr,
			      const char *buf, size_t len, bool debug);

	ssize_t (*ch_read_attr)(const char *device, const char *channel,
				bool ch_out, const char *attr, char *buf, size_t len);
	ssize_t (*ch_write_attr)(const char *device, const char *channel,
				 bool ch_out, const char *attr,
				 const char *buf, size_t len);

	int32_t (*open)(const char *device, size_t sample_size, uint32_t mask);
	int32_t (*close)(const char *device);

	ssize_t (*transfer_dev_to_mem)(const char *device, size_t bytes_count);
	ssize_t (*read_data)(const char *device, char *buf, size_t offset,
			     size_t bytes_count);

	ssize_t (*transfer_mem_to_dev)(const char *device, size_t bytes_count);
	ssize_t (*write_data)(const char *device, const char *buf, size_t offset,
			      size_t bytes_count);

	int32_t (*get_mask)(const char *device, uint32_t *mask);

	int32_t (*set_timeout)(uint32_t timeout);

	ssize_t (*get_xml)(char **outxml);
};

struct tinyiiod * tinyiiod_create(struct tinyiiod_ops *ops);
void tinyiiod_destroy(struct tinyiiod *iiod);
int32_t tinyiiod_read_command(struct tinyiiod *iiod);

#endif /* TINYIIOD_H */