Created
September 23, 2020 23:45
-
-
Save harrylepotter/6f20e27de8dab6bb62e4211a7d8db65b to your computer and use it in GitHub Desktop.
Read audi RNS-e and push to keystrokes for use by headunit apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//requires : | |
// socketcan 2.2.2 | |
// child_process - | |
// underscore (any version) | |
var can = require('socketcan'); | |
var channel = can.createRawChannel("can0", true); | |
var _ = require('underscore'); | |
var cp = require('child_process'); | |
var _execAdb = function(button){ | |
//cp.exec('xdotool search --class headunit windowactivate --sync %1 key ' + button, function(err,stdout, stderr){ | |
cp.exec('xdotool key ' + button, function(err,stdout, stderr){ | |
console.log('stdout:', stdout); | |
}); | |
} | |
var execAdb = _.debounce(_execAdb, 150); | |
// Log any message | |
channel.addListener("onMessage", function(msg) { | |
//console.log(msg.data.toString('utf8')); | |
if(msg.id == 1121){ | |
var digits = []; | |
if(msg.data[2] != 0x01) | |
return; | |
for(var i=0; i<5; i++){ | |
digits.push(msg.data[i].toString(16)); | |
} | |
var sigout = digits.join(' '); | |
console.log(sigout); | |
if(sigout == "37 30 1 0 20"){ | |
console.log("MMI turned right"); | |
execAdb('Right'); | |
}else if(sigout == "37 30 1 0 40"){ | |
console.log("MMI turned left"); | |
execAdb('Left'); | |
}else if(sigout == "37 30 1 0 10"){ | |
console.log("MMI pressed"); | |
execAdb('Return'); | |
}else if(sigout == "37 30 1 80 0"){ | |
console.log("MMI lower left"); | |
execAdb('Down'); | |
}else if(sigout == "37 30 1 40 0"){ | |
console.log("MMI upper left"); | |
execAdb('Up'); | |
}else if(sigout == "37 30 1 0 1"){ | |
console.log("setup"); | |
execAdb('Tab'); | |
}else if(sigout == "37 30 1 0 2"){ | |
console.log("return"); | |
execAdb('Esc'); | |
}else if(sigout == "37 30 1 2 0"){ | |
console.log("ffwd"); | |
execAdb(87); | |
}else if(sigout == "37 30 1 1 0"){ | |
console.log("rwnd"); | |
execAdb('m'); | |
} | |
} | |
}); | |
// Reply any message | |
//channel.addListener("onMessage", channel.send, channel); | |
channel.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment