Example #1
0
 def convert_text(self, text, return_error=False, default_base="dec", **kwargs):
     try:
         value = text_to_int(text, default_base)
         error = ""
     except (ValueError, TypeError), e:
         value = None
         error = str(e)
Example #2
0
def trigger_dialog(event, segment_viewer, obj):
    possible_labels = segment_viewer.get_triggers()
    label = segment_viewer.get_trigger_label(obj.trigger_function)
    if label is None and obj.trigger_function:
        custom_value = "%04x" % obj.trigger_function
    else:
        custom_value = ""
    dlg = ChooseOnePlusCustomDialog(
        event.task.window.control, possible_labels.keys(), label, custom_value,
        "Choose Trigger Function",
        "Select one trigger function or enter custom address",
        "Trigger Addr (hex)")
    if dlg.ShowModal() == wx.ID_OK:
        label, addr = dlg.get_selected()
        if label is not None:
            addr = possible_labels[label]
        else:
            try:
                addr = text_to_int(addr, "hex")
            except ValueError:
                event.task.window.error("Invalid address %s" % addr)
                addr = None
    else:
        addr = None
    dlg.Destroy()
    return addr
Example #3
0
 def get_run_addr(self):
     text = self.run_addr.GetValue()
     try:
         addr = text_to_int(text, "hex")
         if addr < 0 or addr > 0xffff:
             addr = None
     except (ValueError, TypeError), e:
         addr = None
Example #4
0
 def get_run_addr(self):
     text = self.run_addr.GetValue()
     try:
         addr = text_to_int(text, "hex")
         if addr < 0 or addr > 0xffff:
             addr = None
     except (ValueError, TypeError), e:
         addr = None
Example #5
0
 def get_interleave(self):
     text = self.intervleave.GetValue()
     length = self.get_length()
     try:
         num = text_to_int(text, "hex")
         if num < 0 or num > length:
             num = 0
     except (ValueError, TypeError), e:
         num = 0
Example #6
0
 def get_interleave(self):
     text = self.interleave.GetValue()
     length = self.get_length()
     try:
         num = text_to_int(text, "hex")
         if num < 0 or num > length:
             num = 0
     except (ValueError, TypeError), e:
         num = 0
Example #7
0
 def convert_text(self,
                  text,
                  return_error=False,
                  default_base="dec",
                  **kwargs):
     try:
         value = text_to_int(text, default_base)
         error = ""
     except (ValueError, TypeError), e:
         value = None
         error = str(e)
Example #8
0
def trigger_dialog(event, e, obj):
    possible_labels = e.get_triggers()
    label = e.get_trigger_label(obj.trigger_function)
    if label is None and obj.trigger_function:
        custom_value = "%04x" % obj.trigger_function
    else:
        custom_value = ""
    print obj
    print possible_labels
    dlg = ChooseOnePlusCustomDialog(event.task.window.control, possible_labels.keys(), label, custom_value, "Choose Trigger Function", "Select one trigger function or enter custom address", "Trigger Addr (hex)")
    if dlg.ShowModal() == wx.ID_OK:
        label, addr = dlg.get_selected()
        if label is not None:
            addr = possible_labels[label]
        else:
            try:
                addr = text_to_int(addr, "hex")
            except ValueError:
                event.task.window.error("Invalid address %s" % addr)
                addr = None
    else:
        addr = None
    dlg.Destroy()
    return addr
Example #9
0
#!/usr/bin/env python

import numpy as np

from omnivore.utils.textutil import text_to_int

titles = "$c0,$c0,$c0,$c0,$e5,$e1,$f3,$f9,$c0,$e4,$ef,$e5,$f3,$c0,$e9,$f4,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$f2,$ef,$e2,$ef,$f4,$f3,$c0,$e9,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$e2,$ef,$ed,$e2,$f3,$c0,$e1,$f7,$e1,$f9,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$ea,$f5,$ed,$f0,$e9,$ee,$e7,$c0,$e2,$ec,$ef,$e3,$eb,$f3,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$f6,$e1,$ed,$f0,$e9,$f2,$e5,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$e9,$ee,$f6,$e1,$f3,$e9,$ef,$ee,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$e7,$f2,$e1,$ee,$e4,$c0,$f0,$f5,$fa,$fa,$ec,$e5,$c0,$e9,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$e2,$f5,$e9,$ec,$e4,$e5,$f2,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$ec,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$c0,$c0,$c0,$c0,$c0,$c0,$c0,$e6,$f2,$e5,$e5,$fa,$e5,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$e6,$ef,$ec,$ec,$ef,$f7,$c0,$f4,$e8,$e5,$c0,$ec,$e5,$e1,$e4,$e5,$f2,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$f4,$e8,$e5,$c0,$ea,$f5,$ee,$e7,$ec,$e5,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$ed,$f9,$f3,$f4,$e5,$f2,$f9,$c0,$ed,$e1,$fa,$e5,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$ed,$f9,$f3,$f4,$e5,$f2,$f9,$c0,$ed,$e1,$fa,$e5,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$ed,$f9,$f3,$f4,$e5,$f2,$f9,$c0,$ed,$e1,$fa,$e5,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$e7,$f5,$ee,$e6,$e9,$e7,$e8,$f4,$e5,$f2,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$f2,$ef,$e2,$ef,$f4,$f3,$c0,$e9,$e9,$e9,$c0,$c0,$c0,$c0,$c0,$c0,$ee,$ef,$f7,$c0,$f9,$ef,$f5,$c0,$f3,$e5,$e5,$c0,$e9,$f4,$ce,$ce,$ce,$ce,$c0,$c0,$c0,$c0,$c0,$e7,$ef,$e9,$ee,$e7,$c0,$e4,$ef,$f7,$ee,$df,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$e7,$f2,$e1,$ee,$e4,$c0,$f0,$f5,$fa,$fa,$ec,$e5,$c0,$e9,$e9,$e9,$c0,$c0"

data = [text_to_int(v) for v in titles.split(",")]
print data
a = np.empty([len(data)], dtype=np.uint8)
a[:] = data
t = a.reshape([32,20])
print t
output = []
output_map = []
text = []
for i in range(32):
    title = t[i]
    for num in range(10):
        if title[num] == title[20 - num - 1] == 192:
            num += 1
        else:
            break
    small = title[num:20 - num]
    print num, small
    output_map.append(len(output))
    output.append(num)
    output.extend(list(small))
    text.append("        .byte $%02x,%s" % (num, ",".join(["$%02x" % i for i in small])))
print len(output), output