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()
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.
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.
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.

Either your script or device. I run my stuff for days w/o problems.
Or atleast detailed way that how you are doing it?
--
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.
Hello Mr.RobertGlad 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?
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.
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)
--
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.
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)
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)