Page 1 of 1

No _port. What version pyserial?

Posted: Tue May 22, 2018 3:12 pm
by ecorrales
Hello,

===============================================
The Error:
===============================================
AttributeError: Roboclaw instance has no attribute '_port'



===============================================
My configuration:
===============================================
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
serial.VERSION '3.2.1'


===============================================
The Code:
===============================================

import time
import serial
from roboclaw import Roboclaw

rc = Roboclaw("/dev/ttyACM0",115200)

rc.Open()
address = 0x80

while(1):
rc.ForwardM1(address,32) #1/4 power forward
time.sleep(2)
rc.BackwardM2(address,32) #1/4 power backward
time.sleep(2)

rc.BackwardM1(address,32) #1/4 power backward
time.sleep(2)
rc.ForwardM2(address,32) #1/4 power forward
time.sleep(2)

rc.BackwardM1(address,0) #Stopped
time.sleep(2)
rc.ForwardM2(address,0) #Stopped
time.sleep(2)

Re: No _port. What version pyserial?

Posted: Wed May 23, 2018 10:11 am
by Basicmicro Support
1. The library is writen for Python 2.7 so you are ok there.
2. Make sure the Roboclaw shows up in the .dev folder as ttyACM0. If you are using a real serial port(not USB) then it will usually show up as ttyAMA0 but on RPi you shoul use the serial0 alias IIRC.
3. You also need to install pyserial for Python 2.7

Re: No _port. What version pyserial?

Posted: Wed May 23, 2018 10:30 am
by ecorrales
Hi, the device shows up correctly in /dev.

The bare minimum py file worked.

for the pyserial install.. i just did sudo apt-get install python-serial

Let me re-try all that.. (probably uninstall all python.. and re-do)

Re: No _port. What version pyserial?

Posted: Wed May 23, 2018 3:04 pm
by ecorrales
[b]Still no "_port" issue.[/b]

Well.. I did try to remove all python... I think I'm lucky it didn't really do anything. Apparently Raspbian uses python for system purposes?

What it did remove python-serial. I tried that install again : sudo apt-get install python-serial.

Here's what "dpkg --get-selections | grep python" says:

dh-python install
libpython-stdlib:armhf install
libpython2.7-minimal:armhf install
libpython2.7-stdlib:armhf install
libpython3-stdlib:armhf install
libpython3.5:armhf install
libpython3.5-minimal:armhf install
libpython3.5-stdlib:armhf install
python install
python-apt-common install
python-minimal install
python-serial install
python2.7 install
python2.7-minimal install
python3 install
python3-apt install
python3-minimal install
python3.5 install
python3.5-minimal install


Any ideas?

Re: No _port. What version pyserial?

Posted: Thu May 24, 2018 9:57 am
by Basicmicro Support
Try writing a simple function that just opens the serial port and checks the return value.

Re: No _port. What version pyserial?

Posted: Thu May 24, 2018 10:51 am
by ecorrales
sure. is the roboclaw_bareminimum.py the same? it doesnt get the return value i dont think but it does do the open(). no errors

Update: i tried another example: roboclaw_readversion.py

same issue.

I may have to give up on doing python..

Re: No _port. What version pyserial?

Posted: Fri May 25, 2018 10:50 am
by Basicmicro Support
The bareminimum example does not check if the open was succesful. You have to actually check the return value of the Open function. Open fails gracefully so if the port does not open it just returns a 0 and not an error message. That means the bareminimum example will not show anything one way or the other unless you modify it.