Feature request: Scripting serial-terminal

Hello,

I really really (really :wink: ) could need a scripting feature for serial ports, i.e. being able to send out a string over a serial port etc.

Something like

/system serial-terminal serial1 send "the string to send out"

or the like…

Shouldn’t be too complicated?! And would help a lot…

Best regards,
Christian Meis

you can do this with interface ppp client

Just discovered that, too. But it’s a bit cumbersome…

I want to share the solution I came up with with the other forum members, just in case someone needs it someday:

To send out a string over a serial port, you can use this:

/interface ppp-client add name="scripttemp" port=serial0 modem-init="I am the string" null-modem=yes disabled=no
:delay 1
/interface ppp-client remove [/interface ppp-client find name="scripttemp"]

This assumes that:

  • you want to use port serial0
  • you have configured port serial0 (baud rate etc.)
  • port serial0 is not used by serial-console

It will print the string configured as modem-init string to the serial port (in the example that would be ā€œI am the stringā€ (without the quotes)).
Setting null-modem to yes stops RouterOS to send an ā€œATHā€ command (hang up) before doing anything else.
You have to disable (or remove, like above) the interface quickly after creating or enabling it, because some seconds after the init string RouterOS will try to negotiate PPP over the link anyway, and we don’t want to get this to get out over the serial port.

Perhaps someone can come up with a more elegant solution, but this seems to work.

What does not always work, though, is to just have the ppp-plient configured and disabled and then just enabling it for one second to send out the text. Sometimes after enabling it would send out the init string in my tests, but sometimes not and just start PPP ngeotiation right away…

Best regards,
Christian Meis

And yes, it is in the Wiki (now) :smiley:

Best regards,
Christian Meis

nice, thanks :slight_smile:

Hej Cmit,

Is this possible to send via rs232 in initial string something like this:

ā€˜Hello’+#10+#13 (line feed character, cf character)

If not , how i can do it with mikrotik.

Please help.