diff options
author | Vasilii Chernov <vchernov@inr.ru> | 2016-02-17 17:20:25 +0100 |
---|---|---|
committer | Vasilii Chernov <vchernov@inr.ru> | 2016-02-17 17:20:25 +0100 |
commit | 9a9ffd5594a5d27bbecf6160de2c33d44870f5bd (patch) | |
tree | 1fbe5bd017cdc2e81fd7a6a45669d64276438289 /pywrap/pcipywrap.h | |
parent | 3269dce32883e14b45cc490a0cc0037b4c808a68 (diff) | |
download | pcitool-9a9ffd5594a5d27bbecf6160de2c33d44870f5bd.tar.gz pcitool-9a9ffd5594a5d27bbecf6160de2c33d44870f5bd.tar.bz2 pcitool-9a9ffd5594a5d27bbecf6160de2c33d44870f5bd.tar.xz pcitool-9a9ffd5594a5d27bbecf6160de2c33d44870f5bd.zip |
Refactor pcipywrap to object
Diffstat (limited to 'pywrap/pcipywrap.h')
-rw-r--r-- | pywrap/pcipywrap.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/pywrap/pcipywrap.h b/pywrap/pcipywrap.h new file mode 100644 index 0000000..8389445 --- /dev/null +++ b/pywrap/pcipywrap.h @@ -0,0 +1,68 @@ +#ifndef PCIPYWRAP_H +#define PCIPYWRAP_H + +#include "pci.h" +#include "error.h" +#include <Python.h> + +typedef struct { + void* ctx; + int shared; +} Pcipywrap; + +/*! + * \brief Redirect pcilib standart log stream to exeption text. + * Logger will accumulate errors untill get message, starts with "#E". + * After that, logger will write last error, and all accumulated errors + * to Python exeption text + */ +void __redirect_logs_to_exeption(); + +/*! + * \brief Wraps for pcilib_open function. + * \param[in] fpga_device path to the device file [/dev/fpga0] + * \param[in] model specifies the model of hardware, autodetected if NULL is passed + * \return Pointer to pcilib_t, created by pcilib_open; NULL with exeption text, if failed. + */ +PyObject* create_pcilib_instance(const char *fpga_device, const char *model); + +Pcipywrap *new_Pcipywrap(const char* fpga_device, const char* model); +Pcipywrap *create_Pcipywrap(PyObject* ctx); +void delete_Pcipywrap(Pcipywrap *self); + +/*! + * \brief Reads register value. Wrap for pcilib_read_register function. + * \param[in] regname the name of the register + * \param[in] bank should specify the bank name if register with the same name may occur in multiple banks, NULL otherwise + * \return register value, can be integer or float type; NULL with exeption text, if failed. + */ +PyObject* Pcipywrap_read_register(Pcipywrap *self, const char *regname, const char *bank); + +/*! + * \brief Writes value to register. Wrap for pcilib_write_register function. + * \param[in] val Register value, that needs to be set. Can be int, float or string. + * \param[in] regname the name of the register + * \param[in] bank should specify the bank name if register with the same name may occur in multiple banks, NULL otherwise + * \return 1, serialized to PyObject or NULL with exeption text, if failed. + */ +PyObject* Pcipywrap_write_register(Pcipywrap *self, PyObject* val, const char *regname, const char *bank); + +/*! + * \brief Reads propety value. Wrap for pcilib_get_property function. + * \param[in] prop property name (full name including path) + * \return property value, can be integer or float type; NULL with exeption text, if failed. + */ +PyObject* Pcipywrap_get_property(Pcipywrap *self, const char *prop); + +/*! + * \brief Writes value to property. Wrap for pcilib_set_property function. + * \param[in] prop property name (full name including path) + * \param[in] val Property value, that needs to be set. Can be int, float or string. + * \return 1, serialized to PyObject or NULL with exeption text, if failed. + */ +PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *prop); +PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank); +PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank); +PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch); + +#endif /* PCIPYWRAP_H */ |