0

RE: config-pin for UART2 (Grove Connection) on BBGW
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

RE: config-pin for UART2 (Grove Connection) on BBGW

by silver2row on Sat Mar 23, 2019 6:00 pm

Hello,

I am trying to produce the UART2 channel on the BBGW w/:

import Adafruit_BBIO.UART as UART
import serial

UART.setup("UART2")

...

If you need the rest of the software, I will produce it. I found this software from toptechboy.com. Anyway, I changed some of it and it used to work. Now, I have been unable to produce the same results as a couple of months back.

Has the BBIO library been updated/upgraded?

...

Anyway...

This is the error I keep getting and the config-pin utility does no longer work on my BeagleBone Green Wireless.

[url]py_setup_uart(UART2): set_pin_mode() failed for pin=P9_22Traceback (most recent call last):
File "GPS.py", line 5, in <module>
UART.setup("UART2")
ValueError: Set pin mode failed for uart channel.
[/url]

It seems that my P9_22 pin on the board is no longer available for config-pin. What do you make of this, if anything?

Seth

P.S. If you have some extra time to review this info, please do and let me know your thoughts on these subjects. Oh and I have tried w/ python3 and python2. Neither seem to produce desired results.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by drewfustini on Sat Mar 23, 2019 8:19 pm

The results you are seeing could be due to the configuration of your BeagleBone such as the version of the image, kernel, bootloader and associated configuration.

Please post the output of utility that will print diagnostic information:
Code: Select all | TOGGLE FULL SIZE
sudo /opt/scripts/tools/version.sh


Also, please post the full Python source code for the program that you are trying to run.

drewfustini
 
Posts: 920
Joined: Sat Dec 26, 2015 1:19 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by silver2row on Sat Mar 23, 2019 10:18 pm

Hello Sir,

Seth here. Look below:

Code: Select all | TOGGLE FULL SIZE
git:/opt/scripts/:[247665d553b6b28fdd47c38e80e910a9208772be]
eeprom:[A335BNLTGW1ABBGW16055537]
model:[TI_AM335x_BeagleBone_Green_Wireless]
dogtag:[BeagleBoard.org Debian Image 2018-10-07]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.09-00002-g0b54a51eee]:[location: dd MBR]
kernel:[4.14.94-ti-r97]
nodejs:[v6.17.0]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr0=/lib/firmware/BB-UART2-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20190320.1-0rcnee0~stretch+20190320]
pkg:[bb-wl18xx-firmware]:[1.20190227.1-0rcnee0~stretch+20190227]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[librobotcontrol]:[1.0.4-git20190107.0-0rcnee0~stretch+20190108]
pkg:[firmware-ti-connectivity]:[20180825+dfsg-1rcnee1~stretch+20181217]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep pinctrl-single
[    0.945996] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[    0.957104] gpio-of-helper ocp:cape-universal: ready
END


This sums up the command you gave me to show.

Seth

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by silver2row on Sat Mar 23, 2019 10:19 pm

Hello Sir,

I think you gave me some insight. The .dtbo file seems out of place for my configuration. Do you think that may be it or is it the bootloader?

Seth

P.S. I forgot the source code for the program. See below:

Code: Select all | TOGGLE FULL SIZE
import serial
import Adafruit_BBIO.UART as UART
from time import sleep

UART.setup("UART2")
ser=serial.Serial("/dev/ttyO2", 9600)

class GPS:

    def __init__(self):
        #This sets up variables for useful commands.
        #This set is used to set the rate the GPS reports
        UPDATE_10_sec=  "$PMTK220,10000*2F\r\n" #Update Every 10 Seconds
        UPDATE_5_sec=  "$PMTK220,5000*1B\r\n"   #Update Every 5 Seconds 
        UPDATE_1_sec=  "$PMTK220,1000*1F\r\n"   #Update Every One Second
        UPDATE_200_msec=  "$PMTK220,200*2C\r\n" #Update Every 200 Milliseconds
        #This set is used to set the rate the GPS takes measurements
        MEAS_10_sec = "$PMTK300,10000,0,0,0,0*2C\r\n" #Measure every 10 seconds      
        MEAS_5_sec = "$PMTK300,5000,0,0,0,0*18\r\n"   #Measure every 5 seconds
        MEAS_1_sec = "$PMTK300,1000,0,0,0,0*1C\r\n"   #Measure once a second
        MEAS_200_msec= "$PMTK300,200,0,0,0,0*2F\r\n"  #Meaure 5 times a seconds
        #Set the Baud Rate of GPS
        BAUD_57600 = "$PMTK251,57600*2C\r\n"          #Set Baud Rate at 57600
        BAUD_9600 ="$PMTK251,9600*17\r\n"             #Set 9600 Baud Rate
        #Commands for which NMEA Sentences are sent
        ser.write(BAUD_57600)
        sleep(1)
        ser.baudrate=57600
        GPRMC_ONLY= "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n" #Send only the GPRMC Sentence
        GPRMC_GPGGA="$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n"#Send GPRMC AND GPGGA Sentences
        SEND_ALL ="$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n" #Send All Sentences
        SEND_NOTHING="$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n" #Send Nothing
        ser.write(UPDATE_1_sec)
        sleep(1)
        ser.write(MEAS_1_sec)
        sleep(1)
        ser.write(GPRMC_GPGGA)
        sleep(1)
        ser.flushInput()
        ser.flushInput()

    def read(self):
        ser.flushInput()
        ser.flushInput()
        while ser.inWaiting()==0:
            pass
        self.NMEA1=ser.readline()
        while ser.inWaiting()==0:
            pass
        self.NMEA2=ser.readline()
        NMEA1_array=self.NMEA1.split(',')
        NMEA2_array=self.NMEA2.split(',')
        if NMEA1_array[0]=='$GPRMC':
            self.timeUTC=NMEA1_array[1][:-8]+':'+NMEA1_array[1][-8:-6]+':'+NMEA1_array[1][-6:-4]
            self.latDeg=NMEA1_array[3][:-7]
            self.latMin=NMEA1_array[3][-7:]
            self.latHem=NMEA1_array[4]
            self.lonDeg=NMEA1_array[5][:-7]
            self.lonMin=NMEA1_array[5][-7:]
            self.lonHem=NMEA1_array[6]
            self.knots=NMEA1_array[7]
        if NMEA1_array[0]=='$GPGGA':
            self.fix=NMEA1_array[6]
            self.altitude=NMEA1_array[9]
            self.sats=NMEA1_array[7]
        if NMEA2_array[0]=='$GPRMC':
            self.timeUTC=NMEA2_array[1][:-8]+':'+NMEA1_array[1][-8:-6]+':'+NMEA1_array[1][-6:-4]
            self.latDeg=NMEA2_array[3][:-7]
            self.latMin=NMEA2_array[3][-7:]
            self.latHem=NMEA2_array[4]
            self.lonDeg=NMEA2_array[5][:-7]
            self.lonMin=NMEA2_array[5][-7:]
            self.lonHem=NMEA2_array[6]
            self.knots=NMEA2_array[7]

        if NMEA2_array[0]=='$GPGGA':
            self.fix=NMEA2_array[6]
            self.altitude=NMEA2_array[9]
            self.sats=NMEA2_array[7]

myGPS=GPS()
GPSdata=open('/root/GPS_data/GPS.txt', 'w')
GPSdata.close()
while(1):
    myGPS.read()
    if myGPS.fix!=0:
        try:
            latDec=float(myGPS.latDeg)+float(myGPS.latMin)/60.
            lonDec=float(myGPS.lonDeg)+float(myGPS.lonMin)/60.
            if myGPS.lonHem=='W':
                lonDec=(-1)*lonDec
            if myGPS.latHem=='S':
                latDec=(-1)*latDec
            alt=myGPS.altitude
            GPSdata=open('/root/GPS_data/GPS.txt', 'a')
            myString=str(lonDec)+','+str(latDec)+','+alt+' '
            GPSdata.write(myString)
            GPSdata.close()
        except:
            pass

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by silver2row on Sun Mar 24, 2019 12:44 am

Hello Once More,

I am not sure why this software worked back two months prior but now is disabling my system. Anyway, do not worry about it. The .dtbo file was preventing me from using the config-pin utility.

Seth

P.S. I can set up UART2 now but the software will no longer work w/ Python3.5.x. I will try again one day. Who knows? I may get lucky.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by drewfustini on Sun Mar 24, 2019 6:29 pm

Yes, BB-UART2-00A0.dtbo will prevent config-pin from being able to control those pins. You have done the right solution then by removing that from uEnv.txt


P.S. I can set up UART2 now but the software will no longer work w/ Python3.5.x. I will try again one day. Who knows? I may get lucky.

Do you get an error message?

drewfustini
 
Posts: 920
Joined: Sat Dec 26, 2015 1:19 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by silver2row on Sun Mar 24, 2019 7:05 pm

Hello,

I get different errors for each, different version of Python I use. See below for errors on both python2 and python3.

Python 3.5.x:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "GPS.py", line 82, in <module>
    myGPS = GPS()
  File "GPS.py", line 27, in __init__
    ser.write(BAUD_9600)
  File "/home/debian/.local/lib/python3.5/site-packages/serial/serialposix.py", line 532, in write
    d = to_bytes(data)
  File "/home/debian/.local/lib/python3.5/site-packages/serial/serialutil.py", line 63, in to_bytes
    raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
TypeError: unicode strings are not supported, please encode to bytes: '$PMTK251,9600*17\\!r\n'


and for Python 2.7.x:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "GPS.py", line 83, in <module>
    GPSdata = open("/home/debian/GPS_data/GPS.txt", "w")
IOError: [Errno 13] Permission denied: '/home/debian/GPS_data/GPS.txt'


...

Those were the errors I receive while running the commands
Code: Select all | TOGGLE FULL SIZE
python3 GPS.py
and
Code: Select all | TOGGLE FULL SIZE
python GPS.py
.

Seth

P.S. Using sudo is another story. If you would like the commands and errors while I use sudo, please reply. I am still at awe as to what transpired that created this software from not running correctly.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by silver2row on Sun Mar 24, 2019 7:10 pm

Hello Once More Sir,

Seth here. Here are the error codes when trying to run the source code w/ sudo instead of "plain jane."

Python 3.5.x:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "GPS.py", line 82, in <module>
    myGPS = GPS()
  File "GPS.py", line 27, in __init__
    ser.write(BAUD_9600)
  File "/usr/local/lib/python3.5/dist-packages/serial/serialposix.py", line 532, in write
    d = to_bytes(data)
  File "/usr/local/lib/python3.5/dist-packages/serial/serialutil.py", line 63, in to_bytes
    raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
TypeError: unicode strings are not supported, please encode to bytes: '$PMTK251,9600*17\\!r\n'


Python 2.7.x:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "GPS.py", line 86, in <module>
    myGPS.read()
  File "GPS.py", line 48, in read
    return self.in_waiting
AttributeError: GPS instance has no attribute 'in_waiting'


Again...this is while using sudo. So, the command would be sudo python3 GPS.py and/or sudo python GPS.py.

Seth

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by drewfustini on Sun Mar 24, 2019 7:19 pm

The python 2 error seems related to file permissions:
Code: Select all | TOGGLE FULL SIZE
    GPSdata = open("/home/debian/GPS_data/GPS.txt", "w")
IOError: [Errno 13] Permission denied: '/home/debian/GPS_data/GPS.txt'


I would suggest either:
- running with sudo
- or checking the ownership and permissions of /home/debian/GPS_data/GPS.txt

drewfustini
 
Posts: 920
Joined: Sat Dec 26, 2015 1:19 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by drewfustini on Sun Mar 24, 2019 7:26 pm

For Python 2:
Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "GPS.py", line 86, in <module>
    myGPS.read()
  File "GPS.py", line 48, in read
    return self.in_waiting
AttributeError: GPS instance has no attribute 'in_waiting'


That seems unrelated to Adafruit_BBIO.

I don't see "return self.in_waiting" in the code that you posted but looks like it is an issue in GPS.py at line 48.

drewfustini
 
Posts: 920
Joined: Sat Dec 26, 2015 1:19 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by silver2row on Sun Mar 24, 2019 7:35 pm

Hello Sir,

Seth here again.

Yea...that line was added later to test some item on the source code.

I changed that line back to "pass" instead of "return self.in_waiting".

Seth

P.S. After changing the source code back to "pass," the error reads:

Code: Select all | TOGGLE FULL SIZE
Traceback (most recent call last):
  File "GPS.py", line 88, in <module>
    if myGPS.fix != 0:
AttributeError: GPS instance has no attribute 'fix'

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by silver2row on Sun Mar 24, 2019 7:42 pm

Hello,

Yes sir...you are right. I do not think it is a Adafruit_BBIO.UART as UART issue any longer.

Seth

P.S. There were permission issues w/ the file /GPS_data/GPS.txt. The file still does not work regularly like it used to work. I will continue to debug this source code to try to make it useful again. Thank you anyway.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: config-pin for UART2 (Grove Connection) on BBGW

by silver2row on Sun Mar 24, 2019 7:53 pm

Hello Sir,

Good news. I got it to work, again. Insight and guidance. Thank you.

Seth

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Please be positive and constructive with your questions and comments.