Http Post in Macro?
-
-
Rethinking the original question, you don't need to even go that far - just monitor the filament out sensor directly with the ESP8266 ... no need to parse the console stream.
-
The entire philosophy of networking built into Duet/RepRap Firmware as supplied by Duet, or if you prefer, Dave, is that things query it (perhaps repetitively, i.e. 'poll'); it does not push. To my knowledge, this has never been stated anywhere; nonetheless, it is quite clear if you look at how it works, and what feature requests have been implemented, and not, over the years.
DSF on the Pi offers an opportunity to change that, without changing the underlying Firmware and/or DSF. There is an explicit intercept API that can be used from almost any language:
https://github.com/chrishamm/DuetSoftwareFramework#interception-mode
-
For the original use case, "intercept" and then look for something unique to the pause.g, up to and including an M117 with a specific string in the message.
When detected, you can then do anything a Pi can do... which is incredibly flexible.
-
@clearlynotstef said in Http Post in Macro?:
the duet is obviously already connected to the network and sharing data all over the place.
btw, thats not quite true. the only thing the duet sends out is dhcp requests and mdns in the versions where that is supported; everything else is initiated from a client afaik.
-
@bearer said in Http Post in Macro?:
@clearlynotstef said in Http Post in Macro?:
the duet is obviously already connected to the network and sharing data all over the place.
btw, thats not quite true. the only thing the duet sends out is dhcp requests and mdns in the versions where that is supported; everything else is initiated from a client afaik.
Exactly. For whatever reason, it doesn't originate any TCP connections. (both dhcp and mdns are UDP or UPD-like, anyway, no actual connection). It expects to be polled.
-
I've got an m42 in pause.g flipping a gpio pin connected to an 8266 which handles the http get which notifies me different ways based on where I am or what I'm doing. Next question. Can I have the Filament monitor call a different macro than pause.g? I'd still like to occasionally pause my print with the pause button without setting these events in motion. Related second question, can I run a macro from within a second macro? The most efficient thing would be to have the Filament monitor run filamentout.g which would consist of the m42+run pause.g so updates to pause.G would apply to both but I'd still be able to pause manually without notifying myself.
-
@clearlynotstef said in Http Post in Macro?:
Can I have the Filament monitor call a different macro than pause.g?
not without making changes to the firmware afaik.
but you can connect the filament monitor to the esp and have the esp execute M98 filamentmonitor.g over http/telnet/serial.
-
@clearlynotstef said in Http Post in Macro?:
can I run a macro from within a second macro?
Yes. M98 p"/sys/macro.g" or p"/macros/macro.g"
Can I have the Filament monitor call a different macro than pause.g
Not if it is set up as the filament monitor.
However, if you connect the hardware filament monitor to a GPIO pin and set a trigger, that trigger can pause, and do anything else you can do from a macro.
-
Was going to make a new thread but I guess let's keep this all in here. Does anyone know if the extra gpio pins that can be M42'd are pulled down if switched off (S0) or if they're just floating? Based on my printer paused notification I just got even though I'm not printing anything, I'm assuming it's floating?
-
If it is the correct pin, which is sometimes very hard to figure out what's what, a M42 S0 should cause it to pull down. It would be capable of sinking current up to the spec of the chip, usually under 20ma.
-
@Danal that's surprising! Floating would have explained everything. I'm pretty positive it's the right pin, and I did test it 5 or 6 times in a row, S0 to s1 back and forth and watching the notifications track perfectly. I guess I'll throw a 10k resistor from gnd on the esp8266 to the input pin on the esp8266 and see if that helps? I'm no electrical engineer over here lol
-
It can sink or source 2mA, 4mA on a few select pins; (20mA is for the 8bit chips like attiny/atmega)
Some pins have pull up/downs in hardware, others configured in firmware; gotta check schematics and config to be sure.
-
@bearer said in Http Post in Macro?:
It can sink or source 2mA, 4mA on a few select pins; (20mA is for the 8bit chips like attiny/atmega)
Some pins have pull up/downs in hardware, others configured in firmware; gotta check schematics and config to be sure.
WOW, good to know!!!
-
@clearlynotstef said in Http Post in Macro?:
@Danal that's surprising! Floating would have explained everything. I'm pretty positive it's the right pin, and I did test it 5 or 6 times in a row, S0 to s1 back and forth and watching the notifications track perfectly. I guess I'll throw a 10k resistor from gnd on the esp8266 to the input pin on the esp8266 and see if that helps? I'm no electrical engineer over here lol
Approx 70K to 130K, nominal 100K is what the SAM4E series does internally for pull up or down, so I'd just copy that.
-
@bearer I'm using duet2 WiFi, pin CS5, logical pin 60, expansion header pin 50. Any idea?
-