I'm add '/print' to request, of course
I'm using my own class, with Read() method from example, but use BinaryReader inside
public List<string> Read()
{
List<string> output = new List<string>();
string o = "";
byte[] tmp = new byte[4];
long count;
while (!readCancelationSource.IsCancellationRequested)
{
tmp[3] = (byte)streamReader.Read();
//if(tmp[3] == 220) tmp[3] = (byte)connection.ReadByte(); it sometimes happend to me that
//mikrotik send 220 as some kind of "bonus" between words, this fixed things, not sure about it though
if (tmp[3] == 0)
{
output.Add(o);
if (o.Substring(0, 5) == "!done")
{
break;
}
else
{
o = "";
continue;
}
}
else
{
if (tmp[3] < 0x80)
{
count = tmp[3];
}
else
{
if (tmp[3] < 0xC0)
{
int tmpi = BitConverter.ToInt32(new byte[] { (byte)streamReader.Read(), tmp[3], 0, 0 }, 0);
count = tmpi ^ 0x8000;
}
else
{
if (tmp[3] < 0xE0)
{
tmp[2] = (byte)streamReader.Read();
int tmpi = BitConverter.ToInt32(new byte[] { (byte)streamReader.Read(), tmp[2], tmp[3], 0 }, 0);
count = tmpi ^ 0xC00000;
}
else
{
if (tmp[3] < 0xF0)
{
tmp[2] = (byte)streamReader.Read();
tmp[1] = (byte)streamReader.Read();
int tmpi = BitConverter.ToInt32(new byte[] { (byte)streamReader.Read(), tmp[1], tmp[2], tmp[3] }, 0);
count = tmpi ^ 0xE0000000;
}
else
{
if (tmp[3] == 0xF0)
{
tmp[3] = (byte)streamReader.Read();
tmp[2] = (byte)streamReader.Read();
tmp[1] = (byte)streamReader.Read();
tmp[0] = (byte)streamReader.Read();
count = BitConverter.ToInt32(tmp, 0);
}
else
{
//Error in packet reception, unknown length
break;
}
}
}
}
}
}
var b = new byte[count];
for (int i = 0; i < count; i++)
{
b[i] = (byte)streamReader.Read();
}
o += Encoding.Default.GetString(b);
}
return output;
}
No problem with other requests.