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)
On 11 Nov 2013 18:34, "Philip Polstra" <[email protected]> wrote:

> I would recommend you setup the tty port in startup scripts or at least
> delay after setup.
> On Nov 11, 2013 2:21 AM, "Nishant Sood" <[email protected]> wrote:
>
>> 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()
>>
>>
>>
>>
>>  --
>> 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 [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>  --
> 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
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to