From 94bafd94978fe3bd0b90de2573fa74e74e0d9c18 Mon Sep 17 00:00:00 2001 From: "Joshua F. Rountree" Date: Thu, 27 Sep 2018 00:43:17 -0400 Subject: [PATCH] adds fingerprint to api --- app/actions/eon_detail_actions.js | 64 ++++++++++-------------------- app/components/EonDetail/index.js | 8 +--- workbench.zip | Bin 5729 -> 5729 bytes workbench_api/fingerprint.py | 39 ++++++++++++++++++ workbench_api/monitor.py | 16 +------- workbench_api/workbenchd.py | 8 ++++ 6 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 workbench_api/fingerprint.py diff --git a/app/actions/eon_detail_actions.js b/app/actions/eon_detail_actions.js index 9783965..1242f28 100644 --- a/app/actions/eon_detail_actions.js +++ b/app/actions/eon_detail_actions.js @@ -56,30 +56,6 @@ export function FAIL_uninstall(err) { }; } -export function BEGIN_fetchPid() { - return { - type: types.FETCH_PID - }; -} - -export function SUCCESS_fetchPid(results) { - return { - type: types.FETCH_PID_SUCCESS, - payload: { - pid: results - } - }; -} - -export function FAIL_fetchPid(error) { - return { - type: types.FETCH_PID_FAIL, - payload: { - error - } - }; -} - export function OPEN_REQUEST_EON_STATE() { return { type: types.EON_STATE @@ -171,27 +147,29 @@ export function CLOSE_REQUEST_EON_STATE() { // dispatch(CLOSE_REQUEST_EON_STATE()); // } // } -export function installFork(fork) { - return (dispatch, getState) => { - dispatch(BEGIN_fetchPid()); - eonListActions.sendCommand(selectedEon, commands.OPENPILOT_PID).then((result) => { - const pid = result.stdout.split('\n')[0].trim(); +// export function installFork(fork) { +// return (dispatch, getState) => { +// dispatch(BEGIN_fetchPid()); +// eonListActions.sendCommand(selectedEon, commands.OPENPILOT_PID).then((result) => { +// const pid = result.stdout.split('\n')[0].trim(); - if (result.stderr) { - dispatch(FAIL_fetchPid(result.stderr)); - } else { - if (pid && pid.length) { - dispatch(SUCCESS_fetchPid(pid)); - } else { - dispatch(FAIL_fetchPid("Openpilot is not running, or too many processes were returned.")); - } - } - }); - } -} +// if (result.stderr) { +// dispatch(FAIL_fetchPid(result.stderr)); +// } else { +// if (pid && pid.length) { +// dispatch(SUCCESS_fetchPid(pid)); +// } else { +// dispatch(FAIL_fetchPid("Openpilot is not running, or too many processes were returned.")); +// } +// } +// }); +// } +// } -export function fetchEonState(eon) { +export function fetchEonState() { return (dispatch, getState) => { + const { selectedEon, scanResults } = getState().eonList; + const eon = scanResults[selectedEon]; const { polling } = getState().eonDetail setTimeout(() => { fetch(`http://${eon.ip}:8080/state.json`) @@ -240,6 +218,8 @@ export function install() { export function uninstall() { return (dispatch, getState) => { const { selectedEon, scanResults } = getState().eonList; + console.warn("scanResults:",scanResults); + console.warn("selectedEon:",selectedEon); const eon = scanResults[selectedEon]; console.warn("Starting Api UNINSTALL..."); dispatch(BEGIN_uninstall()); diff --git a/app/components/EonDetail/index.js b/app/components/EonDetail/index.js index 1dbc326..a6a1d93 100644 --- a/app/components/EonDetail/index.js +++ b/app/components/EonDetail/index.js @@ -20,14 +20,8 @@ import { Row, CardHeader, Col, Card, CardBody, CardText, CardTitle, CardSubtitle const propTypes = { install: PropTypes.func, eon: PropTypes.object, - pid: PropTypes.string, - fetchingPid: PropTypes.bool, sshConnectionError: PropTypes.object, sshConnectionStatus: PropTypes.string, - tmuxError: PropTypes.string, - tmuxAttached: PropTypes.bool, - tmuxLog: PropTypes.array, - tmuxStartedAt: PropTypes.any, vehicleStarted: PropTypes.string, vehicleStartedAt: PropTypes.string, vehicleConnection: PropTypes.string, @@ -85,7 +79,7 @@ class EonDetail extends Component { // }, 3000); } componentWillUnmount() { - this.props.uninstall(); + // this.props.uninstall(); } // handleInstall = () => { diff --git a/workbench.zip b/workbench.zip index 0a7b1be51d6e20d3875bc7981accefa811490906..156304c276e07c023b4061a03793dac46033a5e7 100644 GIT binary patch delta 83 zcmaE;^H67kDRW2cn#l!1A`^YAm>x{o*s+?CDS6XoQ>JCSOuwdVzRR!7$aG}pW+p)~ kMyN`u$)-XUO#7xxW)u;gtSiJZxl723DRI;0V?wi;0WK^Zw*UYD delta 81 zcmaE;^H67kDO23{$&4bx6TNJh#2;_$Sk1`P|9G=0(=uMB1&=r1 0 else service_list: if m in service_list: port = service_list[m].port @@ -41,7 +40,6 @@ def main(): sock = messaging.sub_sock(context, port, poller, addr=args.addr) if args.proxy: republish_socks[sock] = messaging.pub_sock(context, port) - fingerprint_msgs = {} while 1: polld = poller.poll(timeout=1000) @@ -49,23 +47,11 @@ def main(): if mode != zmq.POLLIN: continue msg = sock.recv() - lc = messaging.recv_sock(logcan, True) - for c in lc.can: - # read also msgs sent by EON on CAN bus 0x80 and filter out the - # addr with more than 11 bits - if c.src%0x80 == 0 and c.address < 0x800: - fingerprint_msgs[c.address] = len(c.dat) - - fingerprint = ', '.join("\"%d\": %d" % v for v in sorted(fingerprint_msgs.items())) - fingerprint = '{' + fingerprint + '}' # print fingerprint evt = log.Event.from_bytes(msg) if sock in republish_socks: republish_socks[sock].send(msg) # print evt - fingerprint_json = json.loads(fingerprint) - print fingerprint_json - data['fingerprint'] = json.dumps(fingerprint_json) service_whitelist = ["thermal","health","gpsLocation"] # THERMAL # if evt.which() == 'thermal': @@ -90,7 +76,7 @@ def main(): # print '\n' # pp.pprint(data, depth=3) if any(data): - f = open("/data//workbench/data/state.json", 'w+') + f = open("/data/workbench/data/state.json", 'w+') f.write(json.dumps(data)) time.sleep(0.25) # if not args.no_print: diff --git a/workbench_api/workbenchd.py b/workbench_api/workbenchd.py index e817f39..bf03bf8 100644 --- a/workbench_api/workbenchd.py +++ b/workbench_api/workbenchd.py @@ -1,9 +1,15 @@ #!/usr/bin/env python from multiprocessing import Process import sys +import fingerprint import monitor import server +def start_fingerprint(): + print '[started] Workbench Fingerprinter' + fingerprint.main() + print '[stopped] Workbench Fingerprinter' + def start_monitor(): print '[started] Workbench Monitor' monitor.main() @@ -19,3 +25,5 @@ def start_server(): p1.start() p2 = Process(target = start_server) p2.start() + p3 = Process(target = start_fingerprint) + p3.start() \ No newline at end of file