1

I installed ev3dev on my ev3 brick so I could create programs on it with python. I am trying to use the "rpyc" library for python which can be found here. However, when I try to run this basic script which is given as an example on the link above:

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)

I get multiple errors thrown at me through the terminal followed by the connection closing. I have followed all the instructions on the page and I also started the server script on the ev3 brick beforehand. When I run the above program the errors from python are displayed:

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
>>> 

Then on my SSH session, here are the errors that are displayed:

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

What is going wrong here in these errors?

malteasy
  • 87
  • 9

1 Answers1

0

Are you connecting python2 and python3? ev3dev uses python2.

Use pyenv to install python3 and use it so that your python version of PC and ev3 are the same.

https://gist.github.com/jaydenkieran/75b2bbc32b5b70c4fdfb161ecdb6daa2

You might need to run this command first to install through curl:

sudo apt-get install curl
sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
leppy
  • 49
  • 4