I’m experimenting with connecting a USB serial relay to a Mikrotik to allow remotely switch off some hardware. The protocol is crude and requires sending Hex to the serial port:
On: \A0\01\01\A2
Off: A0\01\00\A1
To send the hex I’m (ab)using at-chat, like so:
/interface/ppp-client> at-chat usb input=“\A0\01\01\A2”
The ON command worked fine, but OFF failed every time, so I’ve connected to serial interfaces back to back between the Mikroik and a Computer and created a basic script to read from the serial and print the received bytes as hex. This is the resulting data received when issuing the commands:
On: \A0\01\01\A2\0D
Off: A0\01
As you can see, the Mikrotik sends everything up to \00 and then stops. It also doesn’t send a CR.
Does anyone know of a work around, a fix, or anything else I’m overlooking?
I’m using ROS 7.8 on a hAP AC Lite. I also tried 6.48.6 but had issues with the serial port sending garbage, which might have been a driver issue or something…
Ran into something similar actually. While ../ppp at-chat does talk to an arbitrary port, it parses both input and output. AT commands can be null terminated, so AT part of “at-chat” gets in the way here.
Perhaps “wait=no” and splitting at the \00’s into multiple at-chat commands, might do something here…only thing to try…but highly doubt it.
They're all sent through as they were sent, without a NULL.
Thanks for the recommendations, but it looks like this is a non-starter unless Mikrotik add a feature to interact with a serial interface from scripts which seems unlikely.