Fixed missing gcode commands queue

added txt logging
This commit is contained in:
Thomas Herrmann 2021-12-22 00:30:45 +01:00
parent b4b743a9d0
commit 0c771a96e5

11
cnc.py
View File

@ -236,7 +236,7 @@ def grblWrite():
switchButtonState(button) switchButtonState(button)
fopen.config(bg = 'grey') fopen.config(bg = 'grey')
def timedPositionRequest():# >Im Falle das kein GCODE gestremed wird< Abfragen der Momentanen Position nach 1000ms sendet über den "byPass" channel der den GCode Stream nicht beeinflusst def timedPositionRequest():# >Im Falle das kein GCODE gestreamed wird abfragen der momentanen Position nach 1000ms sendet über den "byPass" channel der den GCode Stream nicht beeinflusst
if grbl != 0 and freetosend == 1: if grbl != 0 and freetosend == 1:
grbl_command = '?' grbl_command = '?'
byPass(grbl_command) byPass(grbl_command)
@ -277,7 +277,7 @@ def debugWrite(grbl_command):
infoScreen(grbl_out) infoScreen(grbl_out)
print(grbl_out) print(grbl_out)
def sendGRBL(): def sendGRBL(): #Komplette Gcodes streamen senden
global writebuffer global writebuffer
global freetosend global freetosend
@ -286,17 +286,22 @@ def sendGRBL():
#print ("current",writebuffer[0]) #print ("current",writebuffer[0])
#print (writebuffer) #print (writebuffer)
grbl.write(str.encode(writebuffer[0])) # Send g-code block to grbl grbl.write(str.encode(writebuffer[0])) # Send g-code block to grbl
#writeToFileLog(writebuffer[0])
#grbl.timeout = None #grbl.timeout = None
readbuffer.append(grbl.readline().strip()) # Wait for grbl response with carriage return readbuffer.append(grbl.readline().strip()) # Wait for grbl response with carriage return
del writebuffer[0] del writebuffer[0]
if len(readbuffer) == 5: if len(readbuffer) == 5:
writebuffer.insert(2,'?') writebuffer.insert(2,'?' + '\n') #newline need?
displayPosition() displayPosition()
infoScreen(readbuffer[0]) infoScreen(readbuffer[0])
readbuffer.clear() readbuffer.clear()
freetosend = 1 freetosend = 1
def writeToFileLog(log): #Log für Debugzwecke
with open("log.txt", 'a') as out:
out.write(log)
def displayPosition_request(grbl_pos): def displayPosition_request(grbl_pos):
if grbl != 0 : if grbl != 0 :
try: try: