Browse Source

Initial Commit.

master
Jared Dunbar 3 years ago
commit
6c82db0f7d
Signed by: jared GPG Key ID: CF202CC859BAC692
  1. 106
      graph.py
  2. 104
      sendBroadcast.py
  3. 34
      tmp.lua

106
graph.py

@ -0,0 +1,106 @@
#!/usr/bin/python3
import numpy as np
import matplotlib.pyplot as plt
from scipy.linalg import lstsq
from scipy.stats import linregress
d = []
d.append((int("0000", 16), 0))
d.append((int("000a", 16), 1))
d.append((int("0014", 16), 2))
d.append((int("0032", 16), 5))
d.append((int("0046", 16), 7))
d.append((int("0050", 16), 8))
d.append((int("0064", 16), 10))
d.append((int("012c", 16), 30))
d.append((int("0136", 16), 31))
d.append((int("0140", 16), 32))
d.append((int("014a", 16), 33))
d.append((int("0154", 16), 34))
d.append((int("01f4", 16), 50))
d.append((int("01fe", 16), 51))
d.append((int("0208", 16), 52))
d.append((int("0212", 16), 53))
d.append((int("021c", 16), 54))
d.append((int("0226", 16), 55))
d.append((int("0230", 16), 56))
d.append((int("023a", 16), 57))
d.append((int("0244", 16), 58))
d.append((int("024e", 16), 59))
"""
d.append((int("0000b2", 16), 0))
d.append((int("000abc", 16), 1))
d.append((int("0014c6", 16), 2))
d.append((int("0032e4", 16), 5))
d.append((int("0046f8", 16), 7))
d.append((int("005002", 16), 8))
d.append((int("006416", 16), 10))
d.append((int("012cdf", 16), 30))
d.append((int("0136e9", 16), 31))
d.append((int("0140f3", 16), 32))
d.append((int("014afd", 16), 33))
d.append((int("015407", 16), 34))
d.append((int("01f4a7", 16), 50))
d.append((int("01feb1", 16), 51))
d.append((int("0208bc", 16), 52))
d.append((int("0212c6", 16), 53))
d.append((int("021cd0", 16), 54))
d.append((int("0226da", 16), 55))
d.append((int("0230e4", 16), 56))
d.append((int("023aee", 16), 57))
d.append((int("0244f8", 16), 58))
d.append((int("024e02", 16), 59))
"""
# f4 01 a7: 50
# fe 01 b1: 51
# 08 02 bc: 52
# 12 02 c6: 53
# 1c 02 d0: 54
# 26 02 da: 55
# 30 02 e4: 56
# 3a 02 ee: 57
# 44 02 f8: 58
# 4e 02 02: 59
# e4 02 98: 74
# 02 03 b7: 77
# 4c 04 02: 110
# 56 04 0c: 111
# 60 04 16: 112
# 6a 04 20: 113
# 74 04 2a: 114
# 7e 04 34: 115
# ba 04 70: 121
# ae 06 66: 171
x = np.array([x[0] for x in d])
y = np.array([x[1] for x in d])
M = x[:, np.newaxis]**[0, 2]
slope, intercept, r_value, p_value, std_err = linregress(x,y)
print(linregress(x,y))
plt.plot(x, y, 'o', label='data')
xx = np.linspace(0, 9, 101)
yy = intercept + slope*xx
plt.plot(xx, yy, label='y = mx + b')
plt.xlabel('x')
plt.ylabel('y')
plt.legend(framealpha=1, shadow=True)
plt.grid(alpha=0.25)
plt.show()

104
sendBroadcast.py

@ -0,0 +1,104 @@
#!/usr/bin/python3
import socket, sys
from pprint import pprint
from time import sleep
msg = bytearray(16)
# ID?
msg[0] = 0x3c
msg[1] = 0x54
msg[2] = 0x01
msg[3] = 0x69
msg[4] = 0xe0
msg[5] = 0x81
msg[6] = 0xe2
#??
msg[7] = 0x41
msg[8] = 0x31
msg[9] = 0x01
msg[10] = 0x02
msg[11] = 0x00
# DATA HERE
# EOF?
msg[15] = 0x3e
# reusable socket to send broadcast packets, and get responses
b = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
b.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
b.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
b.bind(("0.0.0.0", 8900))
# DATA:
if (len(sys.argv) == 2):
# first and third bytes will increase by 10 for each degree C
# second byte holds overflow.
num = int(sys.argv[1])
bs = num * 10
msg[12] = (bs & 0x00FF)
msg[13] = (bs & 0xFF00) >> 8
for x in range(0, 256):
msg[14] = x
print("{} {} {}".format(hex(msg[12]), hex(msg[13]), hex(msg[14])))
b.sendto(msg, ("10.1.2.116", 49154))
sleep(0.1)
else:
msg[12] = int(sys.argv[1], 16)
msg[13] = int(sys.argv[2], 16)
msg[14] = int(sys.argv[3], 16)
b.sendto(msg, ("10.1.2.116", 49154))
# 00 00 b2: 0
# 0a 00 bc: 1
# 14 00 c6: 2
# 1e 00 d0: 3?
# 32 00 e4: 5
# 46 00 f8: 7
# f4 00 02: 8?
# 50 00 02: 8
# 64 00 16: 10
# 2c 01 df: 30
# 36 01 e9: 31
# 40 01 f3: 32
# 4a 01 fd: 33
# 54 01 07: 34
# f4 01 a7: 50
# fe 01 b1: 51
# 08 02 bc: 52
# 12 02 c6: 53
# 1c 02 d0: 54
# 26 02 da: 55
# 30 02 e4: 56
# 3a 02 ee: 57
# 44 02 f8: 58
# 4e 02 02: 59
# e4 02 98: 74
# 02 03 b7: 77
# 4c 04 02: 110
# 56 04 0c: 111
# 60 04 16: 112
# 6a 04 20: 113
# 74 04 2a: 114
# 7e 04 34: 115
# ba 04 70: 121
# ae 06 66: 171

34
tmp.lua

@ -0,0 +1,34 @@
-- protocol dissector for EcoPlugs protocol
-- declare our protocol
tmpProt = Proto("TMP","Prograde Temperature Probe")
-- create a function to dissect it
function tmpProt.dissector(buffer,pinfo,tree)
pinfo.cols.protocol = "TMP"
local protocolTree = tree:add(tmpProt, buffer(), "Temperature Setpoint")
if buffer:len() == 14 then
-- this is a 14 byte command that appears to do nothing?
protocolTree:add(buffer(0,6), "ID: " .. buffer(0,6))
end
if buffer:len() == 15 then
-- this is a 15 byte command that appears to do nothing?
protocolTree:add(buffer(0,6), "ID: " .. buffer(0,6))
end
if buffer:len() == 16 then
-- this is a 16 byte command that often causes state change on the board
protocolTree:add(buffer(0,7), "ID (?): " .. buffer(0,7))
protocolTree:add(buffer(7,5), "Command (?): " .. buffer(7, 5))
protocolTree:add(buffer(12,3), "Setpoint (C): " .. buffer(12,1) .. " " .. buffer(13,1) .. " " .. buffer(14,1))
protocolTree:add(buffer(15,1), "End of Data (?)")
end
end
-- load the udp.port table
udp_table = DissectorTable.get("udp.port")
-- register our protocol to handle udp port 25 and if I could, dest ports of 31423
udp_table:add(17000, tmpProt)
Loading…
Cancel
Save