New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When I setWatch on B5 for MPU6050_DMP module, HTTP server becomes completely unresponsive, and Web IDE can no longer send code. #367
Comments
If I try to get the DMP data in the HTTP handler, then at least HTTP is responsive, but the DMP data doesn't work, it just says "FIFO overflow" every time: function getMPU() {
I2C1.setup({scl:B6,sda:B7, bitrate:100000});
var MPU6050 = require("MPU6050");
console.log(MPU6050);
var mpu = MPU6050.connect(I2C1);
return mpu
}
function connectToWifi(wifiName, options) {
var resolve, reject
var promise = new Promise(function(res, rej) {resolve = res; reject = rej})
var wifi = require("EspruinoWiFi");
wifi.connect(wifiName, options, function(err) {
if (err) reject(err);
resolve();
});
return promise
}
connectToWifi("CenturyLink6344", { password : "zpx2psajg7xqat" })
.then(function() {
const mpu = getMPU();
const dmp = require('MPU6050_DMP').create(mpu, 3);
const http = require("http");
let dmpYawPitchRoll = null
//function dmpLoop() {
//const dmpData = dmp.getData()
//if (dmpData !== undefined) console.log(dmpYawPitchRoll = dmp.getYawPitchRoll(dmpData))
//}
//setWatch(dmpLoop, B5, { repeat:true, edge:'rising' });
http.createServer(function (req, res) {
res.writeHead(200);
let result = {
acceleration: mpu.getAcceleration(), // returns an [x,y,z] array with raw accl. data
gravity: mpu.getGravity(), // returns acceleration array in G's
rotation: mpu.getRotation(), // returns an [x,y,z] array with raw gyro data
degreesPerSecond: mpu.getDegreesPerSecond(), // returns gyro array in degrees/s
}
result = JSON.stringify(result)
res.end(result);
const dmpData = dmp.getData()
if (dmpData !== undefined) dmpYawPitchRoll = dmp.getYawPitchRoll(dmpData)
console.log(' ------ dmpYawPitchRoll:', dmpYawPitchRoll)
}).listen(80);
const wifi = require("EspruinoWiFi");
wifi.getIP(function(err, info) {
if (err) throw err
console.log('IP:', info.ip)
});
});
function onInit() {
console.log('Espruino started!');
} So far, it seems like the only way I can get data is with that setWatch interrupt loop, which makes the whole thing unresponsive. |
@trandi Might you know about it? Is there a reason that the setWatch loop makes the HTTP server unresponsive? Do you know if I can just get the data from the MPU6050 module (not MPU6050_DMP), transform it, and pass it to the |
What have you actually connected B5 to? It seems like if it's the IRQ from the MPU6050 then it could be triggering so often that it's using up all of the board's processing power? You could also see if Actually looking at the code for Can you try But please ask questions like this on the forum in future. That's what it's for - you'll get a much better response to any queries, since realistically very few people read GitHub bugs apart from me. |
I deleted that one. It was based on the other issue. I'll try your advice, and I will also bring up these issues in the forums and just post on GitHub when there's a confirmed issue. Thanks for the awesome product and responsiveness! |
Thanks! |
@gfwilliams I'm only doing that " while (fifoCount < PACKET_SIZE) fifoCount = DMP.getFIFOCount();" that you're worried about after testing "if (status & 0x02) { // otherwise, check for DMP data ready interrupt (this should happen frequently) " |
@trandi thanks for weighing in - I don't suppose you get anything like this happening for you? I'm struggling to see what could be causing it. Looks like this is getting discussed here now: http://forum.espruino.com/conversations/306037 |
However, the setWatch loop can continue to log to the console despite both HTTP being unreachable and Web IDE not being able to upload new code (it just hangs).
I've got some code like follows:
The Espruino Wifi server doesn't work when I do that, it is completely unresponsive to the requests sent by my computer.
If I add a console.log, like
then the Espruino WiFi continuously outputs data, so it seems to be running.
Maybe the loop is like a real loop, where all else is blocked? How might I make this work so that I can send the data back to computer? Do I need to make requests inside the dmpLoop instead of making an HTTP server?
The text was updated successfully, but these errors were encountered: