Ran into similar stuff myself. The serial port just isn’t very scriptable in RouterOS. There certainly no equivalent of the old UNIX expect, but more fundamentally there isn’t some basic read/write operation for serial.
Couple ideas but no ideal for the KNOT.
-
What they let you do is convert serial into TCP data (either raw sockets or rfc2217/telnet). See /ports/remote-access. This lets you send serial data to someplace else, like office or cloud. But for something like a pump, you’d like want to be able to turn that on without internet. I built a container “serial2http” (http://forum.mikrotik.com/t/serial2http-container-to-bridge-serial-to-the-routeros-cli/164589/1) that takes the TCP to essentially proxy serial data via HTTP requests that do this locally…BUT the KNOT doesn’t support containers so it won’t work.
-
I’ve used these Texxmo IoT buttons that send an HTTP request upon press, so these can be used to trigger a script via REST on the Mikrotik. https://www.texxmo.info/get-your-iot-buttons/ but not sure they actively sell them, we haven’t used them in a while. I guess you could put in it physical key box or similar with analog combo log. Or maybe some like similar device with keypad exists that more Wi-Fi friendly for the KNOT.
-
The scripting language does support :inkey which waits for keyboard input, so if the keypad acted as HID device. Perhaps that might be useful, still the serial port can NOT be routed directly to a script, only the command line – which doesn’t help since you’d need to accept a PIN code as the first keypresses. Not a command to launch a script…
So not a lot of instant ideas for your problem. Mikrotik scripting language was built for routing, so the I/O operations are rather limited, and they only “recently” started getting into IoT gateway things, but the language hasn’t been extended to support them particular well. And you can’t just load some driver/program into RouterOS.
Maybe someone else has ideas here, but this “authenticated push to start script”… I dunno of any good ones.