No such file or directory
Salut ;
Je suis entrain de développer une interface graphique pour envoyer un code G a Grbl , j'ai donc essayé ce code la mais quand je l'éxecute sur Raspberry y a une erreur qui m'affiche : No such file or directory 'grbl.code' .
Voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
import serial
import time
# Open grbl serial port
s = serial.Serial('/dev/ttyS0',115200)
# Open g-code file
f = open('somefile.gcode','r');
# Wake up grbl
s.write("\r\n\r\n")
time.sleep(2) # Wait for grbl to initialize
s.flushInput() # Flush startup text in serial input
# Stream g-code to grbl
for line in f:
l = line.strip() # Strip all EOL characters for streaming
print ('Sending: ' + l,
s.write(l + '\n')) # Send g-code block to grbl
grbl_out = s.readline() # Wait for grbl response with carriage return
print( ' : ' + grbl_out.strip())
# Wait here until grbl is finished to close serial port and file.
raw_input(" Press <Enter> to exit and disable grbl.")
# Close file and serial port
f.close()
s.close() |
Merçi
'str' does not support the buffer interface
Salut ;
j'ai essayer d'ouvrir un fichier g code et l'envoyer par un port serie mais quand je l'execute il me sort une erreur : 'str' does not support the buffer interface
voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
import serial
import time
# Open grbl serial port
s = serial.Serial('/dev/ttyS0',115200)
# Open g-code file
f = open(r'/home/pi/Downloads/spinner.gcode');
# Wake up grbl
s.write("\r\n\r\n")
time.sleep(2) # Wait for grbl to initialize
s.flushInput() # Flush startup text in serial input
# Stream g-code to grbl
for line in f:
l = line.strip() # Strip all EOL characters for streaming
print ('Sending: ' + l,
s.write(l + '\n')) # Send g-code block to grbl
grbl_out = s.readline() # Wait for grbl response with carriage return
print( ' : ' + grbl_out.strip())
# Wait here until grbl is finished to close serial port and file.
raw_input(" Press <Enter> to exit and disable grbl.")
# Close file and serial port
f.close()
s.close() |
Merçi