Issue sending 0x00 to Serial Port

Hi all,

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…

Thanks
Matthew

0x00 on at-chat is null terminating string… “end of the input”??? ( ^@ )…
so…


For avoid some surprises, regardless this issue, paste this on terminal:

/sys routerboard settings set enter-setup-on=delete-key

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.

I created a container and /port/remote-access to “proxy” the serial via HTTP and TCP to port:
https://github.com/tikoci/serial2http

But if you have another PC/etc., just the /port/remote-access might be another solution too.

0x00 on at-chat is null terminating string… “end of the input”??? ( ^@ )…

Ah, that will explain it then… Thanks for the info



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.

I don’t see that option unfortunatly ?

that command is on LTE interface… not ppp


try some of this, hoping RouterOS send NULL…
\A0\01\1B\00\A1
\A0\01\1B\40\A1
\A0\01\15\40\A1

Geez, I knew that. I actually have a feature request open for a wait= – so wishful thinking.

It may be sending it, dunno.

But the 2nd problem is may not get a response – it's looking for an "OK" (e.g. an implicit wait=yes).

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.