Apr-20-2017, 11:23 PM
(This post was last modified: Apr-21-2017, 01:07 AM by ichabod801.)
my question here:
I am trying the foll. python script to get sensor values from my smart phone so as to do calcs on these values. Hence, I need to convert from xml format to integer or float. Not sure how.
I am trying the foll. python script to get sensor values from my smart phone so as to do calcs on these values. Hence, I need to convert from xml format to integer or float. Not sure how.
import socket, traceback, string from sys import stderr host = '' port = 5555 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) s.bind((host, port)) # print one blank line print while 1: try: message, address = s.recvfrom(8192) # print message # split records using comma as delimiter (data are streamed in CSV format) data = message.split( "," ) # convert to flaot for plotting purposes t = data[0] sensorID = int(data[1]) if sensorID==3: # sensor ID for the eccelerometer ax, ay, az = data[2], data[3], data[4]