No _port. What version pyserial?

General discussion of using Roboclaw motor controllers
Post Reply
ecorrales
Posts: 33
Joined: Sun May 06, 2018 5:06 am
No _port. What version pyserial?

Post 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)
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: No _port. What version pyserial?

Post 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
ecorrales
Posts: 33
Joined: Sun May 06, 2018 5:06 am
Re: No _port. What version pyserial?

Post 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)
ecorrales
Posts: 33
Joined: Sun May 06, 2018 5:06 am
Re: No _port. What version pyserial?

Post 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?
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: No _port. What version pyserial?

Post by Basicmicro Support »

Try writing a simple function that just opens the serial port and checks the return value.
ecorrales
Posts: 33
Joined: Sun May 06, 2018 5:06 am
Re: No _port. What version pyserial?

Post 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..
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: No _port. What version pyserial?

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

Post Reply