简体   繁体   English

Linux -OpenWrt-(未连线)python wlan接口扫描错误

[英]Linux -OpenWrt- (Unwired One) python wlan interface scan error

The thing I am trying to achive, I want my android app to get a list of all available wlan connections within the range of a device with a wlan (at that point the device is an access point). 我想达到的目的是,我希望我的Android应用程序获取具有wlan的设备范围内的所有可用wlan连接的列表(此时该设备是访问点)。 Then I want to tell that device to which network to connect. 然后,我想告诉该设备要连接到哪个网络。 So far so good. 到现在为止还挺好。

I am trying to access the wlan module on my openwert device via python. 我正在尝试通过python访问我的openwert设备上的wlan模块。 I am using this [1] python module. 我正在使用[1] python模块。 When I execute the following example code 当我执行以下示例代码时

python iwlist.py wlan0 scanning

i get the error 我得到错误

Interface does not support scanning

Then I started to dig inside of the code, and the real error message is this one: 然后,我开始深入研究代码,真正的错误消息是:

Argument list too long

and this error is comming from the module (from the file iwlibs.py). 并且此错误来自模块(来自文件iwlibs.py)。 The exact code snippet (class Iwrange, update()) where it is comming from : 来自的确切代码片段(类Iwrange,update()):

buff, s = iwstruct.pack_wrq(640)
print "Now comes the error"
status, result = iwstruct.iw_get_ext(self.ifname,
                                    pythonwifi.flags.SIOCGIWRANGE,
                                    data=s)

I dont know if it is of any help, but I also checked the buff variable and it just says 0x00 (I guess there should be some other stuff too bcz it is indicating some address in the memory, but of course I could be wrong too and the buffer is just being initialized there). 我不知道这是否有帮助,但是我也检查了buff变量,它只是说0x00(我想应该还有其他东西,因为bcz表示内存中有一些地址,但是我当然也可能错了并且缓冲区只是在那里被初始化)。

So, I am not sure what the problem is, it seems to me, maybe, that the reserver space (or buffer?) is too small for the stuff that is being returnd. 因此,我不确定问题出在哪里,也许在我看来,对于返回的内容而言,存储空间(或缓冲区?)是否太小。 Does anybody know what else I could try in order to get this working ? 有人知道我还能尝试什么才能使它正常工作吗?

And one more thing, I also downloaded wireless_tools and now I can use iwlist. 另外,我还下载了wireless_tools,现在可以使用iwlist。 I can also scan and get the list of all surrounding wlan networks. 我还可以扫描并获取所有周围无线局域网的列表。 So it seems the hardware is working fine, I am just not accessing it properly with python 所以看来硬件工作正常,我只是无法使用python正确访问它

[1] https://pypi.python.org/pypi/python-wifi/0.6.1 [1] https://pypi.python.org/pypi/python-wifi/0.6.1

Just as an info, i solved my issue by changing the module I have been using. 就像一个信息一样,我通过更改我一直在使用的模块解决了我的问题。 Now I am using [1]. 现在我正在使用[1]。 When I execute this code 当我执行这段代码

from wifi import Cell, Scheme
print "%s" %(Cell.all('wlan0'))

I get a list with all surrounding networks. 我得到了所有周围网络的清单。 Then I have just to choose one of them (by the SSID) and make my connection 然后,我只需选择其中一个(通过SSID)并建立连接

[1] https://wifi.readthedocs.io/en/latest/ [1] https://wifi.readthedocs.io/en/latest/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM