Mrnt / OctoPrint-FlashForge

OctoPrint plugin to support closed source printers from FlashForge, PowerSpec, Dremel
GNU General Public License v3.0
87 stars 12 forks source link

Dremel 3D20: Timeouts while Connecting w/M27 #40

Closed eduncan911 closed 4 years ago

eduncan911 commented 4 years ago

New install (on an x64 device, no RPi). First time using OctoPrint, and this plugin.

Wiped and installed twice now; however, I've been unable to connect to the printer. Sometimes it does connect, but I am unable to send any commands - and it Times Out.

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0424:2530 Microchip Technology, Inc. (formerly SMSC) BOSCH Dremel 3D Printer
Bus 001 Device 002: ID 0424:4603 Microchip Technology, Inc. (formerly SMSC)
Bus 001 Device 004: ID 2a89:8889 BOSCH BOSCH Dremel 3D Printer

Yep, that's all this device has connected via USB. ;)

I am installing per README, and followed the master zip file approach, as well as just searching Get more and installing that way.

Tried to restart the octoprint service and checked the logs (this is outputted from systemd logs that I have setup):

Aug 18 02:00:29 up-printer-1 python3[1282]: 2020-08-18 02:00:29,649 - octoprint.plugins.pluginmanager - INFO - Loaded notice data from disk, was still valid
Aug 18 02:00:30 up-printer-1 python3[1282]: 2020-08-18 02:00:30,001 - octoprint.plugins.pluginmanager - INFO - Loaded notice data from disk, was still valid
Aug 18 02:00:35 up-printer-1 python3[1282]: 2020-08-18 02:00:35,041 - octoprint.server.preemptive_cache - INFO - ... done in 5.42s
Aug 18 02:00:39 up-printer-1 python3[1282]: 2020-08-18 02:00:39,910 - octoprint.plugins.flashforge - INFO - Found a Dremel Dremel IdeaBuilder 3D20
Aug 18 02:00:39 up-printer-1 python3[1282]: 2020-08-18 02:00:39,955 - octoprint.plugins.flashforge - INFO - Found a Dremel Dremel IdeaBuilder 3D20
Aug 18 02:00:40 up-printer-1 python3[1282]: 2020-08-18 02:00:40,172 - octoprint.plugins.flashforge - INFO - Found a Dremel Dremel IdeaBuilder 3D20

I found the logs to this Octoprint instance and saw this:

2020-08-18 02:00:54,001 - octoprint.util.comm - ERROR - Unexpected error while connecting to serial port unknown, baudrate 250000 from hook flashforge: FlashForgeError: '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Unable to connect to FlashForge printer - permission error.

If you are using OctoPi/Linux add permission to access this device by editing file:
 /etc/udev/rules.d/99-octoprint.rules

and adding the line:
SUBSYSTEM=="usb", ATTR{idVendor}=="2a89", MODE="0666"

You can do this as follows:
1) Connect to your OctoPi/Octoprint device using ssh
2) Type the following to open a text editor:
sudo nano /etc/udev/rules.d/99-octoprint.rules
3) Add the following line:
SUBSYSTEM=="usb", ATTR{idVendor}=="2a89", MODE="0666"
4) Save the file and close the editor
5) Verify the file permissions are set to "rw-r--r--" by typing:
ls /etc/udev/rules.d/99-octoprint.rules
6) Reboot your system for the rule to take effect.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Easy enough. Did the above, and I was able to connect!

However, I ran into more errors:

2020-08-18 02:28:50,625 - octoprint.util.comm - ERROR - Unexpected error while connecting to serial port /dev/ttyS0, baudrate 250000 from hook default: SerialException: '[Errno 13] could not open port /dev/ttyS0: [Errno 13] Permission denied: '/dev/ttyS0'' @ comm.py:_open_serial:2781
Traceback (most recent call last):
  File "/home/eric/.virtualenvs/octoprint/lib/python3.8/site-packages/serial/serialposix.py", line 265, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
PermissionError: [Errno 13] Permission denied: '/dev/ttyS0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/eric/.virtualenvs/octoprint/lib/python3.8/site-packages/octoprint/util/comm.py", line 2781, in _open_serial
    serial_obj = factory(self,
  File "/home/eric/.virtualenvs/octoprint/lib/python3.8/site-packages/octoprint/util/comm.py", line 2761, in default
    serial_obj.open()
  File "/home/eric/.virtualenvs/octoprint/lib/python3.8/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyS0: [Errno 13] Permission denied: '/dev/ttyS0'
2020-08-18 02:28:50,636 - octoprint.util.comm - INFO - Serial detection: Could not open port /dev/ttyS0, baudrate 250000, skipping
2020-08-18 02:28:50,638 - octoprint.util.comm - INFO - Serial detection: Trying port BOSCH Dremel 3D Printer, baudrate 115200
2020-08-18 02:28:50,653 - octoprint.util.comm - INFO - Serial detection: Handshake attempt #1 with timeout 2.0s
2020-08-18 02:28:50,659 - octoprint.util.comm - INFO - Changing monitoring state from "Detecting serial connection" to "Operational"
2020-08-18 02:28:50,716 - octoprint.plugins.flashforge - INFO - Found a Dremel Dremel IdeaBuilder 3D20

Checking, there seems to be a special dialout group assigned to these serial ports. So I added my printer user to it:

$ ls -la /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Aug 18 02:11 /dev/ttyS0

A quick add:

$ sudo gpasswd --add printeruser dialout
Adding user upuser to group dialout
$ sudo gpasswd --add upuser tty
Adding user upuser to group tty
$ sudo reboot

However, I keep seeing the logs show timeout. And I see this in the gcode tab in OctoPrint:

Changing monitoring state from "Offline" to "Opening serial connection"
Connecting to port /dev/ttyS0, baudrate 115200
Changing monitoring state from "Opening serial connection" to "Connecting"
Connected to: Serial<id=0x7f64bc4b9dc0, open=True>(port='/dev/ttyS0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=10.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor
Send: M601 S0
No answer from the printer within the connection timeout, trying another hello
Send: M601 S0

And it will continue that way.

eduncan911 commented 4 years ago

FYI, I'll report on my testing soon when I can.

Mrnt commented 4 years ago

Sounds good - just reopen if the same bug occurs. There is already a separate issue for timeout during upload to SD.

Fred583 commented 4 years ago

Awesome, thanks for taking the time to fix it! Edit: I didn't realize it had already been 22 days. School is boring

eduncan911 commented 4 years ago

I actually was trying this today and ran into several issues with the latest OctoPrint and this plugin versions.

I just didn't have time to debug... Will try to find more time. However, just wanted to note that upgrading to the latest across the board broke the saved settings I had to connect to the Dremel.

IIRC, it was something around M117 returned invalid and connection was closed.

Mrnt commented 4 years ago

@eduncan911 do you remember if you were you using version 0.2.2 before?

Mrnt commented 4 years ago

@eduncan911 can you upload an octopi.log with the error?

eduncan911 commented 4 years ago

Well, my last debug/functional comment about being able to close this issue was 28 days ago. That was the last time I used OcroPrint with it (the kids have been just using the sdcard in the meantime). So whatever version was active then, or the changes I made manually, was what I was using.

I see 0.2.2 was released well after my last debugging streak. So the answer would be Nope.

One other comment: because an "upgrade of everything across the board" such as OctoPrint, and many other plugins happened all at once, it may be related to OctoPrint as well.

I logged into OctoPrint, saw there were many upgrades, upgraded everything, and then tried to print and ran into trouble as-is. No config changes or anything.

Then I tried wiping out all plugins, to go back to mostly stock OctoPrint.

I've noticed the connection settings have all moved to under Settings with the latest OctoPrint. I tried playing with this, but to no avail.

That was the farthest I made it, before turning back to using the sdcard to get it printed (it's almost done, an 18 hour print!).

Yep, when I get time I'll set it all up and will debug. But no time ATM.