I have Octo4A installed on my old cell phone.
The cell phone's USB port is connected to a USB hub with the printer and my arduino connected.
I am able to control the printer as expected.
Both of the devices show up on the USB list:
I ssh'd into the root account using putty and ran this command:
python3 -m serial.tools.list_ports
It responded with
no ports found
I made a plugin and installed it and it gives the same response.
I confirmed I uninstalled serial and installed pyserial:
pip uninstall serial
pip install pyserial
When I connect the arduino to my computer via USB and run the list ports function in python.
I'm able to connect to my arduino via COM3 and write to the serial to control it.
But I'm not able to even see list the device using python on the android phone.
How can I open a com port to my arduino so I can control it via octoprint plugin?
I've done that with my plugin. The code is little messed, but I think you will find what you want (check the level branch): https://github.com/SinisterRj/Octoprint_SafetyPrinter
Look at the Connection.py
I am able to get it to work on octoprint for windows using COM5 and COM6, but on Octo4a (octoprint for android). It only lists one serial port which is called
/dev/ttyOcto4a. So I can't communicate with the arduino exclusively. Both the printer and the arduino try to read the serial, but only one does. Whichever was connected first. How can I fix this?
Android is a kind of Linux. Linux and windows has a very different ways of listing serial comm. ports. I have no experience with Android, but in Linux all serial ports are listed in dev/serial. This kind of port with Octo4a should be a specific android solution to define the printer port..
I tried the android app "Serial USB Terminal" and its able to connect to each port individually to communicate with them. How can I connect to a USB port individually in the terminal or in the plugin via python?
The app did list both ports as having the exact same name and ids though, but it was able to connect to them individually anyways.
SSH into the phone and look at:
/dev/serial/by-id folder. If you have 2 serial devices connected then you should have 2 "files" or IDs there. You can use this path to connect to each one of them on pyserial.
If I remember correctly, Octo4a has a custom way of managing the serial port connection through it's app. The user that O4A runs as in the app doesn't have permission to list the serial ports, it just gets given
/dev/ttyOcto4a or something along those lines, rather than an actual list of devices (due to how the app is setup). This might mean that this kind of plugin doesn't work on an android phone, and only standard installs on other OSes.