1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#ifndef PCIPYWRAP_H
#define PCIPYWRAP_H
#include "pci.h"
#include "error.h"
#include <Python.h>
#include "config.h"
#include "py.h"
#include "pci.h"
#include "pcilib.h"
typedef struct {
char** names;
int names_size;
void* ctx;
struct pcilib_py_s *py;
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);
/*!
* \brief Wrap for pcilib_get_register_list function.
* \param bank [in] bank - if set, only register within the specified bank will be returned
* \return list of registers, serialized to Python object
*/
PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank);
/*!
* \brief Returns the information about the specified register. Wrap for pcilib_get_register_info
* \param[in] reg the name of the register
* \param[in] bank indicates the bank where to look for register, autodetected if NULL is passed
* \return information about the specified register, serialized to Python object
*/
PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank);
/*!
* \brief Returns the list of properties available under the specified path. Wrap for pcilib_get_property_list
* \param[in] branch path or NULL to return the top-level properties
* \return the list of the properties, serialized to Python object
*/
PyObject* Pcipywrap_get_property_list(Pcipywrap *self, const char* branch);
/*!
* \brief Reads data from DMA until timeout is hit, a full DMA packet is read, or the specified number of bytes are read.
* Wrap for pcilib_read_dma.
* \param dma ID of DMA engine
* \param size specifies how many bytes should be read
* \return DMA data, serialierd to Python bytearray
* \warning This function has not been tested.
* \todo Test this fucntion
*/
PyObject* Pcipywrap_read_dma(Pcipywrap *self, unsigned char dma, size_t size);
/*!
* \brief Wrap for pcilib_lock_global
* \return 1, serialized to PyObject or NULL with exeption text, if failed.
*/
PyObject* Pcipywrap_lock_global(Pcipywrap *self);
/*!
* \brief Wrap for pcilib_unlock_global
*/
void Pcipywrap_unlock_global(Pcipywrap *self);
/*!
* \brief Wrap for pcilib_lock
* \param[in] lock_id lock identificator
* \warning This function should be called only under Python standart threading lock.
* Otherwise it will stuck with more than 1 threads. See /xml/test/test_prop_mt.py
* for example.
* \return 1, serialized to PyObject or NULL with exeption text, if failed.
*/
PyObject* Pcipywrap_lock(Pcipywrap *self, const char *lock_id);
/*!
* \brief This function will try to take a lock for the mutex pointed by
* lockfunction to acquire a lock, but that returns immediatly if the lock can't be
* acquired on first try. Wrap for pcilib_try_lock.
* \param[in] lock_id lock id
* \return 1, serialized to PyObject or NULL with exeption text, if failed.
*/
PyObject* Pcipywrap_try_lock(Pcipywrap *self, const char *lock_id);
/*!
* \brief This function unlocks the lock with specified id. Wrap for pcilib_unlock.
* \param[in] lock_id lock id
* \return 1, serialized to PyObject or NULL with exeption text, if failed.
*/
PyObject* Pcipywrap_unlock(Pcipywrap *self, const char *lock_id);
/*!
* \brief Returns list with information about aviable scripts
* \return list with information about scripts, aviable in model
*/
PyObject* Pcipywrap_get_scripts_list(Pcipywrap *self);
/*!
* \brief Runs script with specified name
* \param script_name script name (with extension); name could be found by
* Pcipywrap_get_scripts_list fucntion
* \param[in] value input value
* \return value returned by script
*/
PyObject* Pcipywrap_run_script(Pcipywrap *self, const char* script_name, PyObject* value);
#endif /* PCIPYWRAP_H */
|