forked from deelonleem/windfreak-pycontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
windfreak_control3.py
107 lines (70 loc) · 2.16 KB
/
windfreak_control3.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
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 18 17:32:49 2014
@author: Nick Lewty
Python software for communicating with windfreak USB2
Windfreak USB2 is a $250 PLL that can set frequencies between 34.4MHz - 4.4GHz
Details about windfreak can be found at this web address
http://www.windfreaktech.com/
Code fairly simple hence no comments in the code
"""
import serial
class windfreakusb2(object):
baudrate = 115200
def __init__(self, port):
self.serial = self._open_port(port)
def _open_port(self, port):
ser = serial.Serial(port, self.baudrate, timeout=1)
ser.readline()
ser.timeout = 1
return ser
def _serial_write(self, string):
self.serial.write(bytes(string + '\n', 'utf-8'))
def _serial_read(self):
msg_string = self.serial.readline()
# Remove any linefeeds etc
msg_string = msg_string.rstrip().decode('utf-8')
return msg_string
def get_freq(self):
self._serial_write('f?')
return self._serial_read()
def rf_on(self):
self._serial_write('o1')
return self._serial_read()
def rf_off(self):
self._serial_write('o0')
return self._serial_read()
def rf_power_low(self):
self._serial_write('h0')
def rf_power_high(self):
self._serial_write('h1')
def set_pulse_mode(self,value):
self._serial_write('j' + str(value))
def get_pulse_mode(self,value):
self._serial_write('j?')
return self._serial_read()
def get_power(self):
self._serial_write('a?')
return self._serial_read()
def set_freq(self,value):
self._serial_write('f' + str(value))
return self._serial_read()
def check_osci(self):
self._serial_write('p')
return self._serial_read()
def set_clock(self,value):
self._serial_write('x' + str(value))
return self._serial_read()
def get_clock(self):
self._serial_write('x?')
return self._serial_read()
def set_power(self,value):
self._serial_write('a' + str(value))
return self._serial_read()
def serial_number(self):
self._serial_write('+')
return self._serial_read()
if __name__=='__main__':
dev_addr='/dev/serial/by-id/usb-Windfreak_Synth_Windfreak_CDC_Serial_014571-if00'
dev=windfreakusb2(dev_addr)
dev.set_freq(100)