#!/usr/bin/env python
|
#!/usr/bin/env python
|
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
# generated by wxGlade 0.6.3 on Wed Mar 26 16:29:14 2014
|
# generated by wxGlade 0.6.3 on Wed Mar 26 16:29:14 2014
|
|
|
import wx
|
import wx
|
# imports by maximiq
|
# imports by maximiq
|
import os # se usa para el dialogo de abrir fichero
|
import os # se usa para el dialogo de abrir fichero
|
import subprocess # para interactuar con el shell
|
import subprocess # para interactuar con el shell
|
|
import thread # to prevent gui blocking
|
|
|
#####################################
|
#####################################
|
# Para que funcione mejor en Linux
|
# Para que funcione mejor en Linux
|
#import os
|
#import os
|
|
|
abspath = os.path.abspath(__file__)
|
abspath = os.path.abspath(__file__)
|
dname = os.path.dirname(abspath)
|
dname = os.path.dirname(abspath)
|
os.chdir(dname)
|
os.chdir(dname)
|
#####################################
|
#####################################
|
|
|
# begin wxGlade: extracode
|
# begin wxGlade: extracode
|
# end wxGlade
|
# end wxGlade
|
|
|
|
|
|
|
class MyFrame(wx.Frame):
|
class MyFrame(wx.Frame):
|
def __init__(self, *args, **kwds):
|
def __init__(self, *args, **kwds):
|
# begin wxGlade: MyFrame.__init__
|
# begin wxGlade: MyFrame.__init__
|
kwds["style"] = wx.DEFAULT_FRAME_STYLE
|
kwds["style"] = wx.DEFAULT_FRAME_STYLE
|
wx.Frame.__init__(self, *args, **kwds)
|
wx.Frame.__init__(self, *args, **kwds)
|
self.frame_1_statusbar = self.CreateStatusBar(1, 0)
|
self.frame_1_statusbar = self.CreateStatusBar(1, 0)
|
self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("grafica/banner.jpg", wx.BITMAP_TYPE_ANY))
|
self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("grafica/banner.jpg", wx.BITMAP_TYPE_ANY))
|
self.button_help = wx.Button(self, -1, " Ayuda ")
|
self.button_help = wx.Button(self, -1, " Ayuda ")
|
self.button_about = wx.Button(self, -1, " Acerca de ")
|
self.button_about = wx.Button(self, -1, " Acerca de ")
|
self.text_ctrl_file = wx.TextCtrl(self, -1, "")
|
self.text_ctrl_file = wx.TextCtrl(self, -1, "")
|
self.button_choose_file = wx.Button(self, -1, "Elegir fichero")
|
self.button_choose_file = wx.Button(self, -1, "Elegir fichero")
|
self.button_conf_fpga = wx.Button(self, -1, "Configurar FPGA")
|
self.button_conf_fpga = wx.Button(self, -1, "Configurar FPGA")
|
self.button_prog_prom = wx.Button(self, -1, "Programar PROM")
|
self.button_prog_prom = wx.Button(self, -1, "Programar PROM")
|
self.text_ctrl_console = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
|
self.text_ctrl_console = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
|
self.button_conection = wx.Button(self, -1, u" Comprobar conexión ")
|
self.button_conection = wx.Button(self, -1, u" Comprobar conexión ")
|
self.button_empty = wx.Button(self, -1, " Borrar salida ")
|
self.button_empty = wx.Button(self, -1, " Borrar salida ")
|
|
|
self.__set_properties()
|
self.__set_properties()
|
self.__do_layout()
|
self.__do_layout()
|
|
|
self.Bind(wx.EVT_BUTTON, self.boton_ayuda, self.button_help)
|
self.Bind(wx.EVT_BUTTON, self.boton_ayuda, self.button_help)
|
self.Bind(wx.EVT_BUTTON, self.boton_acerca_de, self.button_about)
|
self.Bind(wx.EVT_BUTTON, self.boton_acerca_de, self.button_about)
|
self.Bind(wx.EVT_BUTTON, self.boton_elegir_fichero, self.button_choose_file)
|
self.Bind(wx.EVT_BUTTON, self.boton_elegir_fichero, self.button_choose_file)
|
self.Bind(wx.EVT_BUTTON, self.boton_conf_fpga, self.button_conf_fpga)
|
self.Bind(wx.EVT_BUTTON, self.boton_conf_fpga, self.button_conf_fpga)
|
self.Bind(wx.EVT_BUTTON, self.boton_prog_prom, self.button_prog_prom)
|
self.Bind(wx.EVT_BUTTON, self.boton_prog_prom, self.button_prog_prom)
|
self.Bind(wx.EVT_BUTTON, self.boton_conexion, self.button_conection)
|
self.Bind(wx.EVT_BUTTON, self.boton_conexion, self.button_conection)
|
self.Bind(wx.EVT_BUTTON, self.boton_borrar, self.button_empty)
|
self.Bind(wx.EVT_BUTTON, self.boton_borrar, self.button_empty)
|
# end wxGlade
|
# end wxGlade
|
|
|
def __set_properties(self):
|
def __set_properties(self):
|
# begin wxGlade: MyFrame.__set_properties
|
# begin wxGlade: MyFrame.__set_properties
|
self.SetTitle("PHR GUI")
|
self.SetTitle("PHR GUI")
|
_icon = wx.EmptyIcon()
|
_icon = wx.EmptyIcon()
|
_icon.CopyFromBitmap(wx.Bitmap("grafica/phr-gui.ico", wx.BITMAP_TYPE_ANY))
|
_icon.CopyFromBitmap(wx.Bitmap("grafica/phr-gui.ico", wx.BITMAP_TYPE_ANY))
|
self.SetIcon(_icon)
|
self.SetIcon(_icon)
|
self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
|
self.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DFACE))
|
self.frame_1_statusbar.SetStatusWidths([-1])
|
self.frame_1_statusbar.SetStatusWidths([-1])
|
# statusbar fields
|
# statusbar fields
|
frame_1_statusbar_fields = ["Listo"]
|
frame_1_statusbar_fields = ["Listo"]
|
for i in range(len(frame_1_statusbar_fields)):
|
for i in range(len(frame_1_statusbar_fields)):
|
self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
|
self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
|
self.text_ctrl_console.SetMinSize((-1, 150))
|
self.text_ctrl_console.SetMinSize((-1, 150))
|
# end wxGlade
|
# end wxGlade
|
# start maximiq
|
# start maximiq
|
font1 = self.text_ctrl_console.GetFont()
|
font1 = self.text_ctrl_console.GetFont()
|
font1 = wx.Font(font1.GetPointSize(), wx.TELETYPE,
|
font1 = wx.Font(font1.GetPointSize(), wx.TELETYPE,
|
font1.GetStyle(),
|
font1.GetStyle(),
|
font1.GetWeight(), font1.GetUnderlined())
|
font1.GetWeight(), font1.GetUnderlined())
|
self.text_ctrl_console.SetFont(font1)
|
self.text_ctrl_console.SetFont(font1)
|
#font1 = wx.Font(9, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')
|
#font1 = wx.Font(9, wx.MODERN, wx.NORMAL, wx.NORMAL, False, u'Consolas')
|
#self.text_ctrl_console.SetFont(font1)
|
#self.text_ctrl_console.SetFont(font1)
|
self.text_ctrl_console.SetValue("PHR>>> ")
|
self.text_ctrl_console.SetValue("PHR>>> ")
|
|
|
def __do_layout(self):
|
def __do_layout(self):
|
# begin wxGlade: MyFrame.__do_layout
|
# begin wxGlade: MyFrame.__do_layout
|
grid_sizer_1 = wx.FlexGridSizer(5, 1, 0, 0)
|
grid_sizer_1 = wx.FlexGridSizer(5, 1, 0, 0)
|
grid_sizer_2 = wx.GridSizer(1, 2, 0, 0)
|
grid_sizer_2 = wx.GridSizer(1, 2, 0, 0)
|
grid_sizer_4 = wx.GridSizer(1, 2, 0, 0)
|
grid_sizer_4 = wx.GridSizer(1, 2, 0, 0)
|
grid_sizer_5 = wx.FlexGridSizer(1, 2, 0, 0)
|
grid_sizer_5 = wx.FlexGridSizer(1, 2, 0, 0)
|
grid_sizer_6 = wx.FlexGridSizer(1, 2, 0, 0)
|
grid_sizer_6 = wx.FlexGridSizer(1, 2, 0, 0)
|
grid_sizer_7 = wx.FlexGridSizer(2, 1, 0, 0)
|
grid_sizer_7 = wx.FlexGridSizer(2, 1, 0, 0)
|
grid_sizer_6.Add(self.bitmap_1, 0, wx.ALL, 5)
|
grid_sizer_6.Add(self.bitmap_1, 0, wx.ALL, 5)
|
grid_sizer_7.Add(self.button_help, 0, wx.RIGHT|wx.TOP|wx.BOTTOM|wx.EXPAND, 5)
|
grid_sizer_7.Add(self.button_help, 0, wx.RIGHT|wx.TOP|wx.BOTTOM|wx.EXPAND, 5)
|
grid_sizer_7.Add(self.button_about, 0, wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
|
grid_sizer_7.Add(self.button_about, 0, wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
|
grid_sizer_6.Add(grid_sizer_7, 1, wx.EXPAND, 0)
|
grid_sizer_6.Add(grid_sizer_7, 1, wx.EXPAND, 0)
|
grid_sizer_6.AddGrowableCol(1)
|
grid_sizer_6.AddGrowableCol(1)
|
grid_sizer_1.Add(grid_sizer_6, 1, wx.EXPAND, 0)
|
grid_sizer_1.Add(grid_sizer_6, 1, wx.EXPAND, 0)
|
grid_sizer_5.Add(self.text_ctrl_file, 0, wx.ALL|wx.EXPAND, 5)
|
grid_sizer_5.Add(self.text_ctrl_file, 0, wx.ALL|wx.EXPAND, 5)
|
grid_sizer_5.Add(self.button_choose_file, 0, wx.RIGHT|wx.TOP|wx.BOTTOM, 5)
|
grid_sizer_5.Add(self.button_choose_file, 0, wx.RIGHT|wx.TOP|wx.BOTTOM, 5)
|
grid_sizer_5.AddGrowableCol(0)
|
grid_sizer_5.AddGrowableCol(0)
|
grid_sizer_1.Add(grid_sizer_5, 1, wx.EXPAND, 0)
|
grid_sizer_1.Add(grid_sizer_5, 1, wx.EXPAND, 0)
|
grid_sizer_4.Add(self.button_conf_fpga, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
|
grid_sizer_4.Add(self.button_conf_fpga, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
|
grid_sizer_4.Add(self.button_prog_prom, 0, wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
|
grid_sizer_4.Add(self.button_prog_prom, 0, wx.RIGHT|wx.BOTTOM|wx.EXPAND, 5)
|
grid_sizer_1.Add(grid_sizer_4, 1, wx.EXPAND, 0)
|
grid_sizer_1.Add(grid_sizer_4, 1, wx.EXPAND, 0)
|
grid_sizer_1.Add(self.text_ctrl_console, 0, wx.ALL|wx.EXPAND, 5)
|
grid_sizer_1.Add(self.text_ctrl_console, 0, wx.ALL|wx.EXPAND, 5)
|
grid_sizer_2.Add(self.button_conection, 0, wx.LEFT|wx.BOTTOM, 5)
|
grid_sizer_2.Add(self.button_conection, 0, wx.LEFT|wx.BOTTOM, 5)
|
grid_sizer_2.Add(self.button_empty, 0, wx.RIGHT|wx.BOTTOM|wx.ALIGN_RIGHT, 5)
|
grid_sizer_2.Add(self.button_empty, 0, wx.RIGHT|wx.BOTTOM|wx.ALIGN_RIGHT, 5)
|
grid_sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
|
grid_sizer_1.Add(grid_sizer_2, 1, wx.EXPAND, 0)
|
self.SetSizer(grid_sizer_1)
|
self.SetSizer(grid_sizer_1)
|
grid_sizer_1.Fit(self)
|
grid_sizer_1.Fit(self)
|
grid_sizer_1.SetSizeHints(self)
|
grid_sizer_1.SetSizeHints(self)
|
grid_sizer_1.AddGrowableRow(3)
|
grid_sizer_1.AddGrowableRow(3)
|
grid_sizer_1.AddGrowableCol(0)
|
grid_sizer_1.AddGrowableCol(0)
|
self.Layout()
|
self.Layout()
|
# end wxGlade
|
# end wxGlade
|
|
|
def OnAboutBox(self):
|
def OnAboutBox(self):
|
|
|
description = """
|
description = """
|
PHR GUI es una interfaz grafica que permite interactuar con
|
PHR GUI es una interfaz grafica que permite interactuar con
|
la Plataforma de Hardware Reconfigurable (desarrollada en el
|
la Plataforma de Hardware Reconfigurable (desarrollada en el
|
CUDAR) a traves del software xc3sprog.
|
CUDAR) a traves del software xc3sprog.
|
|
|
Revision (SVN) 209.
|
Revision (SVN) 209.
|
"""
|
"""
|
|
|
licence = """
|
licence = """
|
PHR GUI is free software; you can redistribute it and/or modify
|
PHR GUI is free software; you can redistribute it and/or modify
|
it under the terms of the GNU General Public License as
|
it under the terms of the GNU General Public License as
|
published by the Free Software Foundation; either version 2
|
published by the Free Software Foundation; either version 2
|
of the License, or (at your option) any later version.
|
of the License, or (at your option) any later version.
|
|
|
PHR GUI is distributed in the hope that it will be useful,
|
PHR GUI is distributed in the hope that it will be useful,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
See the GNU General Public License for more details. You should have
|
See the GNU General Public License for more details. You should have
|
received a copy of the GNU General Public License along with
|
received a copy of the GNU General Public License along with
|
PHR GUI; if not, write to the Free Software Foundation, Inc.,
|
PHR GUI; if not, write to the Free Software Foundation, Inc.,
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
"""
|
"""
|
|
|
|
|
info = wx.AboutDialogInfo()
|
info = wx.AboutDialogInfo()
|
|
|
info.SetIcon(wx.Icon('grafica/phr-gui-96.png', wx.BITMAP_TYPE_PNG))
|
info.SetIcon(wx.Icon('grafica/phr-gui-96.png', wx.BITMAP_TYPE_PNG))
|
info.SetName('PHR GUI')
|
info.SetName('PHR GUI')
|
info.SetVersion('0.1')
|
info.SetVersion('0.1')
|
info.SetDescription(description)
|
info.SetDescription(description)
|
#info.SetCopyright('(C) 2014 CUDAR (UTN-FRC)')
|
#info.SetCopyright('(C) 2014 CUDAR (UTN-FRC)')
|
info.SetCopyright('Abril de 2014, CUDAR (UTN-FRC)')
|
info.SetCopyright('Abril de 2014, CUDAR (UTN-FRC)')
|
info.SetWebSite('http://opencores.org/project,phr')
|
info.SetWebSite('http://opencores.org/project,phr')
|
#info.SetLicence(licence)
|
#info.SetLicence(licence)
|
info.AddDeveloper('Luis Guanuco, Maximiliano Quinteros.')
|
info.AddDeveloper('Luis Guanuco, Maximiliano Quinteros.')
|
|
|
|
|
wx.AboutBox(info)
|
wx.AboutBox(info)
|
|
|
def ShowHelpMessage(self):
|
def ShowHelpMessage(self):
|
mensaje = """
|
mensaje = """
|
Procedimiento para usar este programa:
|
Procedimiento para usar este programa:
|
|
|
Para configurar la FPGA:
|
Para configurar la FPGA:
|
1) Setear el jumper en la placa PHR en modo JTAG.
|
1) Setear el jumper en la placa PHR en modo JTAG.
|
2) Elegir el archivo de configuracion (*.bit).
|
2) Elegir el archivo de configuracion (*.bit).
|
3) Presione el boton \"Configurar FPGA\".
|
3) Presione el boton \"Configurar FPGA\".
|
4) Tras terminar el paso anterior la FPGA debe comenzar a funcionar.
|
4) Tras terminar el paso anterior la FPGA debe comenzar a funcionar.
|
|
|
Para programar la memoria PROM:
|
Para programar la memoria PROM:
|
1) Setear el jumper en la placa PHR en modo \"Master Serial\".
|
1) Setear el jumper en la placa PHR en modo \"Master Serial\".
|
2) Elegir el archivo de programacion (*.bit).
|
2) Elegir el archivo de programacion (*.bit).
|
3) Presione el boton \"Programar PROM\".
|
3) Presione el boton \"Programar PROM\".
|
4) Una vez terminado el paso anterior, presionar el boton de RESET.
|
4) Una vez terminado el paso anterior, presionar el boton de RESET.
|
|
|
Mas ayuda en los manuales que puede descargar desde el servidor de
|
Mas ayuda en los manuales que puede descargar desde el servidor de
|
OpenCores donde se aloja el proyecto: http://opencores.org/project,phr
|
OpenCores donde se aloja el proyecto: http://opencores.org/project,phr
|
"""
|
"""
|
wx.MessageBox(mensaje, 'Info',
|
wx.MessageBox(mensaje, 'Info',
|
wx.OK | wx.ICON_INFORMATION)
|
wx.OK | wx.ICON_INFORMATION)
|
|
|
def boton_ayuda(self, event): # wxGlade: MyFrame.<event_handler>
|
def boton_ayuda(self, event): # wxGlade: MyFrame.<event_handler>
|
self.ShowHelpMessage()
|
self.ShowHelpMessage()
|
event.Skip()
|
event.Skip()
|
|
|
def boton_acerca_de(self, event): # wxGlade: MyFrame.<event_handler>
|
def boton_acerca_de(self, event): # wxGlade: MyFrame.<event_handler>
|
self.OnAboutBox()
|
self.OnAboutBox()
|
event.Skip()
|
event.Skip()
|
|
|
def boton_elegir_fichero(self, event): # wxGlade: MyFrame.<event_handler>
|
def boton_elegir_fichero(self, event): # wxGlade: MyFrame.<event_handler>
|
#funcion editada por maximiq
|
#funcion editada por maximiq
|
|
|
wildcard = "Archivo BIT de Xilinx (*.bit)|*.bit|" \
|
wildcard = "Archivo BIT de Xilinx (*.bit)|*.bit|" \
|
"Todos los archivos (*.*)|*.*"
|
"Todos los archivos (*.*)|*.*"
|
dialog = wx.FileDialog(None, "Elija un archivo", os.getcwd(), "", wildcard, wx.OPEN)
|
dialog = wx.FileDialog(None, "Elija un archivo", os.getcwd(), "", wildcard, wx.OPEN)
|
if dialog.ShowModal() == wx.ID_OK:
|
if dialog.ShowModal() == wx.ID_OK:
|
self.text_ctrl_file.SetValue(dialog.GetPath())
|
self.text_ctrl_file.SetValue(dialog.GetPath())
|
|
|
dialog.Destroy()
|
dialog.Destroy()
|
|
|
event.Skip()
|
event.Skip()
|
|
|
def boton_conf_fpga(self, event): # wxGlade: MyFrame.<event_handler>
|
def before_run (self):
|
#funcion editada por maximiq
|
## preparar entorno para los eventos conf_fpga prog_prom comprobar_conexion
|
|
|
## preparar entorno
|
|
self.button_conf_fpga.Disable()
|
self.button_conf_fpga.Disable()
|
self.button_prog_prom.Disable()
|
self.button_prog_prom.Disable()
|
self.button_conection.Disable()
|
self.button_conection.Disable()
|
self.button_empty.Disable()
|
self.button_empty.Disable()
|
self.frame_1_statusbar.SetFields(["Espere ..."])
|
self.frame_1_statusbar.SetFields(["Espere ..."])
|
|
|
|
def after_run (self):
|
|
## restaurar entorno
|
|
self.button_conf_fpga.Enable()
|
|
self.button_prog_prom.Enable()
|
|
self.button_conection.Enable()
|
|
self.button_empty.Enable()
|
|
self.frame_1_statusbar.SetFields(["Listo"])
|
|
|
|
def boton_conf_fpga_thread(self):
|
|
## preparar entorno
|
|
wx.CallAfter(self.before_run)
|
|
|
## accion
|
## accion
|
# se copia el fichero de programacion al directorio local
|
# se copia el fichero de programacion al directorio local
|
#subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
|
#subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
|
|
|
# se ejecuta el xc3sprog
|
# se ejecuta el xc3sprog
|
command = "./xc3sprog/xc3sprog -v -c ftdi -p 0 \""+ self.text_ctrl_file.GetValue() + "\":w:0:BIT"
|
command = "./xc3sprog/xc3sprog -v -c ftdi -p 0 \""+ self.text_ctrl_file.GetValue() + "\":w:0:BIT"
|
|
|
self.text_ctrl_console.AppendText(command + "\n")
|
wx.CallAfter(self.text_ctrl_console.AppendText, command + "\n")
|
|
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
|
|
|
for line in iter(process.stdout.readline, ''):
|
for line in iter(process.stdout.readline, ''):
|
self.text_ctrl_console.AppendText(line)
|
wx.CallAfter(self.text_ctrl_console.AppendText, line)
|
process.stdout.close()
|
process.stdout.close()
|
|
|
self.text_ctrl_console.AppendText("\nPHR>>> ")
|
wx.CallAfter(self.text_ctrl_console.AppendText, "\nPHR>>> ")
|
|
|
## restaurar entorno
|
## restaurar entorno
|
self.button_conf_fpga.Enable()
|
wx.CallAfter(self.after_run)
|
self.button_prog_prom.Enable()
|
|
self.button_conection.Enable()
|
|
self.button_empty.Enable()
|
|
self.frame_1_statusbar.SetFields(["Listo"])
|
|
|
|
|
def boton_conf_fpga(self, event): # wxGlade: MyFrame.<event_handler>
|
|
#funcion editada por maximiq
|
|
thread.start_new_thread(self.boton_conf_fpga_thread, ())
|
event.Skip()
|
event.Skip()
|
|
|
def boton_prog_prom(self, event): # wxGlade: MyFrame.<event_handler>
|
def boton_prog_prom_thread(self):
|
#funcion editada por maximiq
|
#funcion editada por maximiq
|
|
|
## preparar entorno
|
## preparar entorno
|
self.button_conf_fpga.Disable()
|
wx.CallAfter(self.before_run)
|
self.button_prog_prom.Disable()
|
|
self.button_conection.Disable()
|
|
self.button_empty.Disable()
|
|
self.frame_1_statusbar.SetFields(["Espere ..."])
|
|
|
|
## accion
|
## accion
|
|
|
# se copia el fichero de programacion al directorio local
|
# se copia el fichero de programacion al directorio local
|
#subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
|
#subprocess.call ("copy \"" + self.text_ctrl_file.GetValue() + "\" fpgaFile", shell=True)
|
|
|
command = "./xc3sprog/xc3sprog -v -c ftdi -p 1 \"" + self.text_ctrl_file.GetValue() + "\":w:0:BIT"
|
command = "./xc3sprog/xc3sprog -v -c ftdi -p 1 \"" + self.text_ctrl_file.GetValue() + "\":w:0:BIT"
|
|
|
self.text_ctrl_console.AppendText(command + "\n")
|
wx.CallAfter(self.text_ctrl_console.AppendText, command + "\n")
|
|
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
|
|
|
for line in iter(process.stdout.readline, ''):
|
for line in iter(process.stdout.readline, ''):
|
self.text_ctrl_console.AppendText(line)
|
wx.CallAfter(self.text_ctrl_console.AppendText, line)
|
process.stdout.close()
|
process.stdout.close()
|
# line = ''
|
# line = ''
|
# while True:
|
# while True:
|
# out = process.stdout.read(1)
|
# out = process.stdout.read(1)
|
# if out == '' and process.poll() != None:
|
# if out == '' and process.poll() != None:
|
# break
|
# break
|
# if out != '' and out != '\x0a':
|
# if out != '' and out != '\x0a':
|
# line = line + out
|
# line = line + out
|
# if out == '\x0d':
|
# if out == '\x0d':
|
# self.text_ctrl_console.AppendText(line)
|
# self.text_ctrl_console.AppendText(line)
|
# line = ''
|
# line = ''
|
|
|
self.text_ctrl_console.AppendText("\nPHR>>> ")
|
wx.CallAfter(self.text_ctrl_console.AppendText, "\nPHR>>> ")
|
|
|
## restaurar entorno
|
## restaurar entorno
|
self.button_conf_fpga.Enable()
|
wx.CallAfter(self.after_run)
|
self.button_prog_prom.Enable()
|
|
self.button_conection.Enable()
|
|
self.button_empty.Enable()
|
|
self.frame_1_statusbar.SetFields(["Listo"])
|
|
|
|
event.Skip()
|
|
|
|
def boton_conexion(self, event): # wxGlade: MyFrame.<event_handler>
|
def boton_prog_prom(self, event): # wxGlade: MyFrame.<event_handler>
|
#funcion editada por maximiq
|
#funcion editada por maximiq
|
|
thread.start_new_thread(self.boton_prog_prom_thread, ())
|
|
event.Skip()
|
|
|
|
def boton_conexion_thread (self):
|
## preparar entorno
|
## preparar entorno
|
self.button_conf_fpga.Disable()
|
wx.CallAfter(self.before_run, )
|
self.button_prog_prom.Disable()
|
|
self.button_conection.Disable()
|
|
self.button_empty.Disable()
|
|
self.frame_1_statusbar.SetFields(["Espere ..."])
|
|
|
|
## accion
|
## accion
|
command = "./xc3sprog/xc3sprog -c ftdi" # the shell command
|
command = "./xc3sprog/xc3sprog -c ftdi" # the shell command
|
|
|
self.text_ctrl_console.AppendText(command + "\n")
|
wx.CallAfter(self.text_ctrl_console.AppendText, command + "\n")
|
|
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
|
|
|
for line in iter(process.stdout.readline, ''):
|
for line in iter(process.stdout.readline, ''):
|
self.text_ctrl_console.AppendText(line)
|
wx.CallAfter(self.text_ctrl_console.AppendText, line)
|
process.stdout.close()
|
process.stdout.close()
|
|
|
self.text_ctrl_console.AppendText("\nPHR>>> ")
|
wx.CallAfter(self.text_ctrl_console.AppendText, "\nPHR>>> ")
|
|
|
## restaurar entorno
|
## restaurar entorno
|
self.button_conf_fpga.Enable()
|
wx.CallAfter(self.after_run, )
|
self.button_prog_prom.Enable()
|
|
self.button_conection.Enable()
|
|
self.button_empty.Enable()
|
|
self.frame_1_statusbar.SetFields(["Listo"])
|
|
|
|
|
|
|
def boton_conexion(self, event): # wxGlade: MyFrame.<event_handler>
|
|
#funcion editada por maximiq
|
|
thread.start_new_thread(self.boton_conexion_thread, ())
|
event.Skip()
|
event.Skip()
|
|
|
def boton_borrar(self, event): # wxGlade: MyFrame.<event_handler>
|
def boton_borrar(self, event): # wxGlade: MyFrame.<event_handler>
|
#funcion editada por maximiq
|
#funcion editada por maximiq
|
|
|
## accion
|
## accion
|
self.text_ctrl_console.SetValue("PHR>>> ") # borra todo el contenido
|
self.text_ctrl_console.SetValue("PHR>>> ") # borra todo el contenido
|
|
|
event.Skip()
|
event.Skip()
|
|
|
# end of class MyFrame
|
# end of class MyFrame
|
|
|
|
|
if __name__ == "__main__":
|
if __name__ == "__main__":
|
app = wx.App(False)
|
app = wx.App(False)
|
frame_1 = MyFrame(None, -1, "")
|
frame_1 = MyFrame(None, -1, "")
|
app.SetTopWindow(frame_1)
|
app.SetTopWindow(frame_1)
|
frame_1.Show()
|
frame_1.Show()
|
app.MainLoop()
|
app.MainLoop()
|
|
|