0

Beagle bone: Unable to export UART channel.
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Beagle bone: Unable to export UART channel.

by drewfustini on Thu Aug 03, 2017 12:55 pm

It is ok if you see a similar error in dmesg as long as you've configured the UART pins with config-pin:
Code: Select all | TOGGLE FULL SIZE
[551317.793476] bone_capemgr bone_capemgr: part_number 'ADAFRUIT-UART1', version 'N/A'
[551317.801635] bone_capemgr bone_capemgr: slot #8: override
[551317.807161] bone_capemgr bone_capemgr: Using override eeprom data at slot 8
[551317.814283] bone_capemgr bone_capemgr: slot #8: 'Override Board Name,00A0,Override Manuf,ADAFRUIT-UART1'
[551317.830562] bone_capemgr bone_capemgr: slot #8: ADAFRUIT-UART1 conflict P9.24 (#4:cape-universala)
[551317.839832] bone_capemgr bone_capemgr: slot #8: Failed verification


You should see this for slots:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,cape-universala


For this program:
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.UART as UART
import serial

UART.setup("UART1")

ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600)
ser.close()
ser.open()
if ser.isOpen():
  print "Serial is open!"
  ser.write("Hello World!")
  ser.close()

# Eventually, you'll want to clean up, but leave this commented for now,
# as it doesn't work yet
UART.cleanup()


Here is what the output should be:
debian@beaglebone:~$ sudo python ./uart.py
Serial is open!


Running with strace:
sudo strace -o /tmp/log -f python ./uart.py

Looking at /tmp/log, I can see that it writes Hello World! to /dev/ttyO1:
Code: Select all | TOGGLE FULL SIZE
440   open("/sys/devices/platform/bone_capemgr/slots", O_RDWR|O_LARGEFILE) = 3
440   fstat64(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
440   mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f31000
440   read(3, " 0: PF----  -1 \n 1: PF----  -1 \n"..., 4096) = 135
440   read(3, "", 4096)                 = 0
440   write(3, "ADAFRUIT-UART1", 14)    = -1 EEXIST (File exists)
440   close(3)                          = 0
440   munmap(0xb6f31000, 4096)          = 0
440   nanosleep({0, 200000000}, NULL)   = 0
440   open("/dev/ttyO1", O_RDWR|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 3
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, TIOCMBIS, [TIOCM_DTR])   = 0
440   ioctl(3, TIOCMBIS, [TIOCM_RTS])   = 0
440   ioctl(3, TCFLSH, 0)               = 0
440   pipe([4, 5])                      = 0
440   pipe([6, 7])                      = 0
440   fcntl64(4, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
440   fcntl64(6, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
440   close(3)                          = 0
440   close(5)                          = 0
440   close(4)                          = 0
440   close(7)                          = 0
440   close(6)                          = 0
440   open("/dev/ttyO1", O_RDWR|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 3
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, TIOCMBIS, [TIOCM_DTR])   = 0
440   ioctl(3, TIOCMBIS, [TIOCM_RTS])   = 0
440   ioctl(3, TCFLSH, 0)               = 0
440   pipe([4, 5])                      = 0
440   pipe([6, 7])                      = 0
440   fcntl64(4, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
440   fcntl64(6, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
440   fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
440   mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f31000
440   write(1, "Serial is open!\n", 16) = 16
440   write(3, "Hello World!", 12)      = 12
440   select(7, [6], [3], [], NULL)     = 1 (out [3])
440   close(3)                          = 0

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

Re: Beagle bone: Unable to export UART channel.

by IMME on Mon Aug 14, 2017 5:30 pm

drewfustini wrote:It is ok if you see a similar error in dmesg as long as you've configured the UART pins with config-pin:
Code: Select all | TOGGLE FULL SIZE
[551317.793476] bone_capemgr bone_capemgr: part_number 'ADAFRUIT-UART1', version 'N/A'
[551317.801635] bone_capemgr bone_capemgr: slot #8: override
[551317.807161] bone_capemgr bone_capemgr: Using override eeprom data at slot 8
[551317.814283] bone_capemgr bone_capemgr: slot #8: 'Override Board Name,00A0,Override Manuf,ADAFRUIT-UART1'
[551317.830562] bone_capemgr bone_capemgr: slot #8: ADAFRUIT-UART1 conflict P9.24 (#4:cape-universala)
[551317.839832] bone_capemgr bone_capemgr: slot #8: Failed verification


You should see this for slots:
Code: Select all | TOGGLE FULL SIZE
debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/slots
 0: PF----  -1
 1: PF----  -1
 2: PF----  -1
 3: PF----  -1
 4: P-O-L-   0 Override Board Name,00A0,Override Manuf,cape-universala


For this program:
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.UART as UART
import serial

UART.setup("UART1")

ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600)
ser.close()
ser.open()
if ser.isOpen():
  print "Serial is open!"
  ser.write("Hello World!")
  ser.close()

# Eventually, you'll want to clean up, but leave this commented for now,
# as it doesn't work yet
UART.cleanup()


Here is what the output should be:
debian@beaglebone:~$ sudo python ./uart.py
Serial is open!


Running with strace:
sudo strace -o /tmp/log -f python ./uart.py

Looking at /tmp/log, I can see that it writes Hello World! to /dev/ttyO1:
Code: Select all | TOGGLE FULL SIZE
440   open("/sys/devices/platform/bone_capemgr/slots", O_RDWR|O_LARGEFILE) = 3
440   fstat64(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
440   mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f31000
440   read(3, " 0: PF----  -1 \n 1: PF----  -1 \n"..., 4096) = 135
440   read(3, "", 4096)                 = 0
440   write(3, "ADAFRUIT-UART1", 14)    = -1 EEXIST (File exists)
440   close(3)                          = 0
440   munmap(0xb6f31000, 4096)          = 0
440   nanosleep({0, 200000000}, NULL)   = 0
440   open("/dev/ttyO1", O_RDWR|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 3
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, TIOCMBIS, [TIOCM_DTR])   = 0
440   ioctl(3, TIOCMBIS, [TIOCM_RTS])   = 0
440   ioctl(3, TCFLSH, 0)               = 0
440   pipe([4, 5])                      = 0
440   pipe([6, 7])                      = 0
440   fcntl64(4, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
440   fcntl64(6, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
440   close(3)                          = 0
440   close(5)                          = 0
440   close(4)                          = 0
440   close(7)                          = 0
440   close(6)                          = 0
440   open("/dev/ttyO1", O_RDWR|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 3
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_START or SNDRV_TIMER_IOCTL_TREAD or TCSETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B9600 -opost -isig -icanon -echo ...}) = 0
440   ioctl(3, TIOCMBIS, [TIOCM_DTR])   = 0
440   ioctl(3, TIOCMBIS, [TIOCM_RTS])   = 0
440   ioctl(3, TCFLSH, 0)               = 0
440   pipe([4, 5])                      = 0
440   pipe([6, 7])                      = 0
440   fcntl64(4, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
440   fcntl64(6, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
440   fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
440   mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f31000
440   write(1, "Serial is open!\n", 16) = 16
440   write(3, "Hello World!", 12)      = 12
440   select(7, [6], [3], [], NULL)     = 1 (out [3])
440   close(3)                          = 0


Hi, our code (using the UART) does not seem to be able to receive a serial stream.
Is there something wrong with our code or has something changed in the new version?
I call the code from rc.local and include the following:

config-pin P9_24 uart
config-pin P9_26 uart
sudo python /etc/ppp/ip-up.d/send_back_vpn_ip.py &

It dials up and connects the the VPN fine etc.
The should then wait for a serial request before send back the IP address.
We detect an output from our code but it does not react to anything even though scoping and using a logic analyser it is there on the pin (at the correct baud rate etc).
This code works on the old version.

Any ideas please?

Ian
Code: Select all | TOGGLE FULL SIZE
import Adafruit_BBIO.UART as UART
import serial
import netifaces as ni
import os
import time

os.system("ser2net &")
time.sleep(5) # delays for 5 seconds
os.system("wvdial 3gconnect &")

UART.setup("UART1")
ser = serial.Serial(port = "/dev/ttyO1", baudrate=115200)
ser.close()
ser.open()
ser.write("OPEN\n")


while True:
   try:
      line = ser.readline()

      if( line == "vpn_ip\n" ):
         iflist=ni.interfaces()
         if any("ppp1" in s for s in iflist):
            ip = ni.ifaddresses('ppp1')[2][0]['addr']
            str_back = ip + "\n"

         else:
            str_back = "ERROR\n"

         if ser.isOpen():
            ser.write(str_back)      

      if( line == "ready\n" ):
         ser.write("OK\n")
   except:
      continue
      
ser.close()
 
# Eventually, you'll want to clean up, but leave this commented for now,
# as it doesn't work yet
#UART.cleanup()

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by drewfustini on Wed Aug 16, 2017 4:19 pm

It dials up and connects the the VPN fine etc.
The should then wait for a serial request before send back the IP address.
We detect an output from our code but it does not react to anything even though scoping and using a logic analyser it is there on the pin (at the correct baud rate etc).


So it sound like the Python program on the BeagleBone is not receiving any information back from the serial port?

I tink this would be the line in the Pythom program that should be receiving data from the serial port?

Code: Select all | TOGGLE FULL SIZE
      line = ser.readline()


I would like to try to determine what system I/O is happening when you are observing the signals on the logic analyzer:

Could you run this?
sudo strace -o /tmp/strace-send_back_vpn_ip.txt -f python /etc/ppp/ip-up.d/send_back_vpn_ip.py &

There should be read() and write() system calls in there corresponding to serial port device activity.


This code works on the old version.


Do you know which version of the library? I can view the commits between new and old and see if anything related to UART.

Is it the same Debian image version and kernel version between the working and not working states?

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

Re: Beagle bone: Unable to export UART channel.

by IMME on Tue Aug 22, 2017 11:00 am

Hi, I seem to have it working.
The problem was that the uart would not accept unicode.
The unicode is generated from netifaces in the form of an IP address.

iflist=ni.interfaces()
if any("ppp1" in s for s in iflist):
ip = ni.ifaddresses('ppp1')[2][0]['addr']
str_back = ip + "\n"
str_back_ascii = str_back.encode('latin-1')
else:
str_back_ascii = "ERROR1\n"

if ser.isOpen():
ser.write(str_back_ascii)

So I just added an encode line and it fixed the problem.
It used to work so I'm not, has the UART driver changed?

Also I do get this error each time I run the code:

bone_capemgr bone_capemgr: slot #5: ADAFRUIT-UART1 conflict P9.24 (#4:cape-universala)
[ 25.225084] bone_capemgr bone_capemgr: slot #5: Failed verification

Is this a problem?

Thanks Ian

IMME
 
Posts: 11
Joined: Thu Jul 27, 2017 7:01 pm

Re: Beagle bone: Unable to export UART channel.

by drewfustini on Wed Aug 23, 2017 2:39 am

Thanks for following up and insight about unicode. I'm glad to hear that it is working.

That error is not an actual issue:
bone_capemgr bone_capemgr: slot #5: ADAFRUIT-UART1 conflict P9.24 (#4:cape-universala)
[ 25.225084] bone_capemgr bone_capemgr: slot #5: Failed verification


This is because those pins have already been reserved for the config-pin utility to control.

I need to update Adafruit_BBIO to use config-pin when present and stop unnecessarily loading the device tree overlay.

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

Please be positive and constructive with your questions and comments.