pcipywrap.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef PCIPYWRAP_H
  2. #define PCIPYWRAP_H
  3. #include "pci.h"
  4. #include "error.h"
  5. #include <Python.h>
  6. typedef struct {
  7. void* ctx;
  8. int shared;
  9. } Pcipywrap;
  10. /*!
  11. * \brief Redirect pcilib standart log stream to exeption text.
  12. * Logger will accumulate errors untill get message, starts with "#E".
  13. * After that, logger will write last error, and all accumulated errors
  14. * to Python exeption text
  15. */
  16. void __redirect_logs_to_exeption();
  17. /*!
  18. * \brief Wraps for pcilib_open function.
  19. * \param[in] fpga_device path to the device file [/dev/fpga0]
  20. * \param[in] model specifies the model of hardware, autodetected if NULL is passed
  21. * \return Pointer to pcilib_t, created by pcilib_open; NULL with exeption text, if failed.
  22. */
  23. PyObject* create_pcilib_instance(const char *fpga_device, const char *model);
  24. Pcipywrap *new_Pcipywrap(const char* fpga_device, const char* model);
  25. Pcipywrap *create_Pcipywrap(PyObject* ctx);
  26. void delete_Pcipywrap(Pcipywrap *self);
  27. /*!
  28. * \brief Reads register value. Wrap for pcilib_read_register function.
  29. * \param[in] regname the name of the register
  30. * \param[in] bank should specify the bank name if register with the same name may occur in multiple banks, NULL otherwise
  31. * \return register value, can be integer or float type; NULL with exeption text, if failed.
  32. */
  33. PyObject* Pcipywrap_read_register(Pcipywrap *self, const char *regname, const char *bank);
  34. /*!
  35. * \brief Writes value to register. Wrap for pcilib_write_register function.
  36. * \param[in] val Register value, that needs to be set. Can be int, float or string.
  37. * \param[in] regname the name of the register
  38. * \param[in] bank should specify the bank name if register with the same name may occur in multiple banks, NULL otherwise
  39. * \return 1, serialized to PyObject or NULL with exeption text, if failed.
  40. */
  41. PyObject* Pcipywrap_write_register(Pcipywrap *self, PyObject* val, const char *regname, const char *bank);
  42. /*!
  43. * \brief Reads propety value. Wrap for pcilib_get_property function.
  44. * \param[in] prop property name (full name including path)
  45. * \return property value, can be integer or float type; NULL with exeption text, if failed.
  46. */
  47. PyObject* Pcipywrap_get_property(Pcipywrap *self, const char *prop);
  48. /*!
  49. * \brief Writes value to property. Wrap for pcilib_set_property function.
  50. * \param[in] prop property name (full name including path)
  51. * \param[in] val Property value, that needs to be set. Can be int, float or string.
  52. * \return 1, serialized to PyObject or NULL with exeption text, if failed.
  53. */
  54. PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *prop);
  55. PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank);
  56. PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank);
  57. PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch);
  58. #endif /* PCIPYWRAP_H */