1. Those startup gocde won't execute after I reboot the Repetier-Server. It also no any startup gcode execute when deactivate printer and activate it.
2. After I execute those startup gcode manually, deactivate printer and activate can see Repetier-Server will execute those startup gcode.
For workaround, I have to add this python script and execute it at raspberrypi bootup.
import serial
import urllib, json, time, datetime, sys
#API Setting
apikey='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
urllistPrinter = '
http://localhost:3344/printer/api/3DPrinter?apikey='+apikey+'&a=listPrinter'
urlgetFirmwareData = '
http://localhost:3344/printer/api/3DPrinter?apikey='+apikey+'&a=getFirmwareData'
urlsendCMD = '
http://localhost:3344/printer/api/3DPrinter?apikey='+apikey+'&a=send&data={"cmd":"##GCODE##"}'
theCMDs = [ "M110 N0" , "M105" , "M115" , "M220 S100" , "M221 S100" , "M355" , "G92 E0" , "G90" , "M82" , "G21" , "M114" , "G90" , "M111 S6" , "M360" , "M539 S1" , "@getip" ]
isconnected = False
try:
print('Get printer connect status ...')
response = urllib.urlopen(urllistPrinter)
data = json.loads(response.read())
print(data)
theprinteronline = data[0]['online']
theprinteractive = data[0]['active']
if theprinteronline == 1 and theprinteractive == True :
print('printer is connected ...')
isconnected = True
except:
print('Cannot execute API ... may be normal...')
try:
if not isconnected :
print('Try to kick start the Due board ...')
ser = serial.Serial( port='/dev/serial/by-id/usb-Arduino
www.arduino.ccArduino_Due_Prog._Port_55730323831351411151-if00', baudrate=115200, parity=serial.PARITY_ODD, stopbits=serial.STOPBITS_TWO, bytesize=serial.SEVENBITS )
if ser.isOpen():
ser.close()
else:
print('no need to kick start the Due board...')
except:
print('Fail to connect serial port... exit()')
exit()
while 1:
try:
print('Get printer connect status ...')
response = urllib.urlopen(urllistPrinter)
data = json.loads(response.read())
print(data)
theprinteronline = data[0]['online']
theprinteractive = data[0]['active']
if theprinteronline == 1 and theprinteractive == True :
print('printer is connected ...')
break
except:
print('Exception - Fail to execute API')
print('Printer not connected - Wait 10 sec ...')
time.sleep(10)
counttry=0
countcmd=0
while 1:
try:
print('Get firmware status ...')
response = urllib.urlopen(urlgetFirmwareData)
data = json.loads(response.read())
print(data)
thefirmware = data['firmware']['firmware']
thefirmwarename = data['firmware']['name']
if thefirmwarename == 'Repetier-Firmware':
if thefirmware == '':
#if thefirmware == 'Repetier_1.0.3':
print('Execute startup GCODE ...')
for thecmd in theCMDs:
time.sleep(0.5)
print('Send CMD: '+thecmd)
theurl = urlsendCMD.replace('##GCODE##',thecmd)
response = urllib.urlopen(theurl)
data = response.read()
if data == '{}':
countcmd += 1
print(str(countcmd) + ' command executed')
else:
print('Check passed - Exit')
break
except:
print('Exception - Fail to execute API')
counttry += 1
print('Sleep 5 sec ... and retry('+str(counttry)+') ...')
time.sleep(5)
<div>
</div>