Commit 0063b1dc authored by Ryan Day's avatar Ryan Day

adding working pinoccio example

parent 960adb28
......@@ -8,12 +8,12 @@ var data = fs.readFileSync(__dirname+'/../../panda-attack/bootstrap.hex')+'';
var hex = intel_hex.parse(data).data;
//var pageSize = 256;
var pageSize = 256;
var baud = 115200;
//var delay1 = 10;
//var delay2 = 1;
/*
var signature = new Buffer([0x1e, 0x98, 0x01]);
var delay1 = 10;
var delay2 = 1;
var signature = new Buffer([0x1e, 0xa8, 0x02]);
var options = {
timeout:0xc8,
......@@ -24,7 +24,7 @@ var options = {
pollValue:0x53,
pollIndex:0x03
};
*/
var comName = '/dev/ttyACM0';
......@@ -36,16 +36,37 @@ var serialPort = new serialport.SerialPort(comName, {
console.log(serialPort);
});
var flasher = stk500(serialPort);
flasher.parser.on('rawinput',function(buf){
var programmer = stk500(serialPort);
// debug
programmer.parser.on('rawinput',function(buf){
console.log("->",buf.toString('hex'));
})
flasher.parser.on('raw',function(buf){
programmer.parser.on('raw',function(buf){
console.log("<-",buf.toString('hex'));
})
flasher.sync(2,function(err,data){
console.log('callback',err," ",data)
})
// do it!
programmer.sync(5,function(err,data){
console.log('callback sync',err," ",data)
});
programmer.verifySignature(signature,function(err,data){
console.log('callback sig',err," ",data);
});
programmer.enterProgrammingMode(options,function(err,data){
console.log('enter programming mode.',err,data);
});
programmer.upload( hex, pageSize,function(err,data){
console.log('upload> ',err,data);
programmer.exitProgrammingMode(function(err,data){
console.log('exitProgrammingMode> ',err,data)
})
});
......@@ -64,13 +64,13 @@ stk500.prototype.sync = function(attempts, done) {
error.code = "E_CMD_ERROR";
} else if(response[1] !== c.STATUS_CMD_OK){
// malformed. check command status constants and return error
error = new Error('command status was incorrect. '+response[1]);
error = new Error('command status was not ok. '+response[1]);
error.code = "E_CMD_STATUS";
} else {
var len = response[2];
res = response.slice(3)+'';
if(res.length != len) {
// something is wroing but all signs point to right,
// something is wrong but all signs point to right,
}
}
}
......@@ -143,7 +143,6 @@ stk500.prototype.verifySignature = function(signature, done) {
}
stk500.prototype.getSignature = function(done) {
console.log("read signature");
var self = this;
var reportedSignature = new Buffer(3);
......@@ -158,7 +157,6 @@ stk500.prototype.getSignature = function(done) {
var cmd = new Buffer([CMD_SPI_MULTI, numTx, numRx, rxStartAddr, 0x30, 0x00, 0x00, 0x00]);
self.parser.send(cmd, function(error, pkt) {
console.log("sent sig1");
if (pkt && pkt.message && pkt.message.length >= 6)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment