serial port - Raspberry Pi - Rainforest EMU-2 - Python - Read time from SCE smart meter -


i programming in python , first project. appreciated.

i obtained device rainforest reads electric meter. unit has usb port accessible via usb. managed hook device raspberry pi , extract hex string serial port. string reading 0x18f0cb39. need take number , convert proper format , output time , date. manual device programming @ http://www.rainforestautomation.com/sites/default/files/download/rfa-z106/raven_xml_api_r127.pdf

i quite confused when comes converting epoch time , date. put #'s in front of lines having difficulties.

the code have written is:

#!/usr/bin/env python import serial import time serial.port = serial.serial("/dev/ttyusb0", 115200, timeout=0.5) serial.port.write("<command><name>get_time</name><refresh>n</refresh></command>") response=serialport.readline(none) response=serialport.readline(none) response=serialport.readline(none) response=serialport.readline(none) response=serialport.readline(none) mystring=response[13:23] #struct_time = int(raw_input(((mystring >> 40) +1970, (ts >> 32 & 0xff) +1, ts >> 24 & 0xff, ts>> 16))) #thetime=time.strftime("%7-%m-%d-%h-%m-%s) print mystring 

thanks in advance help

scott

looking @ documentation, don't understand how using slice 13:23 time (in hex) out of timecluster response, gist of question , commented out code seems how convert 0x18f0cb39 local date , time?

>>> import time >>> help(time) (output snipped, handy....) >>> t = 0x18f0cb39 >>> time.ctime(t) 'tue apr  5 15:37:29 1983' >>> time.localtime(t) time.struct_time(tm_year=1983, tm_mon=4, tm_mday=5, tm_hour=15, tm_min=37, tm_sec=29, tm_wday=1, tm_yday=95, tm_isdst=0) 

since posted question 6 days ago , today 11th, date in answer seems off 30 years, must doing wrong, maybe take step in right direction or prompt else write better answer you.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -