-
Building a lexer that handles serial output is painful, because you never know when the output finishes. Imagine sending multiple commands in quick succession which return one or multiple lines, building something to properly handle that is really tricky, especially if the first commands take longer to return.
I didn't know about theSerial1.setConsole
, I will take a look and see what options are available.I don't view implementing additional options on the espruino itself as a good idea, because these just take up memory and force other users to use the same options. For example, I would be interested in a "search-through-history" feature where you press
ctrl+r
like on linux, start typing some text and the matching commands are shown, and I already implemented something similar in here, but most users wouldn't even be aware of that.Take a look at how other projects do it, the most popular servers are distributed with a separate client (mysql, redis, mongodb). They implement a protocol, and you can build alternate clients for them if you need to.
Anyway, I'm totally fine with the status quo, these are just my 2c :P if the "cli-on-espruino" will not change and cannot be avoided/disabled, we'll just have to adapt to it.
-
(I think we should create separate threads of discussion if these go any further)
@Gordon I am aware of
echo(0)
, but that does not help. I want to know when a command finishes, in a consistent manner. At the moment, I can only read the output, which is inconsistent when single commands return single or multiple lines, and inconsistent when a command spans over multiple lines. I saw that you got over this problem by waiting for 100ms in the Web IDE, but that's a slow hack, not a proper solution solution.You said you wanted something easy to get started with, but not getting in the way if you want something more advanced. At the moment, the protocol only allows simple things and is getting in the way of something more advanced. I wanted to implement a more advanced cli, that's why I asked if there is a protocol other than espruino's cli.
My purpose was to have a cli which allowed command history, which sent minified commands, which only sent the commands once the code block was closed, and it should also implement internal commands such as
.sendFile('path/to/file.js')
. A GUI could be built on top of it, even integrated with chrome.If that is not possible, then I guess we'll have to deal with the current behavior, and simply forward everything to espruino and wait for 100-1000 miliseconds after every command.
-
I tried something similar, but the terminal implementation on the espruino itself is the painful part. I was surprised to find out that the board is the one implementing the CLI and the serial connection simply sends/receives text characters.
Is it possible to use a communication protocol and bypass espruino's CLI? Or maybe configure espruino to not send the cli prefix
>
, nor the response prefix=
. You could also view it as a consistency problem, espruino is sending\r\n
at the end of intermediate lines, and\r>
at the end of output, but interpreting the text is wrong and can lead to a lot of problems.Overall, is there a way to connect to the board without using its CLI, in order to implement a (proper) cli?
-
I tracked it down to the slide on the edge towards the 10uF condenser. Just pressing it down a little but using a pen makes the board work. I am pointing to the disconnected slide in this photo.
I took some photos using my phone since I don't have another camera. They are high res, but the phone's sensor is rather limited. Here's the link with the pictures, there is also an archive if you want to download all of them. Warning: large sized pictures.
-
Keeping the
RST
button pressed helped debug the issue. The contact between the connector and the board needs resoldering or a complete change, looks rather tricky for my bulky soldering iron. I guess they are not as resistant as I had hoped, I only plugged/unplugged the cable a couple of times. I guess I'll speed up my USB extension cable purchase :)If anyone is curious: applying pressure on the back of the board's connector (on the margin that sits towards the inside of the board) makes it work.
-
I was unaware that setTimeout supported timeouts of less than 1 ms, you have
0.07
. I don't yet know whether this is an Espruino feature.As for the
eval
'd strings, you can always pass a function that returns what you want to run, take a look at line 51. -
I'm not sure what the default value is for time or if you want
0.1
to be the time. I believe the second param should either be1
or0
, nothing in between. Try setting it all params explicitly, like this:digitalPulse(C7, 1, 100)
And make sure that
100
ms pass before running it again. Here is an example where I'm pulsating the led every 2 seconds, check out line 45.The official reference lists the format as
digitalPulse(pin, state, time)
, where:pin
idstate
either 1 or 0 (for high or low)time
in miliseconds
-
False alarm. I guess it worked for 1 second. Here is the
dmesg
output when I handled the operation described above:[30086.430599] usb 3-1: new full-speed USB device number 6 using xhci_hcd [30086.430724] usb 3-1: Device not responding to set address. [30086.634859] usb 3-1: Device not responding to set address. [30086.838994] usb 3-1: device not accepting address 6, error -71 [30101.974199] usb 3-1: new full-speed USB device number 8 using xhci_hcd [30101.991363] usb 3-1: New USB device found, idVendor=0483, idProduct=5740 [30101.991366] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [30101.991368] usb 3-1: Product: STM32 Virtual COM Port [30101.991369] usb 3-1: Manufacturer: STMicroelectronics [30101.991370] usb 3-1: SerialNumber: 48DF62573330 [30101.991480] usb 3-1: ep 0x82 - rounding interval to 1024 microframes, ep desc says 2040 microframes [30102.072469] cdc_acm 3-1:1.0: This device cannot do calls on its own. It is not a modem. [30102.072487] cdc_acm 3-1:1.0: ttyACM0: USB ACM device [30102.072735] usbcore: registered new interface driver cdc_acm [30102.072737] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters [30102.146920] usb 3-1: USB disconnect, device number 8
It disconnected without me unplugging it. Now there is no output, i retried the steps above. It does not look like it's dead, it still blinks the red led after resetting, but the logs are empty. I'll explore additional options tomorrow :(
-
@Gordon, you suggested
peek
andpoke
, how can we tell which addresses are safer than others? -
I did what cephdon suggested. Here's how it went:
- plug in, no output in dmesg, plug out, change cable, plug in, no output.
- hold RST then BTN1 pressed for ~1 sec, then plug out and release buttons
- plug in, I saw the red LED light up for a split second, dmesg said
Device not responding to set address
again. - hold RST then BTN1 again for ~1 sec, then plug out and release buttons
- plug in, I saw the red LED light up for a split second again, dmesg shown proper registration as USB ACM device
Thanks cephdon. I hope the steps I listed here help others and help debug :)
- plug in, no output in dmesg, plug out, change cable, plug in, no output.
-
After compiling the linux version and running some tests locally, when I plugged the Espruino board in,
/dev/ttyACM0
did not exist. After several retries, includingRESET
on Espruino, I noticed there was no output indmesg
. Changed the USB hub, still nothing.After a PC restart, this is the message I got in
dmesg
, but only the first time I plug the board in:[ 70.487846] usb 3-2: new full-speed USB device number 5 using xhci_hcd [ 70.487912] usb 3-2: Device not responding to set address. [ 70.691909] usb 3-2: Device not responding to set address. [ 70.896019] usb 3-2: device not accepting address 5, error -71
Subsequent plugins do not output anything. Does this sound familiar to anyone? (i did not flash the board, other usb devices are working)
Later edit: I added
usbcore.old_scheme_first=1
to grub init, same thing, no dmesg output when plugging in. The cable works, tested with my phone.Later later edit: I tested with the Espruino board I got for a friend and it works :( So I guess mine is bricked ... somehow... no messages are output by dmesg anymore, not even after restart(s). I remember the red led flashing for a fraction of a second (very short time) when I plugged it in and I noticed it wasn't working.
-
-
The only
make
targets in theMakefile
are:clean gdb serialflash flash proj
Tried each with
BOARDNAME=1 RELEASE=1 ESPRUINO_1V3=1 make <target>
, but no espruino script, only the binaries, so the compiler works.Tried with
LINUX=1 make
, and it outputs a lot of warnings and this errorlibs/graphics/lcd_sdl.c:18:21: fatal error: SDL/SDL.h: No such file or directory # include <SDL/SDL.h> ^
Tried with
BOARDNAME=1 RELEASE=1 ESPRUINO_1V3=1 LINUX=1 make
, and it exits with this error:src/jsutils.c:21:19: fatal error: mconf.h: No such file or directory # include "mconf.h" ^
Tried with
LINUX=1 make -i
(ignore errors), to no avail. Cleaned every time before new run.Any hints? :)
-
-
-
-
I noticed that many functions are not implemented, and some uncommon behaviour is not supported (eg: [1,2,,,5]), but those are not common problems.
You will find many inconsistencies by running the tests here, but I will list the most likely to affect users:
Unexpected
if
behaviourvar asd = 1; if ( undefined ) asd = 2; console.log('asd is:', asd); // 1 - is actually 2
Math.abs(-5) === 5
,Math.log(Math.E*Math.E) === 2
andMath.log(1) === 0
should returntrue
, but returnfalse
no
Date
objectNumber.POSITIVE_INFINITY === Infinity
should be true but is actually false, same forNEGATIVE_INFINITY
(8.5).toString(16)
should be8.8
but found8.5
(-8.5).toString(16)
should be-8.8
but found-8.5
09
should be9
but found0
019
should be19
but found1
var i = -8; i >>>= 24
should be255
but found1099511627775
Math.PI
should be3.141592653589793
but found3.141592653590000061569
Math.E
should be2.718281828459045
but found2.718281828459999882596
Math.atan2(-1, Infinity)
should be negative0
(so-0
) but foundNaN
toFixed
does not work although I remember @Gordon saying it was implemented'abc' ? 1 : 2
should be1
but found2
Trying to
delete
non-deletable properties eg:delete Array.prototype
should returnfalse
but object is returned.delete
always returns the value, so it's impossible to tell if the property was deleted or not from its return.Redefining a var inside the same scope does not work
var a = 'asd'; console.log(a); // asd var a; console.log(a); // undefined - is actually asd
no unicode
var u = "a\u1234c"; console.log(u.charCodeAt(1)) // 4660 - is actually 117
the
for (x in y)
works differently with {}, for example the following code behaves differently if curly braces are used to wrap{propnames.push(i);}
, view the comments.var arr = new Array('a','b','c'); var propnames = []; for (var i in arr) propnames.push(i); console.log(propnames.length); // 3 - is actually 1 console.log(propnames[0]); // 0 - is actually 2 console.log(propnames[1]); // 1 - is actually undefined console.log(propnames[2]); // 2 - is actually undefined
Other than not-yet-implemented functions and these examples, most tests in here run ok.
-
-
-
Nice solution, Bogdan. I would improve it to allow passing params from one to another, so you would not need to use globals. This does degrade readability though:
function setupBTN1(customParams) { return function() { function test() { return callback(); } var id = setWatch(test, BTN1, {repeat:false, edge:"rising"}); function callback() { console.log('Hello! watch id was', id, 'and customParams was', customParams); clearWatch(id); setTimeout(setupBTN1(customParams + Math.random()), 1000); } }; } setupBTN1(0)();
-
I created a LED dimming function (source code). It does what I expect it to do every
DURATION
miliseconds, with an exception. I added two console logs to highlight the problem, this is the line which does not work,clearInterval(stepInterval)
, loggingERROR: Unknown Interval
.
All the otherclearInterval
s seem to be working. Here is some sample output from the script:run to 1 clearing stepInterval number 11 ERROR: Unknown Interval should have cleared stepInterval number 11 done 1. done 0.99 run to 0 clearing stepInterval number 13 ERROR: Unknown Interval should have cleared stepInterval number 13 done -0. done 0.01 run to 1 clearing stepInterval number 15 ERROR: Unknown Interval should have cleared stepInterval number 15 done 1. done 0.99 run to 0 clearing stepInterval number 17 ERROR: Unknown Interval should have cleared stepInterval number 17 done -0. done 0.01 run to 1 clearing stepInterval number 19 ERROR: Unknown Interval should have cleared stepInterval number 19
So the intervals keep adding up, I assume it will either run out of memory or gray dragons will come out of the espruino board.
Any hints?
-
-
-
I doubt it will be, and you can define your own function or just use:
Please test this, I haven't :P