-
@loopMasta - did you get your file server working? Would you be able to share the code - I could really use this :)
-
Hi
I've got console working over Serial1 successfully :). Some questions
Is it possible to change the baud rate of the console? I tried setting the serial
to 38400 and then using setConsole, but the webIDE didn't work. (Just curious -
9600 may be fine...)Is there any flow control on serial? If I try to send big files, would it work?
Does the firmware update work over serial, or does it require USB?
Thanks
Martin
-
Guys
I've been playing with Wiznet, and I get the same problems - if I try HTTP transactions more frequently than every 30s, I get "socket error -7"
However, for the record, I've also seen other errors including - "no free sockets" and "SPI communications error"
Gordon - if you do some work on this, I'm very happy to test it
Martin
-
-
Hi
I'm using setWatch on an input that has 50hz pulses which are ~0.9ms wide. I was expecting to see two callbacks alternating true/false per pulse, one for each edge - but I actually see multiple successive true or false values. This seems strange.
My code
'''
var states=new Array();
var index=0;function onpulse(e)
{
states.push(e);
if (index<100) index++;
}setWatch(onpulse,C5,{repeat:true,edge:'both',debounce:0});
'''I'm storing the state change data in an array to try to be sure I'm catching
all the events - I thought that printing them might cause some to be lost.The output I get looks like this
'''
for(var i=0;i<100;i++) {print(states[i]);}
{"lastTime":undefined,"time":41004.582653045654296875,"state":false}
{"lastTime":41004.582653045654296875,"time":41004.5826625823974609375,"state":false}
{"lastTime":41004.5826625823974609375,"time":41004.588489532470703125,"state":false}
{"lastTime":41004.588489532470703125,"time":41004.588512420654296875,"state":true}
{"lastTime":41004.588512420654296875,"time":41004.58955669403076171875,"state":false}
{"lastTime":41004.58955669403076171875,"time":41004.60842227935791015625,"state":false}
{"lastTime":41004.60842227935791015625,"time":41004.60844326019287109375,"state":true}
{"lastTime":41004.60844326019287109375,"time":41004.60946750640869140625,"state":false}
{"lastTime":41004.60946750640869140625,"time":41004.62811374664306640625,"state":false}
{"lastTime":41004.62811374664306640625,"time":41004.62813091278076171875,"state":true}
{"lastTime":41004.62813091278076171875,"time":41004.62916660308837890625,"state":false}
{"lastTime":41004.62916660308837890625,"time":41004.647785186767578125,"state":false}
{"lastTime":41004.647785186767578125,"time":41004.64781093597412109375,"state":true}
{"lastTime":41004.64781093597412109375,"time":41004.64885044097900390625,"state":false}
{"lastTime":41004.64885044097900390625,"time":41004.6675014495849609375,"state":false}
{"lastTime":41004.6675014495849609375,"time":41004.66751956939697265625,"state":true}
{"lastTime":41004.66751956939697265625,"time":41004.66753864288330078125,"state":true}
'''What's puzzling me is that there doesn't seem to be any pattern - I was
expecting true,false, true, false...Any ideas?
Martin
-
-
-
-
Does the webIDE recursively check requires? I require a module in RHS from website. webIDE downloads it. Does it check inside the downloaded text for a new require?
Does the webIDE have some way to tell the device "this is a module, insert it into your cache". What name does it give it? I mean, if I use require("http://....date.js") is it added to the cache with the full path or just the filename? (Just curious)
I still think there is a throttle bug somewhere. I'll try the gitHub webIDE, but otherwise I'll finalize the modules and put them on SD card... that will work around it for now.
Thanks
-
@graf - your method can't handle a varying number of arguments. Note - I have tested my method, and it works fine :) It's actually pretty logical now that I've understood JS a bit better. The constructor is just a function, and I'm just passing a reference to it out :)
It does say a few messages back that I'd tried throttle before, and it doesn't help.
Actually, I'll be more specific. Right now I'm doing the following
- Requiring date in my RHS test code - this works with throttle on
- Requiring clock in my RHS test code
- requiring date again inside my clock code
It seems to be only the LAST one that generates the odd errors.
This raises questions
If there's a module cache, why does my second-level require inside clock attempt to re-load date? (I can see it printing log messages, so it is doing
this)Hmm - presumably the second-level require inside clock is being handled by the device, not the IDE. Maybe the problem is that the code in the device to read from an HTTP address also needs throttle?
Martin
- Requiring date in my RHS test code - this works with throttle on
-
-
DrAzzy
Your method above won't support arguments to the constructor - my code supports zero, 1 and 7 arguments. Gordon seemed to think my method was fine :)
I just retested with minify off, and I get the same sort of bizarre error.
I then just copied the whole of Date and Clock modules into RHS, and fixed
the exports to use a variable - and it all works.Just to double-check, I copied the modules to the SD card - again it works fine.
These errors strongly suggest that throttle isn't working and characters or chunks of source are being dropped. I could just copy the files to SD card and re-test.
Gordon - I have 1v61, Chrome 34.0.1847.116 on Win 8.1 pro
I think this may be only happening because I'm nesting requires. Not sure.
Martin
-
Gordon
Thanks. Files attached. Please remember this is my first serious piece of JS - feedback appreciated :)
My current test code for using it looks like this:
var Date=require("http://192.168.0.12/date.js").constructor; var Clock2=require("http://192.168.0.12/clock.js").constructor; print("hello"); print(Clock2); var clk=new Clock2(2014,15,4,23,57,0,0); function showClock() { print(clk.getClockTime().toString()); } setInterval(showClock,1000);
The result on running:
Date Module - Loading...
Before date fn
After date fn
getDayssinceepoch
setDayssinceepoch
Done Loading Clock Module
Date Module - Loaded.
Clock Module - Loading
xLoading Date
xDone loading Date
ERROR: Using '.' operator on non-object at line 66 col 29
print("Clock module - Loaded.");^
ERROR: Got String:');
' expected ID at line 66 col 31
print("Clock module - Loaded.");^
hello
undefined
ERROR: Constructor should be a function at line 1 col 161
var Date=require("http://192.168.0.12/date.js").constructor,Clock2=require("http://192.168.0.12/clock.js").constructor;print("hello");print(Clock2);var clk=new Clock2(2014,15,4,23,57,0,0);function showClock(){print(clk.getClockTime().toString())}setInterval(showClock,1E3);^
Throttle sending is ON. Minify is set to 'simple optimisations'
Martin
-
Gordon
re: 1v61 - yes, I think so. Will check. I am updating quite often, but have multiple devices.
re: Recursive - Clock requires Date, but Date doesn't require Clock. Clock creates a subclass of Date.
The error really does look odd - I included print statements in the module, and it seems to just skip some of them and jump to a lower statement and then complain.
It's not lost characters, more like lost chunks of 100 bytes or more. Hard to debug - I can't see what it's actually getting.
Martin
-
Gordon
Thanks. However, I hit another problem last night: I now have this
Main file
var Clock = require("http://192.168.0.12/clock.js").constructor;
Clock file:
var Date= require("http://192.168.0.12/date.js").constructor;
Is there any issue with doing nested requires?
Note - I previously appeared to have corruption problems, so I turned on the 'throttle' option. It now seems to be missing some of the code in the second require - is there any chance the throttle setting only applies to the first file?
BTW - throttle is very slow :(
Thanks
Martin
-
-
@gadicc - your solution looks good, but I don't know what it would look like inside the module source. "connect" is usually declared as a function member of 'exports' and I suspect declaring the date constructor as "exports.connect = function.." might stop it being a date constructor...
Ah, someone at my work has said that if I declare the date as normal
Date = function ()...
Then put a line like this
exports.Date=Date;
Then I can use it like this
Date = require('date').Date;
var d1 = new Date();
I'll test this approach soon...
Martin
Martin
-
Sacha
Thanks, but I was hoping for something a bit more like 'new'
Imagine I want three date objects. I guess I'd have to write
x=require('date');
d1=x.connect();
d2=x.connect();It's not very elegant, IMHO :)
There's also the problem of passing constructors.
d=require('date'.connect(args)
I think I can do this using 'apply' inside the 'connect'' function but I'm not sure
how exactly it would look.Martin
-
Gordon, DrAzzy
Thanks. I got the require("http").. working
But how do I create a Date() type within a module which is accessible to users of the module using 'new'? So for example
require("date");
d=new Date();
I did have a reasonable look for any other file like this, didn't see one... maybe I missed it?
Martin
-
Hi All
I've written a Date and Clock module. The Date module uses the same API as JS Date (but doesn't implement everything at all), and Clock inherits from it. (It's all a bit rough so want to polish a bit more before sharing :)
I'm a bit of a newbie at JS, so have a few questions...
Should these be two modules or one? I guess two... any reason why not?
Is there any way to get WebIDE to pull modules from either a) my PC or b) multiple locations? Can it pull them direct from my github account?
These aren't device modules - where would I put them in github?
Is there any convention for unit tests for Espurino modules?
Thanks
Martin
-
-
-
Hi All
After a bit of playing about, I've got Espruino posting data to grovestreams.com. This is an internet of things site, like xively - but the limits on free use are more reasonable, and the pricing for non-free seems OK too. It also seems to have good features.
Debugging the code was a bit tricky as the service is a little fussy about some details. Also, I'm using the Wiznet ethernet, and there are some problems with it on Espruino right now.
I'm deliberately using the JSON body version of the grovestreams PUT feed to allow for future expansion.
I've attached my code in case it helps anyone.
Note - I've also found a website which allows me to query the current time without NTP :)
Martin