Beispiel #1
0
    def t_read(self):
        try:
            self.read_mode = MODE_IDLE
            data_buffer = []
            while self.alive:
                try:
                    data = self.nrfjprog.rtt_read(0, 100, encoding=None)
                    if data != '':
                        for byte in data:
                            n = byte
                            if self.read_mode == MODE_IDLE:
                                ''' Mode Idle - Not Receiving '''
                                if n == STX:
                                    self.read_mode = MODE_RECV

                            elif self.read_mode == MODE_RECV:
                                ''' Mode Receiving - Receiving data '''
                                if n == ESC:
                                    self.read_mode = MODE_ESC_RECV
                                elif n == ETX:
                                    self.callback(data_buffer)
                                    data_buffer[:] = []
                                    self.read_mode = MODE_IDLE
                                elif n == STX:
                                    data_buffer[:] = []
                                else:
                                    data_buffer.append(n)

                            elif self.read_mode == MODE_ESC_RECV:
                                ''' Mode Escape Received - Convert next byte '''
                                data_buffer.append(n ^ 0x20)
                                self.read_mode = MODE_RECV

                except AttributeError as attre:
                    # RTT module reported error upon exit
                    debug_print(str(attre))
                    pass

                except Exception as e:
                    debug_print(str(e))
                    print("Lost connection, retrying for 10 times")
                    print("Reconnecting...")
                    connected = False
                    tries = 0
                    while (tries != 10):
                        try:
                            print(tries)
                            time.sleep(0.6)
                            self.nrfjprog.close()
                            self.nrfjprog = API.API('NRF52')
                            self.nrfjprog.open()
                            self.nrfjprog.connect_to_emu_without_snr(
                                jlink_speed_khz=JLINK_SPEED_KHZ)
                            self.nrfjprog.sys_reset()
                            self.nrfjprog.go()
                            self.nrfjprog.rtt_start()
                            time.sleep(1)
                            print(
                                "Reconnected, you may start the graphs again.")
                            connected = True
                            break

                        except Exception as e:
                            print("Reconnecting...")
                            tries += 1
                            self.alive = connected
                    if (connected):
                        self.alive = True
                    else:
                        raise Exception("Failed to reconnect")

        except Exception as e:
            debug_print(str(e))
            self.alive = False
 def rtt_get_device_family():
     with API.API(API.DeviceFamily.UNKNOWN) as api:
         api.connect_to_emu_without_snr()
         return api.read_device_family()
Beispiel #3
0
from pynrfjprog import API, Hex

if __name__ == "__main__":
    hexfile = "ppk_110.hex"
    success = False
    retries = 5
    # Open connection to debugger and rtt
    nrfjprog = API.API('NRF52')
    nrfjprog.open()
    nrfjprog.connect_to_emu_without_snr()
    while (success is False or retries == 0):
        try:
            nrfjprog.recover()
            print "PPK erased"
            success = True
        except:
            print "failed, retrying"
            retries -= 1
            pass
    try:
        application = Hex.Hex(hexfile)
        for segment in application:
            nrfjprog.write(segment.address, segment.data, True)
        print "PPK reprogrammed"
        nrfjprog.sys_reset()
        nrfjprog.go()
        nrfjprog.rtt_start()
        print "PPK ready to go"
    except Exception as e:
        print str(e)
        print "Unable to flash " + hexfile + ", make sure this file is found in working directory."
Beispiel #4
0
 def __init__(self, quiet=False, verbose=False):
     self._quiet = quiet
     self._verbose = verbose
     self.api = API.API("NRF91")
            threading.Thread(target=programe_file_thread,
                             args=[
                                 jlink_1, download_progress, sd_file, app_file,
                                 bootload_file
                             ]).start()
        else:
            messagebox.showerror(
                'Programe Status',
                'Programe Failed.\nNo %s.' % (JLinkDevice.get()))
    else:
        messagebox.showerror('Programe Status', 'Must choice one file.')


#-------------------------------------------------------------------------
root = Tk()  # create a top-level window
jlink_1 = API.API(API.DeviceFamily.NRF51)
#-------------------------------------------------------------------------
SoftDevicePath = StringVar()
AppPath = StringVar()
BootloadPath = StringVar()

Check_1 = IntVar()
Check_2 = IntVar()
Check_3 = IntVar()

JLinkDevice = StringVar()
JLinkDeviceList = get_jlink_list(jlink_1)

if platform.release() == 'XP':
    w = 860  # width for the Tk root
    h = 595  # height for the Tk root
Beispiel #6
0
    from smu.SMU2450 import API as smuAPI

    smu = smuAPI()

    if smu.discover_and_connect() is False:
        print('Test failed, no device found')

    print("Connected!")

    smu.write('SENS:FUNC "VOLT"')
    smu.output_disable()
    smu.set_source_current()
    smu.set_current_drain_microamp(0)
    smu.output_enable()

rtt = API.API('NRF52')
rtt.open()
rtt.connect_to_emu_without_snr()

if (write_firmware):
    hex_file_path = '.\\hex\\ppk_nrfconnect.hex'
    print("Erasing")
    rtt.erase_all()
    print("Erased")
    application = Hex.Hex(hex_file_path)  # Parsing hex file into segments
    print("Flashing")
    for segment in application:
        print("...")
        rtt.write(segment.address, segment.data, True)
    print("Flashed!")