Product specifications

Source Code
25
if dbf > 16:
dbf = 16
vco = freq * dbf
EPDF = self._getEPDF(synth)
ncount = int(vco / EPDF)
frac = int((vco - ncount * float(EPDF)) / chan_spacing + 0.5)
mod = int(EPDF / float(chan_spacing) + 0.5)
if frac != 0 and mod != 0:
while not (frac & 1) and not (mod & 1):
frac /= 2
mod /= 2
else:
frac = 0
mod = 1
self.conn.open()
bytes = struct.pack('>B', 0x80 | synth)
self.conn.write(bytes)
old_bytes = self.conn.read(24)
checksum = self.conn.read(1)
#self._verify_checksum(old_bytes, checksum)
bytes = struct.pack('>B24s', 0x00 | synth,
self._pack_freq_registers(ncount, frac, mod,
dbf, old_bytes))
checksum = self._generate_checksum(bytes)
self.conn.write(bytes + checksum)
bytes = self.conn.read(1)
self.conn.close()
ack = struct.unpack('>B', bytes)[0]
return ack == ACK
def get_reference(self):
"""
Get reference frequency in MHz
"""
self.conn.open()
bytes = struct.pack('>B', 0x81)
self.conn.write(bytes)
bytes = self.conn.read(4)
checksum = self.conn.read(1)
self.conn.close()
#self._verify_checksum(bytes, checksum)
freq = struct.unpack('>I', bytes)[0]
return freq
def set_reference(self, freq):
"""
Set reference frequency in MHz
@param freq : frequency in MHz
@type freq : float
@return: True if success (bool)
"""
self.conn.open()
bytes = struct.pack('>BI', 0x01, freq)
checksum = self._generate_checksum(bytes)
self.conn.write(bytes + checksum)
bytes = self.conn.read(1)
self.conn.close()
ack = struct.unpack('>B', bytes)[0]
return ack == ACK
def get_rf_level(self, synth):
"""
Returns RF level in dBm
@param synth : synthesizer address, 0 or 8
@type synth : int