Skip to content

Commit

Permalink
support eon panda firmware builds
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjhogan committed Feb 8, 2020
1 parent ecf4ee9 commit 84c0fd8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
12 changes: 5 additions & 7 deletions src/components/CheckCompatible.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,11 @@ class CheckCompatible extends React.Component {
this.props.onReceiveCompatible(this.state.firmwareValid && this.state.canAddress && compatible)
break
case 'error':
if (result.cmd === 'connect') {
this.setState(state => ({
softwareVersion: undefined,
versionStatus: undefined,
connected: false,
}))
}
this.setState(state => ({
softwareVersion: undefined,
versionStatus: undefined,
connected: false,
}))
break
default:
break
Expand Down
45 changes: 40 additions & 5 deletions src/ecu.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import sleep from './sleep'

class EcuWorker {
constructor() {
console.log('initializing ... (v1)')
console.log('initializing ... (v2)')
this.panda = Panda()
this.panda.onError(this._onError)
this.heartbeatHandle = undefined

this.client = new UdsClient(this.panda)
this.rwd = undefined
this.softwareVersion = undefined

this._connectWebWorker = this._connectWebWorker.bind(this)
this._heartbeat = this._heartbeat.bind(this)
this._setPowerSaveState = this._setPowerSaveState.bind(this)
this._onError = this._onError.bind(this)
this.setFirmwareFile = this.setFirmwareFile.bind(this)
this.getFirmwareInfo = this.getFirmwareInfo.bind(this)
Expand All @@ -34,9 +37,11 @@ class EcuWorker {
for (let device of devices) {
if (device.serialNumber === serialNumber) {
this.panda.device.device = device
await this.panda.device.device.open();
await this.panda.device.device.selectConfiguration(1);
await this.panda.device.device.claimInterface(0);
await this.panda.device.device.open()
await this.panda.device.device.selectConfiguration(1)
await this.panda.device.device.claimInterface(0)
await this._setPowerSaveState()
await this._heartbeat()
// use SAFETY_ELM327
await this.panda.setSafetyMode(3)
// not using event based message delivery
Expand All @@ -52,6 +57,37 @@ class EcuWorker {
console.error(err)
}

async _setPowerSaveState() {
console.log('normal power mode ...')
let params = {
request: 0xe7,
value: 0,
index: 0
}
await this.panda.device.vendorRequest(params, 0);
}

async _heartbeat() {
try {
if (!this.panda || !this.panda.device || !this.panda.device.device || !this.panda.device.device.opened) {
return
}

console.log('heartbeat ...')
let params = {
request: 0xf3,
value: 0,
index: 0
}
await this.panda.device.vendorRequest(params, 0);
}
catch (e) {
console.log(`heartbeat failed: ${e.toString()}`)
}
// send heartbeat every second to keep panda from going into no output mode
this.heartbeatHandle = setTimeout(this._heartbeat, 1000)
}

async setFirmwareFile(file) {
if (file) {
console.log('parse rwd file ...')
Expand All @@ -73,7 +109,6 @@ class EcuWorker {
console.log('connecting ...')
console.log(serialNumber)
// can not use panda.start() because it calls requestDevice which is not supported from a Web Worker
//await this.panda.start()
await this._connectWebWorker(serialNumber)
if (this.rwd && this.rwd.canAddress) {
console.log(`0x${this.rwd.canAddress.toString(16)}`)
Expand Down

0 comments on commit 84c0fd8

Please sign in to comment.