First, explain the whole plan , It's divided into three parts ,
In this automatic way , Reduce duplication of effort in chip testing , And improve code generation IDE Tools .
The following code is opened through an absolute path Keil engineering
import subprocess
import os
main = "C:/Users/siyu/.PyCharmCE2019.1/config/scratches/two/main.uvproj"
if os.path.exists(main):
rc,out= subprocess.getstatusoutput(main)
print (rc)
print ('*'*10)
print (out)
Reference resources :
python in 3 Call executable file .exe Methods
python Realize to windows The libraries involved in window operation are ctypes 、win32GUI、pywin32、win32con etc. , These still need to continue to enrich knowledge .
Use python Open the project file , Use python Medium pyautiogui Realize the positioning of the keys
The installation of the package
pip install pyautogui
import pyautogui
# Determine the position of the target screenshot on the system , Both methods can be implemented
#location=pyautogui.locateOnScreen(image='autotest.png')
location=pyautogui.locateOnScreen(image='C:/Users/siyu/Pictures/autotest.png')
# Output coordinates
print(location)
# utilize center() Function to obtain the central coordinate position of the target image in the system
x,y=pyautogui.center(location)
print('center()',x,y)
# Click on the recognized target image
# Parameters x,y Represents the coordinate position ,clicks Represents the number of hits ,button It can be set as left or right key
pyautogui.click(x=x,y=y,clicks=1,button='left')
This has been implemented based on GUI The operating , The difference lies in clicking different buttons , Need to dynamically add buttons .
Reference code
The use of
【pyautogui】 utilize Python Conduct windows Image recognition and click on the system (Mac OS The system can also )
other
【Python】 Match the position in the original image through the screenshot (opencv)
pyppeteer( 6、 ... and )– adopt opencv Find the location of the picture in another picture
This is divided into three parts
a) Add... To the implementation project C file
b) Yes C Change the code in the file
C) After optimization GUI The implementation of the
Implementation steps :
Open the project file in text mode >>> Add files
Realize the reading of project files , And save it to str Array
f = open("main.uvproj","r") # Set file object
str = f.read() # take txt All the contents of the file are read into the string str in
print(str)
f.close() # Close the file
Realization main String lookup , And output line number
findMusic="main";
MusicLine=0;
f = open('main.c','r')
for lines in f.readlines():
MusicLine=MusicLine+1;
if lines.find(findMusic)!=-1:
print(lines)
print("find it .........................")
print(MusicLine)
#print(lines,end='')
f.close()
python Change the specified row
Code not verified , Should be python2 Code for
#coding=utf-8
lines=[]
f=open("d:\\1script\\1.txt",'r') #your path!
for line in f:
lines.append(line)
f.close()
print lines
lines.insert(3,"666\n") # Fourth line insert 666 And return
s=''.join(lines)
f=open("d:\\1script\\1.txt",'w+') # Rewrite file
f.write(s)
f.close()
del lines[:] # clear list
print lines
Reference code :
python How to open a txt file It realizes two functions of reading and writing .
python Write to the specified line of the file
Implementation steps : open C file >>> Locate the location that needs to be changed >>> Compare and modify libraries , Modify the code >>> Save and exit
Library functions are required to locate the code , It is difficult to recognize the meaning of all the codes , Only code regions can be generated and cannot be edited ,
Realization c File reading , And storage to str in
f = open("main.c","r") # Set file object
str = f.read() # take txt All the contents of the file are read into the string str in
print(str)
f.close() # Close the file
Make replicable ,
PS: As mentioned above Excel The input can be replaced by GUI Interface input . And the mapping relationship is directly recognized by the picture .
Implementation steps :
gpio Read high and low levels >>> Upload high and low levels PC>>>PC According to the uploaded data , And the part of coding , Know whether the requirements are met
FPGA The high-speed port of can realize GHZ The judgment of the , But it needs to be confirmed that the common IO Maximum reading speed of the port .
Common interface speeds
Generally, the maximum test speed is 18M, If the rich design 50M The biggest one is . If there is a high-speed requirement , Need to redraw PCB, Or connect to a specific interface in advance .
adopt USB Protocol upload , Common are the use of specific USB chip , Realization 2.0 The transmission of . Can basically meet the needs of ?
USB The speed of :
USB Transfer to computer
Little Mei :USB2.0 CY7C68013 Based on little MEG ACX720 FPGA Development board , The driver recommended by the chip manufacturer is adopted .
Punctual atom Da Vinci FPGA Development board
This part needs to develop corresponding receiving tools , be based on USB Learning from . There is no corresponding knowledge reserve for this part .
FPGA >>> High speed connector >>> Adapter plate >>>FPGA Daughter board
The first two are ready-made Salins development boards , The rear adapter board is a multilayer board ,
The adapter board can be connected to the... For logic analysis FPGA, It can also be connected to the existing voltage converter PCB.
PS: Possible problems :
a) Voltage matching problem . existing FPGA The output voltage is 1.8V,
b) The problem of board signal attenuation