-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.py
154 lines (102 loc) · 3.78 KB
/
setup.py
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
# -*- coding: utf-8 -*-
import os
from distutils.core import setup
from distutils.command.build import build
from distutils.command.install import install
from PyRedPitaya import __version__
# If we want to overrid the build processe
# For example, to compile de libmonitor and install it
# Install libmonitor only for redpitaya, i.e. when
build_dir = "monitor/"
def compile_libmonitor():
cwd = os.getcwd() # get current directory
try:
os.chdir(build_dir)
os.system("make clean")
os.system("make all")
finally:
os.chdir(cwd)
def install_libmonitor(prefix=''):
cwd = os.getcwd() # get current directory
try:
os.chdir(build_dir)
os.system("make install INSTALL_DIR={prefix}".format(prefix=prefix))
finally:
os.chdir(cwd)
class lib_build(build):
def run(self):
compile_libmonitor()
build.run(self)
class lib_install(install):
def run(self):
compile_libmonitor()
install_libmonitor(self.prefix)
# install.run(self)
cmdclass = {}
cmdclass['lib_build'] = lib_build
cmdclass['lib_install'] = lib_install
long_description = """\
Overview
========
This package provides a library to access the Red Pitaya registers. This library consist of a C library (libmonitor.c) and a ctypes interface on the Python side.
An object oriented interface to the different application (scope, generator, PID, AMS, ...) is provided. This interface is implemented using Python properties (see usage below) and can quickly be extended to your own application.
An rpyc server is used in order to communicate with your computer. The interface is the same on the computer as the one on the board.
Installation
============
The process to install PyRedPitaya on the board requires the installation of Python first. See <https://github.com/clade/RedPitaya/tree/master/python>.
To install PyRedPitaya on the computer download the package and run the command::
python setup.py install
or use easy_install::
easy_install PyRedPitaya
Usage
=====
You need to have Python installed on you Red Pitaya.
Interactive Python
------------------
Logging onto the redpitaya using ssh, one can start the ipython shell and run :
.. code ::
from PyRedPitaya.board import RedPitaya
redpitaya = RedPitaya()
print redpitaya.ams.temp # Read property
redpitaya.hk.led = 0b10101010 # Write property
Remote access
-------------
You need to install the PyRedPitaya package on your PC as well as Rpyc:
..code::
rpyc_server
On the computer (replace REDPITAYA_IP by the string containing the IP address) :
.. code::
from rpyc import connect
from PyRedPitaya.pc import RedPitaya
conn = connect(REDPITAYA_IP, port=18861)
redpitaya = RedPitaya(conn)
print redpitaya.ams.temp # Read property
redpitaya.hk.led = 0b10101010 # Write property
from time import sleep
from pylab import *
redpitaya.scope.setup(frequency = 100, trigger_source=1)
sleep(100E-3)
plot(redpitaya.scope.times, redpitaya.scope.data_ch1)
show()
Background script
-----------------
Example to log the FPGA temperature. Copy the following script in a file, make it exacutable and run it in the background.
.. code::
#!/usr/bin/python
from PyRedPitaya.board import RedPitaya
from time import sleep
red_pitaya = RedPitaya()
with open('/tmp/log.txt', 'a') as f:
while True:
f.write(str(red_pitaya.ams.temp)+'\n')
sleep(1)
"""
setup(name='PyRedPitaya',
version=__version__,
description='Python utilities for redpitaya',
author=u'Pierre Cladé',
author_email='[email protected]',
packages=['PyRedPitaya', 'PyRedPitaya.enum'],
install_requires=['myhdl', 'rpyc', 'cached_property', 'numpy'],
cmdclass=cmdclass,
)