frostspb / aio_api_ros

Async implementation Mikrotik api (apiros)
MIT License
23 stars 7 forks source link

怎么使用 #1

Closed mrli20182018 closed 5 years ago

mrli20182018 commented 5 years ago

image

请问怎么使用?

frostspb commented 5 years ago

i think u must del lead space in mk.talk_word('/ip/service/print') its looks like mk.talk_word(' /ip/service/print')

can you try this code?

res = await mk.read(256) # or 64 or something
print(res.decode())
mrli20182018 commented 5 years ago

我认为你必须在 mk.talk_word('/ip/service/print') 它的外观中引领空间 mk.talk_word(' /ip/service/print')

你能试试这段代码吗?

res =  await mk.read(256)#或64或
print(res.decode())

image

我是新手

image 能返回所有结果吗?

frostspb commented 5 years ago

This should help

res = await mk.read(1024)

Its low level function. I think , in the next version I will make a function to read the full response

frostspb commented 5 years ago

OK. I have released a new version 0.0.8. Now the function "read" parses the answer with flag parse=True (default behavior)

res = await mk.read() 
print(res)

if you need original response

res = await mk.read(parse=False) 
print(res.decode())
mrli20182018 commented 5 years ago

好。 我发布了0.0.8的新版本。现在函数“read”用flag parse = True解析答案(默认行为)

res =  await mk.read() 
 print(res)

如果你需要原始回复

res =  await mk.read(parse = False) 
 print(res.decode())

image 不是返回所有?

frostspb commented 5 years ago

Fixed in v 0.0.9

if you want to see full personse:

res =  await mk.read(full_answer=True)

result:

('!re', None, {'.id': '*8', 'name': 'winbox', 'port': 8291, 'address': '', 'invalid': False, 'disabled': False})

('!re', None, {'.id': '*9', 'name': 'api-ssl', 'port': 8729, 'address': '', 'certificate': 'none', 'invalid': False, 'disabled': False})

('!done', None, {})

without this params:

res =  await mk.read()
{'.id': '*8', 'name': 'winbox', 'port': 8291, 'address': '', 'invalid': False, 'disabled': False}
{'.id': '*9', 'name': 'api-ssl', 'port': 8729, 'address': '', 'certificate': 'none', 'invalid': False, 'disabled': False}
mrli20182018 commented 5 years ago

image

这就是我要的
谢谢 api语法我还不是很会

frostspb commented 5 years ago

Thank you for testing