BBBlack hangs in some hours!

109 views
Skip to first unread message

Nishant Sood

unread,
Nov 11, 2013, 3:21:11 AM11/11/13
to beagl...@googlegroups.com

I have a python script running on a raring BBBLack ubuntu image that has wiFi working flawlessly, but while using the python script as follows I'm see that the script runs but the Request Log on the xively dashboard isn't receiving anything?!

Is there a frequency limit for which I can update the feeds?

Or is it my App? Which I think is running and not going down.

here's the code:



#!/usr/bin/env python

import os
import xively
import subprocess
import time
import datetime
import requests
import serial
import re
import string
from select import select

#OS variables and other settings for UART transfer
os
.system("sudo chmod 777 -R  /sys/devices/bone_capemgr.8/slots")

os
.system("sudo echo ttyO1_armhf.com > /sys/devices/bone_capemgr.8/slots")

serial
= serial.Serial("/dev/ttyO1", baudrate=9600)

resp
= ""
inData
= ['']*14
started
= False
ended
= False
check_point
= 0
check_point_listener
= 0

# extract feed_id and api_key from environment variables
FEED_ID
= "34534"
API_KEY
= "blahhblahh"
DEBUG
=   "DEBUG" or false
DEBUG_listener
= "DEBUG" or false

# initialize api client
api
= xively.XivelyAPIClient(API_KEY)

# function to return a datastream object. This either creates a new datastream,
# or returns an existing one
def get_datastream(feed):
 
try:
    datastream
= feed.datastreams.get("Lock_Controller")
   
if DEBUG:
     
print "Found existing datastream"
   
return datastream
 
except:
   
if DEBUG:
     
print "Creating new datastream"
    datastream
= feed.datastreams.create("Lock_Controller", tags="ON/OFF")
   
return datastream

# function to return a datastream object. This either creates a new datastream,
# or returns an existing one
def get_datastream_listener(feed):
 
try:
    datastream_listener
= feed.datastreams.get("load_avg")
   
if DEBUG:
     
print "Found existing datastream"
   
return datastream_listener
 
except:
   
if DEBUG:
     
print "Creating new datastream"
    datastream_listener
= feed.datastreams.create("load_avg", tags="load_01")
   
return datastream_listener


# main program entry point - runs continuously updating our datastream with the
def run():
 
print "Script initiation"

 
#Initializing one channel
  feed
= api.feeds.get(FEED_ID)
  datastream
= get_datastream(feed)
  datastream
.max_value = None
  datastream
.min_value = None
 
#Initializing one channel
  feed_listener
= api.feeds.get(FEED_ID)
  datastream_listener
= get_datastream_listener(feed_listener)
  datastream_listener
.max_value = None
  datastream_listener
.min_value = None

 
while True:
     
while serial.inWaiting() > 0:
           inChar
= serial.read() # Read a character
           
if inChar =='<': # not sure what to put in if statement to run until end
             
global started
              started
= True
             
global ended
              ended
= False
              index
= 0
           
elif inChar =='>':
             
global ended
              ended
= True            
           
if started == True:
              inData
[index] = inChar # Store it
              index
= index + 1      # Increment where to write next
             
#inData[index] = '\0'   # Null terminate the string    
           
if ended == True:
             
global ended
              ended
= False
              index
= 0
             
Data = inData #values of acclerometer like "545X" etc enter and stored in Data
             
print (Data)
              values
= "".join(str(v) for v in Data)    
             
print (values)      
              strData
= string.replace(values, "<", "")
              strData
= string.replace(strData, ">", "")
              strData
= string.replace(strData, " ", "")
              strData
= string.replace(strData, "\0", "")
             
print (strData)
             
if strData[0] == 's' and strData[1] == 't':
                 
print "Nishant Here"
                 strData
= string.replace(strData, "st", "")
                 strData
= string.replace(strData, "\0", "")
                 strData
= string.replace(strData, " ", "")
                 
print strData
                 
if strData == '1':
                   
print "This is arrived at 1"  
                   
global check_point_listener              
                    datastream_listener
.current_value = str(check_point_listener) + "h"
                    datastream_listener
.update()
                   
#serial.write("<v0" + str(check_point) + ">") #serial write value
                    time
.sleep(1)
                    datastream_listener
.current_value = 0
                    datastream_listener
.update()
                 
elif strData == '0':
                   
print "This is arrived at 0"  
                   
global check_point_listener                
                    datastream_listener
.current_value = str(check_point_listener) + "L"
                    datastream_listener
.update()                  
                    time
.sleep(1)
                    datastream_listener
.current_value = 0
                    datastream_listener
.update()
     
if DEBUG:
               
print "Updating Xively feed with value: %s"  
               
global check_point
               check_point
= 0
               datastream
= get_datastream(feed)
               
global check_point
               check_point
= datastream.current_value
               
print "AAGYa: %s" % check_point
               
for x in range(1,61):
                   
#print x
                   checking
= int(check_point)
                   
if x == checking:
                       
print "Got it"
                       serial
.write("<ch" + str(x) + ">")
                       datastream
.current_value = 0
                       datastream
.update()
     
if DEBUG_listener:
               
print "Query stuff: %s"  
               
global check_point_listener
               check_point_listener
= 0
               datastream_listener
= get_datastream_listener(feed_listener)
               
global check_point_listener
               check_point_listener
= datastream_listener.current_value
               
print "AAGYa: %s" % check_point_listener
               check_point_listener
= string.replace(check_point_listener, "L", "")
               check_point_listener
= string.replace(check_point_listener, "h", "")
               
for x in range(1,61):
                   
#print x
                   checking
= int(check_point_listener)
                   
if x == checking:
                       
print "Got it Query"
                       serial
.write("<Q" + str(x) + ">")            

run
()



Nishant Sood

unread,
Nov 11, 2013, 3:32:23 AM11/11/13
to beagl...@googlegroups.com
Running Ubuntu raring from Robert C Nelson 13.04 version!

Philip Polstra

unread,
Nov 11, 2013, 8:04:21 AM11/11/13
to beagl...@googlegroups.com

I would recommend you setup the tty port in startup scripts or at least delay after setup.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Nishant Sood

unread,
Nov 11, 2013, 8:06:37 AM11/11/13
to beagl...@googlegroups.com

This very same code is turned into a executable using chmod +x and then provided full 777 privileges and made a start up script using Upstart.
I think this is fine here, whats say?

Thanks & Regards,
Nishant
-------------------
Sent from My Android (humongous NOTE-II)

You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/PiNkUTjnV3M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Philip Polstra

unread,
Nov 11, 2013, 8:23:08 AM11/11/13
to beagl...@googlegroups.com

You need to give cape manager time to setup tty after echo command before talking to device.  Shouldn't need sudo either if done right.  This is working great in my pentesting devices using xbee modems on ttyo2.

Nishant Sood

unread,
Nov 11, 2013, 8:28:24 AM11/11/13
to beagl...@googlegroups.com
Ok I understand your point But if TTy isn't configured correctly from the very beginning how could it then function at all? I mean in my case all the UART hardware function goes perfectly well but after sometime like an hour or so the script goes down.

Thanks & Regards,

Nishant Sood
--
CEO and Founder

Winacro Innovation's Inc.
----------------------------------------
----------------------------------------
Contact's:
Phone:  0129-4176798

Philip Polstra

unread,
Nov 11, 2013, 8:35:21 AM11/11/13
to beagl...@googlegroups.com

Either your script or device.  I run my stuff for days w/o problems.

Nishant Sood

unread,
Nov 11, 2013, 8:38:14 AM11/11/13
to beagl...@googlegroups.com
Philip,

Okay can I have your code or what exactly you are doing(If can provide code then it would be the best for me)

thanks!

Nishant Sood

unread,
Nov 11, 2013, 9:01:43 AM11/11/13
to beagl...@googlegroups.com
Or atleast detailed way that how you are doing it?

Robert Nelson

unread,
Nov 11, 2013, 9:04:01 AM11/11/13
to Beagle Board
On Mon, Nov 11, 2013 at 8:01 AM, Nishant Sood <nis...@winacro.com> wrote:
Or atleast detailed way that how you are doing it?


If your not using any capes, give the v3.12.x branch a try. .(specially for usb related lockups..)

sudo /bin/bash install-me.sh

Regards,

--
Robert Nelson
http://www.rcn-ee.com/

Nishant Sood

unread,
Nov 11, 2013, 9:08:23 AM11/11/13
to beagl...@googlegroups.com
Hello Mr.Robert

Glad to see the image maker here>> 
I'm not using any capes!
also wgetting that branch will make drastic changes? You see my concern is that I already spent a lot of time installing individual needy items from the very big pool so I don't want to install them again, will this change things drastically?


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/PiNkUTjnV3M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Robert Nelson

unread,
Nov 11, 2013, 9:10:26 AM11/11/13
to Beagle Board
On Mon, Nov 11, 2013 at 8:08 AM, Nishant Sood <nis...@winacro.com> wrote:
Hello Mr.Robert

Glad to see the image maker here>> 
I'm not using any capes!
also wgetting that branch will make drastic changes? You see my concern is that I already spent a lot of time installing individual needy items from the very big pool so I don't want to install them again, will this change things drastically?

It just installs the 3.12.x based kernel..

You can see the details of the install-me.sh script here:


Including where it backs up your existing kernel files..


Regards,

Philip Polstra

unread,
Nov 11, 2013, 9:13:09 AM11/11/13
to beagl...@googlegroups.com

Give Robert's 3.12 kernel a try. As for my code, download the MeshDeck from http://sf.net/projects/thedeck and look at install script.

Nishant Sood

unread,
Nov 11, 2013, 9:24:04 AM11/11/13
to beagl...@googlegroups.com

Ok so installing that kernel lets all other things remain the same?  Like the python framework.  Eclipse ide all those don't get effected?

Thanks!

Thanks & Regards,
Nishant
-------------------
Sent from My Android (humongous NOTE-II)

--

Nishant Sood

unread,
Nov 11, 2013, 9:32:49 AM11/11/13
to beagl...@googlegroups.com
Thanks philip

Nishant Sood

unread,
Nov 13, 2013, 2:41:59 AM11/13/13
to beagl...@googlegroups.com
Hi Philip and Robert,

So I have tested the BeagleBone removing any scripts that may clash and cause the OS env. to restart and I have my BBBlack running all the night till present its still on while I'm writing this email, I checked this with "uptime" command ,so Now it seems to be a problem with upstarting of these py scripts, So here the following I give you my upstart code to respawn the py script in the even of any crash!

# Start LINUX UART
#

description     "Start LINUX UART"

start on runlevel [2345]
stop on runlevel [016]

respawn
exec python /etc/init.d/xlockController_UART.py

what you think? is this problem because of runlevel definitions above?

Philip Polstra

unread,
Nov 13, 2013, 7:53:19 AM11/13/13
to beagl...@googlegroups.com

Did you upgrade to 3.12 as well?

You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Nishant Sood

unread,
Nov 13, 2013, 8:02:35 AM11/13/13
to beagl...@googlegroups.com

No was checking that is the problem because of script or else then after it now it seems it was python script.
Is there any anomaly in my upstart you see I want to restart the script when it dies unexpectedly.

Thanks & Regards,
Nishant
-------------------
Sent from My Android (humongous NOTE-II)

Philip Polstra

unread,
Nov 13, 2013, 12:20:34 PM11/13/13
to beagl...@googlegroups.com
I'm not using upstart.  I'm putting code in rc.local, etc. directly.  It could be a problem with permissions or the timing of when your script gets executed.

Nishant Sood

unread,
Nov 13, 2013, 12:29:25 PM11/13/13
to beagl...@googlegroups.com

Hey Philip

I gave full permissions to the py script. That's 777 just to be sure that such problems don't play with me.
But I think I can't do anything about the timing as I won't know about which script is colliding.

Also when I run script sometimes when it dies I get a sort of http error may be capturing it solves the problem. Still I just want to make sure that no matter what uncaptured etc error comes it just restarts the py script on fail because I don't need to retain it.

Can you tell me the what are the steps you are following to restart your script.

Thanks & Regards,
Nishant
-------------------
Sent from My Android (humongous NOTE-II)

Nishant Sood

unread,
Nov 13, 2013, 1:09:15 PM11/13/13
to beagl...@googlegroups.com
Another thing I dont understand at all that If I'm respawing it so it should atleast restart and work for a time till again something conflicts with it and kills it ,Still it just goes down once and for ever, any logical reasoning for the same?

Nishant Sood

unread,
Nov 18, 2013, 2:16:53 AM11/18/13
to beagl...@googlegroups.com
I checked for the configuration script that now goes like >>
# Start LINUX UART
#

description     "Start LINUX UART"

start on net-device-up

respawn
exec python /home/ubuntu/Desktop/xlockController_UART.py

It shows me start/running even if the xlockController_UART.py isn't running which this configuration script is supposed to get it up and running!!

Reply all
Reply to author
Forward
0 new messages