Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include serial number in emoncms HTTP post #127

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/emonhub_interfacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,34 @@ def __init__(self, name):
# create a stop
self.stop = False

# Read RaspberryPi serial number if applicable
pi_serial = False
try:
f = open('/proc/cpuinfo','r')
for line in f:
if line[0:6]=='Serial':
length=len(line)
pi_serial = line[11:length-1]
f.close()
except:
pi_serial = False

if pi_serial:
pi_serial_short = ""
zero_flag = 1
for i in range(0,len(pi_serial)):
if pi_serial[i]!='0':
zero_flag = 0
if not zero_flag:
pi_serial_short += pi_serial[i]
self._settings['serial_num'] = pi_serial_short.upper()+"_"
else:
self._settings['serial_num'] = ""

self.first_msg = {}
self.last_msg = {}
self.missed = {}
self.rx_msg = {}


@log_exceptions_from_class_method
def run(self):
Expand Down Expand Up @@ -142,7 +165,7 @@ def add(self, cargo):
f = []
try:
f.append(cargo.timestamp)
f.append(cargo.nodeid)
f.append(str(self._settings['serial_num'])+str(cargo.nodeid))
# FIXME replace with f.extend(cargo.realdata)
for i in cargo.realdata:
f.append(i)
Expand Down Expand Up @@ -429,7 +452,7 @@ def _process_rx(self, cargo):
nodename = False
if node in ehc.nodelist and 'nodename' in ehc.nodelist[node]:
nodename = ehc.nodelist[node]['nodename']
rxc.nodename = nodename
rxc.nodename = str(self._settings['serial_num'])+str(nodename)

if not rxc:
return False
Expand Down