Using PERL API based on
https://github.com/akschu/MikroTikPerl, with my rework.
focus on problem:
after recive from router: "=message=no such item"
check the router is still something send to me, but not send: "Check read_len, got '0'"
OK, that's your API client... And the Perl code from which you call it (feel free to replace your router credentials)?
Trying a similar test with my router (and API client), I get, as expected:
MODE | LENGTH | LENGTH | CONTENTS
| (decoded) | (encoded) |
-----|-------------|--------------|--------------------------------------------
SEND | <prompt> | <prompt> | /system/script/environment/set
SEND | <prompt> | <prompt> | =numbers=status
SEND | <prompt> | <prompt> | =value=1465363657
SEND | <prompt> | <prompt> |
SENT | 30 | 0x1E | /system/script/environment/set
SENT | 15 | 0x0F | =numbers=status
SENT | 17 | 0x11 | =value=1465363657
SENT | 0 | 0x00 |
RECV | 5 | 0x05 | !trap
RECV | 21 | 0x15 | =message=no such item
RECV | 0 | 0x00 |
SEND | <prompt> | <prompt> | /put
SEND | <prompt> | <prompt> | =message=test
SEND | <prompt> | <prompt> |
SENT | 4 | 0x04 | /put
SENT | 13 | 0x0D | =message=test
SENT | 0 | 0x00 |
RECV | 5 | 0x05 | !done
RECV | 0 | 0x00 |
SEND | <prompt> | <prompt> |
SENT | 0 | 0x00 |
RECV | 5 | 0x05 | !done
RECV | 9 | 0x09 | =ret=test
RECV | 0 | 0x00 |
SEND | <prompt> | <prompt> |
SENT | 0 | 0x00 |
NOTE | Receiving timed out |
SEND | <prompt> | <prompt> | /quit
SEND | <prompt> | <prompt> |
SENT | 5 | 0x05 | /quit
SENT | 0 | 0x00 |
RECV | 6 | 0x06 | !fatal
RECV | 29 | 0x1D | session terminated on request
RECV | 0 | 0x00 |
NOTE | Connection terminated |
Notice how I do the second command before I get the first one's !done... Maybe if you were to keep reading until the !done sentence, and only send the second command there, it would work as you'd expect, e.g.
MODE | LENGTH | LENGTH | CONTENTS
| (decoded) | (encoded) |
-----|-------------|--------------|--------------------------------------------
SEND | <prompt> | <prompt> | /system/script/environment/set
SEND | <prompt> | <prompt> | =numbers=status
SEND | <prompt> | <prompt> | =value=1465363657
SEND | <prompt> | <prompt> |
SENT | 30 | 0x1E | /system/script/environment/set
SENT | 15 | 0x0F | =numbers=status
SENT | 17 | 0x11 | =value=1465363657
SENT | 0 | 0x00 |
RECV | 5 | 0x05 | !trap
RECV | 21 | 0x15 | =message=no such item
RECV | 0 | 0x00 |
RECV | 5 | 0x05 | !done
RECV | 0 | 0x00 |
NOTE | Receiving timed out |
SEND | <prompt> | <prompt> | /put
SEND | <prompt> | <prompt> | =message=test
SEND | <prompt> | <prompt> |
SENT | 4 | 0x04 | /put
SENT | 13 | 0x0D | =message=test
SENT | 0 | 0x00 |
RECV | 5 | 0x05 | !done
RECV | 9 | 0x09 | =ret=test
RECV | 0 | 0x00 |
NOTE | Receiving timed out |
SEND | <prompt> | <prompt> | /quit
SEND | <prompt> | <prompt> |
SENT | 5 | 0x05 | /quit
SENT | 0 | 0x00 |
RECV | 6 | 0x06 | !fatal
RECV | 29 | 0x1D | session terminated on request
RECV | 0 | 0x00 |
NOTE | Connection terminated |