Skip to content

Commit

Permalink
more Py3 fixes before release v1.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
atlas0fd00m committed Sep 1, 2020
1 parent 067990a commit fc5abec
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions rfcat_server
Original file line number Diff line number Diff line change
Expand Up @@ -688,15 +688,15 @@ class CC1111NIC_Server(cmd.Cmd):
'''
* save_config <filename> - save the radio configuration to a file you specify
'''
file(line, "wb").write(repr(self.nic.getRadioConfig()))
open(line, "wb").write(repr(self.nic.getRadioConfig()))


def do_load_config(self, line):
'''
* load_config
(be very cautious! the firmware expects certain things like return-to-RX, and no RX-timeout, etc..)
'''
config = file(line, "rb").read()
config = open(line, "rb").read()
self.nic.setModeIDLE()
print("loading config from bytes: %s" % repr(config))
self.setRadioConfig(config)
Expand Down
2 changes: 1 addition & 1 deletion rflib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _doSpecAn(self, centfreq, inc, count):
freq, fbytes = self.getFreq()
delta = self.getMdmChanSpc()

self.send(APP_NIC, RFCAT_START_SPECAN, "%c" % (count) )
self.send(APP_NIC, RFCAT_START_SPECAN, b"%c" % (count) )
return freq, delta

def _stopSpecAn(self):
Expand Down
6 changes: 3 additions & 3 deletions rflib/cc111Xhparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ def parseLines(lines):

if __name__ == '__main__':
defs = {}
defs.update(parseLines(file('../includes/cc1110-ext.h')))
defs.update(parseLines(file('../includes/cc1111.h')))
defs.update(parseLines(file('/usr/share/sdcc/include/mcs51/cc1110.h')))
defs.update(parseLines(open('../includes/cc1110-ext.h')))
defs.update(parseLines(open('../includes/cc1111.h')))
defs.update(parseLines(open('/usr/share/sdcc/include/mcs51/cc1110.h')))

skeys = list(defs.keys())
skeys.sort()
Expand Down
7 changes: 4 additions & 3 deletions rflib/ccspecan.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import numpy
import threading
import rflib
from rflib.bits import ord23
from .bits import correctbytes
# import cPickle in Python 2 instead of pickle in Python 3
if sys.version_info < (3,):
Expand Down Expand Up @@ -74,7 +75,7 @@ def run(self):

if type(self._data) == list:
for rssi_values, timestamp in self._data:
rssi_values = [ (old_div((ord(x)^0x80),2))-88 for x in rssi_values[4:] ]
rssi_values = [ (old_div((ord23(x)^0x80),2))-88 for x in rssi_values[4:] ]
# since we are not accessing the dongle, we need some sort of delay
time.sleep(self._delay)
frequency_axis = numpy.linspace(self._low_frequency, self._high_frequency, num=len(rssi_values), endpoint=True)
Expand All @@ -86,7 +87,7 @@ def run(self):
while not self._stop:
try:
rssi_values, timestamp = self._data.recv(APP_SPECAN, SPECAN_QUEUE, 10000)
rssi_values = [ (old_div((ord(x)^0x80),2))-88 for x in rssi_values ]
rssi_values = [ (old_div((ord23(x)^0x80),2))-88 for x in rssi_values ]
frequency_axis = numpy.linspace(self._low_frequency, self._high_frequency, num=len(rssi_values), endpoint=True)

self._new_frame_callback(numpy.copy(frequency_axis), numpy.copy(rssi_values))
Expand Down Expand Up @@ -359,7 +360,7 @@ def _open_data(self, data):
numChans = int(old_div((self._high_freq-self._low_freq), self._spacing))
data._doSpecAn(freq, spc, numChans)
else:
data = pickle.load(file(data,'rb'))
data = pickle.load(open(data,'rb'))
if data is None:
raise Exception('Data not found')
return data
Expand Down
2 changes: 1 addition & 1 deletion rflib/chipcon_nic.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def strobeModeReturn(self, marcstate=None):
#if marcstate is None:
#marcstate = self.radiocfg.marcstate
#if self._debug: print("MARCSTATE: %x returning to %x" % (marcstate, MARC_STATE_MAPPINGS[marcstate][2]) )
#self.poke(X_RFST, "%c"%MARC_STATE_MAPPINGS[marcstate][2])
#self.poke(X_RFST, b"%c"%MARC_STATE_MAPPINGS[marcstate][2])
self.poke(X_RFST, b"%c" % self._rfmode)


Expand Down

0 comments on commit fc5abec

Please sign in to comment.