Skip to content

Commit

Permalink
Fix for exit on windows and missing encoding for ascii text
Browse files Browse the repository at this point in the history
  • Loading branch information
consp committed Dec 29, 2019
1 parent 5892010 commit bcb6a8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/apim.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def launch_qt(self):
self.button_open = QPushButton("Open File ...")
self.button_open.clicked.connect(self.open_file)
self.button_exit = QPushButton("Exit")
self.button_exit.clicked.connect(exit)
self.button_exit.clicked.connect(sys.exit)

self.main_layout.addWidget(self.button_open)
self.main_layout.addWidget(self.button_exit)
Expand Down
21 changes: 5 additions & 16 deletions src/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,40 +384,27 @@ def format(self, ab1, ab2=None):

def combo_change(box, item, bitfieldblock, *args, **kwargs):
value = box.currentIndex()
print("changed to %d" % (value))
print(args)
print(kwargs)
print(bitfieldblock.text())
data = int(bitfieldblock.text(), 16)
bitdata = '{0:08b}'.format(data)
bitdata = bitdata[:item['bit']] + ("{0:0%db}" % (item['size'])).format(value) + bitdata[item['bit']+item['size']:]
data = int(bitdata, 2)
print(bitdata)
print(data)

bitfieldblock.setText("%02X" % (data))

def value_change(box, item, bitfieldblock, *args, **kwargs):
value = float(box.text())
print("changed to %d" % (value))
print(args)
print(kwargs)
print(bitfieldblock[0].text())
if len(bitfieldblock) > 1:
print(bitfieldblock[1].text())


if value > item['max']:
value = item['max']
elif value < item['min']:
value = item['min']
v = ((value - item['offset']) / item['multiplier'])
print(v)
box.setText("%.2f" % value)
data = int(bitfieldblock[0].text(), 16) if len(bitfieldblock) == 1 else int(bitfieldblock[0].text() + bitfieldblock[1].text(), 16)
bitdata = ('{0:0%db}' % (item['size'])).format(data)
bitdata = bitdata[:item['bit']] + ("{0:0%db}" % (item['size'])).format(int(v)) + bitdata[item['bit']+item['size']:]
data = int(bitdata, 2)
print(bitdata)
print(data)
string = "%04X" % (data)
if item['size'] > 8:
bitfieldblock[0].setText(string[:2])
Expand All @@ -427,7 +414,9 @@ def value_change(box, item, bitfieldblock, *args, **kwargs):


def ascii_change(box, item, bitfieldblock, *args, **kwargs):
pass
value = box.text()
#bitdata = bitdata[:item['bit']] + ("{0:0%db}" % (item['size'])).format(value) + bitdata[item['bit']+item['size']:]
bitfieldblock.setText("%02X" % (ord(value[0])))

class ItemEncoder(object):
items = []
Expand Down

0 comments on commit bcb6a8e

Please sign in to comment.