Issue: On starting the machine the the Pi does not connect to MKS and shows an offline error. To connect need to open the Octoprint terminal and disconnect, and reconnect to the Pi to establish a connection with MKS.
Cause: Octoprint issue. The updated code snippet will solve the issue.
Solution:
Previous code snippet.
for result line:
if ‘FTDI’ in line:
self.MKSPort = line[line.index(‘ttyUSB’):line.index(‘ttyUSB’) + 7]
print self.MKSPort
if not self.MKSPort:
octopiclient.connectPrinter(port=”VIRTUAL”, baudrate=115200)
Updated code snippet.
for result line:
if ‘ch341-uart’ in line:
self.MKSPort = line[line.index(‘ttyUSB’):line.index(‘ttyUSB’) + 7]
print self.MKSPort
elif ‘FTDI’ in line:
self.MKSPort = line[line.index(‘ttyUSB’):line.index(‘ttyUSB’) + 7]
print self.MKSPort
if not self.MKSPort:
octopiclient.connectPrinter(port=”VIRTUAL”, baudrate=115200)
Works for both mks 2,1 and 1.4.