PseudoEror removed

This commit is contained in:
Thomas Herrmann 2021-09-12 14:50:47 +02:00
parent e2e9646c80
commit 7940990e7b

31
cnc.py
View File

@ -42,7 +42,7 @@ def grblConnect2():
try: try:
#print([comport.device for comport in serial.tools.list_ports.comports()]) #print([comport.device for comport in serial.tools.list_ports.comports()])
print ("Trying...",device) print ("Trying...",device)
grbl = serial.Serial(port= device, baudrate= 115200, timeout =3, dsrdtr= True) grbl = serial.Serial(port= device, baudrate= 115200, timeout =3) #dsrdtr= True)
#grbl.open() #grbl.open()
#print(grbl.readline()) #print(grbl.readline())
grbl.write(str.encode("\r\n\r\n")) grbl.write(str.encode("\r\n\r\n"))
@ -65,8 +65,8 @@ def jogWrite(AXIS, CMD, scale): #Schreiben von manuellen Positionierungsbefehlen
DECIMAL = [0.1,1,10,100] DECIMAL = [0.1,1,10,100]
scale = increments.get() scale = increments.get()
MOVE = int(CMD) * DECIMAL[scale -1] MOVE = int(CMD) * DECIMAL[scale -1]
grbl_command = ('$J=G91' +' ' + AXIS + str(MOVE) + ' '+ 'F1000') grbl_command = ('$J=G91' + 'G21' + AXIS + str(MOVE)+ 'F1000')
#print(grbl_command) #print(grbl_command) $J=G91G21X10F185
if freetosend == 1: if freetosend == 1:
byPass(grbl_command+'\n') byPass(grbl_command+'\n')
else: else:
@ -81,6 +81,7 @@ def switchButtonState(button): #Umschalter für Knopfstatus
def directWrite(CMD): #Direktes schreiben eines Befehls def directWrite(CMD): #Direktes schreiben eines Befehls
global freetosend global freetosend
#print(freetosend)
grbl_command = CMD grbl_command = CMD
if freetosend == 0: if freetosend == 0:
now_bufferGRBL(grbl_command + '\n') now_bufferGRBL(grbl_command + '\n')
@ -138,14 +139,6 @@ def latchWrite(CMD):
byPass(grbl_command + '\n') byPass(grbl_command + '\n')
print(grbl_command) print(grbl_command)
def zeroWrite(CMD, AXIS): #Umwandlung für Achsennullung
global freetosend
grbl_command = (CMD + ' ' + AXIS + '0')
if freetosend == 0:
now_bufferGRBL(grbl_command + '\n')
else:
byPass(grbl_command+ '\n')
def terminalWrite(): #Holt Zeichenstring von Editfeld und sendet es def terminalWrite(): #Holt Zeichenstring von Editfeld und sendet es
grbl_command = terminal.get() grbl_command = terminal.get()
#print(grbl_command) #print(grbl_command)
@ -154,7 +147,6 @@ def terminalWrite(): #Holt Zeichenstring von Editfeld und sendet es
else: else:
byPass(grbl_command+'\n') byPass(grbl_command+'\n')
def infoScreen(data): #Anzeigecanvas für GRBL Rückmeldungen def infoScreen(data): #Anzeigecanvas für GRBL Rückmeldungen
global i global i
terminalFrame = Frame(terminal_recv, bg = 'white') terminalFrame = Frame(terminal_recv, bg = 'white')
@ -248,18 +240,27 @@ def now_bufferGRBL(grbl_command):
def byPass(grbl_command): def byPass(grbl_command):
global writebuffer_byPass global writebuffer_byPass
#print (grbl_command)
if grbl_command == '?': if grbl_command == '?':
grbl.write(str.encode(grbl_command)) # Send g-code block to grbl grbl.write(str.encode(grbl_command)) # Send g-code block to grbl
grbl_out = grbl.readline().strip() grbl_out = grbl.readline().strip()
else: else:
print(grbl_command) #print(grbl_command)
writebuffer_byPass.append(grbl_command) writebuffer_byPass.append(grbl_command)
grbl.write(str.encode(writebuffer_byPass[0])) # Send g-code block to grbl grbl.write(str.encode(writebuffer_byPass[0])) # Send g-code block to grbl
grbl_out = grbl.readline().strip() grbl_out = grbl.readline().strip()
#print(writebuffer_byPass)
del writebuffer_byPass[0] del writebuffer_byPass[0]
displayPosition_request(grbl_out) displayPosition_request(grbl_out)
infoScreen(grbl_out) infoScreen(grbl_out)
#print(grbl_out)
def debugWrite(grbl_command):
grbl.write(str.encode(grbl_command)) # Send g-code block to grbl
grbl_out = grbl.readline().strip()
displayPosition_request(grbl_out)
infoScreen(grbl_out)
print(grbl_out) print(grbl_out)
def sendGRBL(): def sendGRBL():
@ -510,7 +511,7 @@ terminal_recv.grid(row = 0, column = 8, padx =10, pady =10,rowspan = 7, columnsp
mill_table.grid(row=0, column=4,padx=10, pady=10,columnspan = 4, rowspan = 7) mill_table.grid(row=0, column=4,padx=10, pady=10,columnspan = 4, rowspan = 7)
sendGRBL() #sendGRBL()
#BlockedButtons #BlockedButtons
blkbuttons = (up,down,left,right,z_up,z_down, zero_x, zero_y, zero_z, zero_all, setzero, gozero, spindle) blkbuttons = (up,down,left,right,z_up,z_down, zero_x, zero_y, zero_z, zero_all, setzero, gozero, spindle)