Android phone as octoprint server

It might be a hidden file.

I'm honestly still stuck on getting the serial to work.
I do have a favor to ask though
Can you please post the output of tsu --version
If its not the latest version I can try to build an earlier version and install that.
Then maybe if it works I can be of further assistance

The message at the start is:
You are using a legacy Termux environment. Packages are unmaintained and will not receive any updates.

tsu --version doesn't work, keeps saying unknown option --. If I use pkg list-all I can see tsu/stable,now 2.3-1 all [installed]

Well seeing as tsu is now at 8.5.1.
That is quite old.

Actually can you use an apk extractor and extract termux and send it over?

EDIT: Found the legacy version on archive.org

I used apk extractor to create an apk from it but it wouldn't install on my phone. Probably better off with the one you have from the archive. I only installed Termux from the play store last week though, if you can find an Android 6.0.1 cyanogenmod rom and install Termux from the play store you should end up with the same version. It's working well enough for now, internal memory has a few GB spare so I'll probably leave the set up as is for now.

@ImTheBadWolf Sorry for my late reply, kinda got stuck with other projects. Link to working apk: https://drive.google.com/file/d/135vKG3A8h0nTFh0FyeIHUcQivRASvRiz/view

The only requirements are having a phone with at least Android lollipop and otg usb cable. Your phone doesn't need to be rooted.
It's def not finished, some stuff like automatic baudrate detection might be buggy, but it should print just fine :slight_smile:
Message me on discord if anyone wants to help out with the project ( Filip#9731).

2 Likes

Thank you for app, installed correctly but I can't connect to my printer throught octoprint interface. In your android app I see Printer is connected but I'm unable to connect to the printer throught octoprint server.

Any advice? I'm using auto port and baud rate set to 115200,my printer is ender 3.

Thank you for ideas

Try setting the port manually - maybe auto detect does not work? Also make sure that the custom plugin (I can't remember the name, something like Octo4A) is enabled too.

1 Like

Can you provide me with the logs you see in serial monitor?

Thank you for reply. Setting port manually didnt help - I dont see any port in drop down list, I was also trying to add it manualy throught setting. In this time I'm printing but I will check serial log tommorow.

I will post logs tommorow because I'm printing now. Thank you.

Log in the attachment. I was also checking plugin Β΄- octo4android is enabled.serial (1).log (2.0 KB)

I was also trying to install your app on another 2 devices (both rooted) but in both cases I got error - app stopped working after I hit install Octoprint button in the app.

I have a tx6 android tv box with real USB ports. I installed everything and tried connecting to the printer (lk4pro) but I see no printer
Where do I find it? Under /dev/what ?
Termux-usb -l shows no devices

Hey @Filip,

I built the app on my laptop and have installed it on an old phone. It starts the octoserver, it sees the connected printer, but octoprint doesn't see the serial port. I think it is a rights issue, could it be that the child process doesn't get the permission to access the serial devices ?

I'm investigating the issue right now, looks like it broke with some octoprint update. I'll try to upload the fix this week

Hi, I want to use my Android phone as print-server too, but sadly @Filip 's .apk crashed while installing octoprint. My phone in question is an ancient Galaxy S2 (almost 10 years old by now...), but it still gets unofficial LinageOS updates. Thing is the kernel doesn't supply a driver for /dev/ttyACM* devices, and I'm to lazy to recompile it. But thanks to a couple helpful pointers in here I came up with another solution:

I made an Octoprint plugin that uses termux-usb and libusb to talk to CDC-ACM usb-serial devices. I tested this on my Galaxy S2 with LineageOS 17.1 (=Android 10) and an Ender 3 with a SKR-Mini E3 board. It is a bit flaky, also when while printing the printer stutters because something is still not fast enough, and also after like a minute of printing the phone crashes :joy: But it works up to that point :partying_face:

If you want to try it, see code and basic instructions here: https://github.com/schuhumi/Termux_CDC_ACM

It's not exactly elegant, because it seems like you can only get the file descriptor for the usb device by running termux-usb -r -e myprogram.py /dev/bus/usb/001/011. So this Plugin opens a subprocess that starts the so called "cdcDaemon" with termux-usb. That Daemon uses the usb-fd to talk to the printer. The Daemon and Octoprint in turn are talking through two sockets (one for each direction).

2 Likes

Fixed a couple bugs and remembered I had a HTC 10 laying around as well -> Got my first smooth print off of an Android phone! :rocket: :grin: https://imgur.com/a/qw9E5Q3

This method should work with most devices as it neither needs root nor the dcd-acm driver in the kernel enabled.

1 Like

This is awesome! I think this is a very big deal. I have a new printer coming in and I'm going to set this up and report back.

Hey, @schuhumi

Trying to use the plugin in non rooted Honor 9. Almost there:

~ $ termux-usb -r /dev/bus/usb/001/002
Access granted.

Octoprint sees the port, but connections with 250000 baud rate failsl. 250000 is default for my printer, and I could communicate with it using other serial port connection apps. But here it fails:

2021-01-11 12:42:08,479 - octoprint.util.comm - ERROR - Unexpected error while connecting to serial port /dev/bus/usb/001/002, baudrate 250000 from hook Termux_CDC_ACM: timeout: 'timed out' @ comm.py:_open_serial:3666
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/octoprint/util/comm.py", line 3666, in _open_serial
    serial_obj = factory(
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/octoprint/util/__init__.py", line 1890, in wrapper
    return f(*args, **kwargs)
  File "/data/data/com.termux/files/home/.octoprint/plugins/Termux_CDC_ACM/__init__.py", line 95, in serial_printer_factory
    serial_obj = serial_printer(
  File "/data/data/com.termux/files/home/.octoprint/plugins/Termux_CDC_ACM/__init__.py", line 38, in __init__
    self.OOPIconn = self.OOPIlistener.accept()
  File "/data/data/com.termux/files/usr/lib/python3.9/multiprocessing/connection.py", line 468, in accept
    c = self._listener.accept()
  File "/data/data/com.termux/files/usr/lib/python3.9/multiprocessing/connection.py", line 614, in accept
    s, self._last_accepted = self._socket.accept()
  File "/data/data/com.termux/files/usr/lib/python3.9/socket.py", line 293, in accept
    fd, addr = self._accept()
socket.timeout: timed out

What could cause this?