Simple programs such as blink seem to transfer and run just fine, but I'm working with some Wifi and Http code that is significantly longer and it doesn't seem to transfer correctly. Log is below. The hardware is relatively new, but it worked correctly for about a day.
Steps I've tried so far to resolve:
Unplugged it and plugged it back in again (yea, I worked in IT, gotta start there)
Used another USB cable
Turned on "Throttle Send" in the settings
Commented out large chunks, and the error moved to another line
Environment:
Espruino Web IDE used as Chrome App
Mac OSX 10.12.6
>
Connected
>echo(1)
=undefined
>< << {"VERSION":"1v91","BUILD_DATE":"Jan 12 2017","BUILD_TIME":"10:55:52","GIT_COMMIT":"a6300790b771b7afffdb2bb2d8c5d0607f7977ef","BOARD":"ESPRUINOWIFI","CHIP":"STM32F411CEU6","CHIP_FAMILY":"STM32F4","FLASH":524288,"RAM":131072,"SERIAL":"43001d00-0b513532-39333638","CONSOLE":"USB","EXPORTS":{"jsvLock":336089,"jsvLockAgainSafe":336075,"jsvUnLock":336049,"jsvSkipName":184381,"jsvMathsOp":141949,"jsvMathsOpSkipNames":141995,"jsvNewFromFloat":336405,"jsvNewFromInteger":336441,"jsvNewFromString":339205,"jsvNewFromBool":336425,"jsvGetFloat":184749,"jsvGetInteger":180485,"jsvGetBool":185337,"jspeiFindInScopes":145525,"jspReplaceWith":154073,"jspeFunctionCall":150877,"jspGetNamedVariable":145585,"jspGetNamedField":146857,"jspGetVarNamedField":146449,"jsvNewWithFlags":336245}} >> >
>
=undefined
>
_____ _
| __|___ ___ ___ _ _|_|___ ___
| __|_ -| . | _| | | | | . |
|_____|___| _|_| |___|_|_|_|___|
|_| http://espruino.com
1v91 Copyright 2016 G.Williams
>Connecting to sensor
>Starting Wifi connection
Uncaught SyntaxError: Got '(' expected ','
at line 1 col 22
function start(equire('http');
^
ERROR: Prompt not detected - upload failed. Trying to recover...
=undefined
>echo(1)
=undefined
Connected!
Uncaught Error: Function "start" not found!
at line 6 col 3
start()
// Constants
var DEVICE_ID = "1234";
var WIFI_NAME = "*********";
var WIFI_OPTIONS = {
password : "*********"
};
var SERVER_ADDRESS = '*********';
var SERVER_PORT = 3000;
// Connect to Sensor
var ow = new OneWire(A0);
var sensor;
console.log('Connecting to sensor');
try {
sensor = require("DS18B20").connect(ow);
} catch (e) {
console.log('Unable to connect to sensor \n', e.message);
}
// Connect to Wifi
console.log('Starting Wifi connection');
var wifi = require("EspruinoWiFi");
wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) {
if (err) {
console.log("Wifi Connection error: "+err);
return;
}
console.log("Connected!");
start();
});
var http;
function start() {
http = require('http');
if (sensor) {
getTemp();
//setInterval(getTemp, 60000);
} else {
// TODO: Report failure to somewhere
}
}
function getTemp() {
sensor.getTemp(function(temp) {
console.log("Temp is "+temp+"°C");
sendTemp(temp);
});
}
function sendTemp(temp) {
var postData = {
value: {
temperature: temp,
unit: 'celsius'
},
};
var reqPath= '/api/devices/' + DEVICE_ID;
var req = http.request({
host: SERVER_ADDRESS,
port: SERVER_PORT,
path: reqPath,
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
}, function(res) {
console.log("STATUS: " + res.statusCode);
console.log("HEADERS: " + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function(data) {
console.log("HTTP> "+data);
});
res.on('close', function(data) {
console.log("Connection closed");
});
});
req.on('error', function(e) {
console.log("ERROR: problem with request: " + e.message);
});
req.write(postData);
req.end();
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Simple programs such as blink seem to transfer and run just fine, but I'm working with some Wifi and Http code that is significantly longer and it doesn't seem to transfer correctly. Log is below. The hardware is relatively new, but it worked correctly for about a day.
Steps I've tried so far to resolve:
Environment:
Mac OSX 10.12.6