我在我的 ev3 砖上安装了 ev3dev,这样我就可以用 python 在上面创建程序。我正在尝试使用可在此处找到的 python 的“rpyc”库。但是,当我尝试运行上面链接中作为示例给出的这个基本脚本时:
import rpyc
conn = rpyc.classic.connect('192.168.137.3') # host name or IP address of the EV3
ev3 = conn.modules['ev3dev.ev3'] # import ev3dev.ev3 remotely
m = ev3.LargeMotor('outA')
m.run_timed(time_sp=1000, speed_sp=600)
我通过终端收到多个错误,然后连接关闭。我已按照页面上的所有说明进行操作,并且事先在 ev3 砖块上启动了服务器脚本。当我运行上述程序时,会显示来自 python 的错误:
Traceback (most recent call last):
File "C:/Python27/cooode/moottertest.py", line 2, in <module>
conn = rpyc.classic.connect('192.168.137.3') # host name or IP address of the EV3
File "C:\Python27\lib\site-packages\rpyc\utils\classic.py", line 65, in connect
return factory.connect(host, port, SlaveService, ipv6 = ipv6)
File "C:\Python27\lib\site-packages\rpyc\utils\factory.py", line 90, in connect
return connect_stream(s, service, config)
File "C:\Python27\lib\site-packages\rpyc\utils\factory.py", line 51, in connect_stream
return connect_channel(Channel(stream), service = service, config = config)
File "C:\Python27\lib\site-packages\rpyc\utils\factory.py", line 40, in connect_channel
return Connection(service, channel, config = config)
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 147, in __init__
self._init_service()
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 150, in _init_service
self._local_root.on_connect()
File "C:\Python27\lib\site-packages\rpyc\core\service.py", line 145, in on_connect
self._conn.builtin = self._conn.modules.__builtin__
File "C:\Python27\lib\site-packages\rpyc\core\service.py", line 114, in __getattr__
return self[name]
File "C:\Python27\lib\site-packages\rpyc\core\service.py", line 111, in __getitem__
self.__cache[name] = self.__getmodule(name)
File "C:\Python27\lib\site-packages\rpyc\core\netref.py", line 196, in __call__
return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
File "C:\Python27\lib\site-packages\rpyc\core\netref.py", line 71, in syncreq
return conn.sync_request(handler, oid, *args)
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 435, in sync_request
self.serve(0.1)
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 383, in serve
data = self._recv(timeout, wait_for_lock = True)
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 341, in _recv
data = self._channel.recv()
File "C:\Python27\lib\site-packages\rpyc\core\channel.py", line 50, in recv
header = self.stream.read(self.FRAME_HEADER.size)
File "C:\Python27\lib\site-packages\rpyc\core\stream.py", line 190, in read
raise EOFError("connection closed by peer")
EOFError: connection closed by peer
>>>
然后在我的 SSH 会话中,显示以下错误:
robot@ev3dev:~$ ./rpyc_server.sh
INFO:SLAVE/18812:server started on [0.0.0.0]:18812
INFO:SLAVE/18812:accepted 192.168.137.1:5725
INFO:SLAVE/18812:welcome [192.168.137.1]:5725
INFO:SLAVE/18812:goodbye [192.168.137.1]:5725
ERROR:SLAVE/18812:client connection terminated abruptly
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/rpyc/utils/server.py", line 172, in _authenticate_and_serve_client
self._serve_client(sock2, credentials)
File "/usr/lib/python3/dist-packages/rpyc/utils/server.py", line 197, in _serve_client
conn._init_service()
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 154, in _init_service
self._local_root.on_connect()
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 150, in on_connect
self._conn.builtin = self._conn.modules.builtins
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 121, in __getattr__
return self[name]
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 118, in __getitem__
self.__cache[name] = self.__getmodule(name)
TypeError: 'b'instancemethod'' object is not callable
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
File "/usr/lib/python3.4/threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/rpyc/utils/server.py", line 172, in _authenticate_and_serve_client
self._serve_client(sock2, credentials)
File "/usr/lib/python3/dist-packages/rpyc/utils/server.py", line 197, in _serve_client
conn._init_service()
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 154, in _init_service
self._local_root.on_connect()
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 150, in on_connect
self._conn.builtin = self._conn.modules.builtins
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 121, in __getattr__
return self[name]
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 118, in __getitem__
self.__cache[name] = self.__getmodule(name)
TypeError: 'b'instancemethod'' object is not callable
这些错误出了什么问题?