printers-for-people / ACEResearch

Anycubic ACE Pro Reverse Engineering
3 stars 0 forks source link

Write a testing tool that runs on the Kobra 3 #7

Open Jookia opened 1 week ago

Jookia commented 1 week ago

After #5 is done we will need this for manual testing good cases and high-level functionality.

It should include the following functionality:

Being able to call this using an exec call in Python would be good for initial Klipper bring-up.

wiltwong commented 1 week ago

I compiled ser2net, screen, minicom and socat for the Kobra3 and they all work, however there is some handshake that is missing. If you kill off the anycubic processes (i.e. gkapi, gklib, gkcam and K3SysUi) the ACE Pro just keeps on connecting and disconnecting the USB, I am assuming there is some sort of handshake that needs to happen for it to stay connected.

[   19.129489] rtk_btcoex: BTCOEX hci_rev 0xbab7
[   19.129501] rtk_btcoex: BTCOEX lmp_subver 0x6f72
[   51.638125] adbd (658): /proc/658/oom_adj is deprecated, please use /proc/658/oom_score_adj instead.
[  285.066328] usb 1-1.3: new high-speed USB device number 3 using xhci-hcd
[  285.157061] [ac]usb_parse_endpoint:272,size=0,----
[  285.172569] hub 1-1.3:1.0: USB hub found
[  285.173064] hub 1-1.3:1.0: 4 ports detected
[  285.482993] usb 1-1.3.3: new full-speed USB device number 4 using xhci-hcd
[  285.573773] [ac]usb_parse_endpoint:272,size=0,----
[  285.588901] cdc_acm 1-1.3.3:1.0: ttyACM0: USB ACM device
[  294.036939] usb 1-1.3.3: USB disconnect, device number 4
[  294.439658] usb 1-1.3.3: new full-speed USB device number 5 using xhci-hcd
[  294.530395] [ac]usb_parse_endpoint:272,size=0,----
[  294.548491] cdc_acm 1-1.3.3:1.0: ttyACM0: USB ACM device
[  297.876941] usb 1-1.3.3: USB disconnect, device number 5
[  298.116317] usb 1-1.3.3: new full-speed USB device number 6 using xhci-hcd
[  298.207087] [ac]usb_parse_endpoint:272,size=0,----
[  298.228481] cdc_acm 1-1.3.3:1.0: ttyACM0: USB ACM device

...

[  330.132943] usb 1-1.3.3: USB disconnect, device number 14
[  330.369638] usb 1-1.3.3: new full-speed USB device number 15 using xhci-hcd
[  330.460388] [ac]usb_parse_endpoint:272,size=0,----
[  330.484500] cdc_acm 1-1.3.3:1.0: ttyACM0: USB ACM device
[  333.716945] usb 1-1.3.3: USB disconnect, device number 15
[  333.952976] usb 1-1.3.3: new full-speed USB device number 16 using xhci-hcd
[  334.043772] [ac]usb_parse_endpoint:272,size=0,----
[  334.068507] cdc_acm 1-1.3.3:1.0: ttyACM0: USB ACM device

... etc ... 
wiltwong commented 1 week ago

ser2net.tar.gz

Compiled ser2net is attached, untar and upload to Kobra 3, make ser2net executable and put the libraries (libasound.so.2, libyaml-0.so.2 and libgensio.so.0) in /ac_lib/lib/third_lib so they can be found by the library loader.

Kill off the Anycubic processes to release the USB serial ports

root@Rockchip:/# ps | grep gk
  346 root      803m S    ./gklib -a /tmp/unix_uds1 printer.cfg
  357 root      791m S    ./gkapi
  413 root     27596 S    ./gkcam
 1559 root      1208 S    grep gk
root@Rockchip:/# ps | grep Ui
  358 root     46244 S    ./K3SysUi
 1588 root      1208 S    grep Ui
root@Rockchip:/# kill 346 357 413 358 

Follow any example to get ser2net and socat working on /dev/ttyACM0 (i.e. https://www.acmesystems.it/socat)

Jookia commented 1 week ago

So ser2net and socat work but the ACE connects and disconnects without the Kobra's firmware running?

wiltwong commented 1 week ago

As soon as you kill off the Anycubic processes the ACE will start disconnecting and reconnecting.

Jookia commented 1 week ago

What if you connect to it using screen?

wiltwong commented 1 week ago

No difference, connecting via screen, minicom or ser2net the ACE pro just keeps on disconnecting and reconnecting. If I had to guess, the ACE firmware is connecting, waiting for some handshake or message and then disconnecting if it doesn't receive a message, it's probably designed that way so the Anycubic process running on the Kobra 3 only needs to listen to hot plug events (i.e. it doesn't constantly check to see what is connected, for example in the case when the ACE pro is connected when you power on the Kobra 3).

Jookia commented 1 week ago

Hmm. I would actually guess that this is probably some watchdog that resets the ACE and shuts down drying if you don't send a command every few seconds, like get_status.

wiltwong commented 1 week ago

When it connects the Kobra 3 sends a series of get_info requests, I've tried doing that manually, but maybe I have the format wrong or I am not fast enough.

Jookia commented 1 week ago

Are you sending them every second?

On Tue, Sep 03, 2024 at 11:59:19PM -0700, wiltwong wrote:

When it connects the Kobra 3 sends a series of get_info requests, I've tried doing that manually, but maybe I have the format wrong or I am not fast enough.

-- Reply to this email directly or view it on GitHub: https://github.com/printers-for-people/ACEResearch/issues/7#issuecomment-2328066972 You are receiving this because you authored the thread.

Message ID: @.***>

wiltwong commented 1 week ago

I have not gone as far as getting any automation done, it's on my list but probably won't get to it before you do!

WaresWichall commented 1 week ago

Hmm. I would actually guess that this is probably some watchdog that resets the ACE and shuts down drying if you don't send a command every few seconds, like get_status.

As far as I understand, the ACE can continue drying if you unplug the cable while it's drying. Unless they patched that out in recent firmware.

The Kobra 3 sends a MQTT message to the cloud as soon as the ACE is connected so what @wiltwong is saying makes sense to me.

Anycubic like to add random checks in odd places to try and protect all their proprietary stuff, even though they keep on promising "open source is coming"

Why do you think they made their own connector for the ACE units instead of using plain old USB connectors? ;)

Jookia commented 1 week ago

I would hope it stops drying as the printer can't monitor the thermistor while it dries.

MQTT messages don't have anything to do with the ACE's protocol, they could be done with a watchdog, with a handshake, or any combination of inner workings.

Let's not speculate about Anycubic's practices and instead focus on things we can test. If you have an ACE are you up for running tests on it?

WaresWichall commented 1 week ago

I would hope it stops drying as the printer can't monitor the thermistor while it dries.

My unit here continues drying after unplugging the cable, presumably forever.

Jookia commented 1 week ago

It doesn't turn off when dryed?

On Sat, Sep 07, 2024 at 04:44:13AM -0700, WaresMyHass wrote:

I would hope it stops drying as the printer can't monitor the thermistor while it dries.

My unit here continues drying after unplugging the cable, presumably forever.

-- Reply to this email directly or view it on GitHub: https://github.com/printers-for-people/ACEResearch/issues/7#issuecomment-2335161499 You are receiving this because you authored the thread.

Message ID: @.***>

Jookia commented 6 days ago

I'm continuing discussion about this watchdog/handshake in #9.