Jump to content

New JavaScript Bindings for Test


iia

Recommended Posts

  • Replies 61
  • Created
  • Letzte Antwort

Top Posters In This Topic

What if the stack is connected via e.g. WiFi-Extension and no brickd is running on the localhost?

Then the attacker would indeed have to know the IP of the WiFi-Extension. There is no way for the browser to scan your network or similar.

 

Shure?

But the browser can determine the local IP and test, step by step, all local addresses via websockets to find the stack?

 

Der Loetkolben.

Link zu diesem Kommentar
Share on other sites

Shure?

But the browser can determine the local IP and test, step by step, all local addresses via websockets to find the stack?

 

Der Loetkolben.

I don't think that is practical. You can't determine what subnet the local network uses. But it doesn't matter, both options also protect the Ethernet and WIFI Extension ;).

Link zu diesem Kommentar
Share on other sites

I tried the new BrickD on a raspberry pi. First of all I got the following error:

(Reading database ... 72768 files and directories currently installed.)
Preparing to replace brickd 2.0.10 (using brickd-2.1.0-rc1_armhf.deb) ...
Stopping Brick Daemon: Stopped process in pidfile '/var/run/brickd.pid' (pid 2133).
update-rc.d: using dependency based boot sequencing
Unpacking replacement brickd ...
dpkg: dependency problems prevent configuration of brickd:
brickd depends on pm-utils; however:
  Package pm-utils is not installed.

dpkg: error processing brickd (--install):
dependency problems - leaving unconfigured
Processing triggers for man-db ...
Errors were encountered while processing:

 

Trying to install pm-utils manually returned the following error:

 

sudo apt-get install pm-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
pm-utils : Depends: powermgmt-base but it is not going to be installed
            Recommends: vbetool but it is not installable
            Recommends: hdparm but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

 

I think the main problem is, that the raspberry pi can't use pm-utils since it hasn't got a powermanagement. Did anyone else solve this problem?

 

Edit: I ran apt-get intall -f.  hdparm pm-utils and powermgmt-base were installed an the installation of brickd continued.

 

Edit 2: I got it running. But the problem should be solved to ensure a clean installation. Great work! Getting the temperature on a web inteface without using an additional php script is a much better and cleaner way.

Link zu diesem Kommentar
Share on other sites

Robin, I tested this before posting here about RC1. I used a Raspberry Pi here running Raspbian and it worked without problems.

 

The first problem you mentioned is expected if you don't have pm-utils already installed. This is because dpkg doesn't do any dependency handling for your, that's what apt-get is for. dpkg only tells you what dependencies are missing and you have to install them manually.

 

The second error is unexpected and I didn't encounter it during testing. Also this dosen't look to me as dpkg is rejecting the installation because the hardware might not support suspend. pm-utils is just a bunch of scripts that allow to forward suspend/resume events.

 

I think the pm-utils dependency will stay as it is, because your second problem looks like an apt-get hiccup to me and not like a general problem.

 

Anyway, thanks for testing :)

Link zu diesem Kommentar
Share on other sites

I put the JS File into Eclipse (JS View) and got the following two Errors just for information if there is a problem or Bug in it.  Version from "2014-02-26"

- The left-hand side of an assignment must be a variable    Tinkerforge.js

function assert (test, message) {

  if (!test) throw new Error(message || 'Failed assertion')

}

 

},{"base64-js":55,"ieee754":56}],55:[function(require,module,exports){

var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

 

- Syntax error on token ",", ArrayLiteralHeader expected after this token    Tinkerforge.js

// TODO(shtylman)

process.cwd = function () { return '/' };

process.chdir = function (dir) {

    throw new Error('process.chdir is not supported');

};

 

},{}],54:[function(require,module,exports){

var base64 = require('base64-js')

var ieee754 = require('ieee754')

 

-------

 

What IDE are you (all) using for JS development?

Link zu diesem Kommentar
Share on other sites

I just tried it in Eclipse and i get the same two errors. But after formatting the js around that place a little better so it is human-readable i can't find a problem.

 

I think the Eclipse parser is either not able to parse the relatively complex output of browserify or it has problems with ECMA 5. The eclipse i have only seems to be able to understand ECMA 3, while the code might need a ECMA 5 parser.

 

The Javascript for Browser Bindings will only support the (currently) latest Browsers and versions up from here. The latest Firefox, Chrome, Safari and even IE are very standard compliant and compatible regarding JavaScript and Websockets. If you go only 2 or 3 versions down it suddenly becomes a minefield :D.

Link zu diesem Kommentar
Share on other sites

I would like to introduce an early alpha version of the Web Brick Viewer: http://www.brickv.com

 

It is our attempt to implement a Bick Viewer-like tool with web technologies and new JavaScript for browser bindings. The current version supports Ambient Light, Barometer, Humidity and Temperature Bricklet.

 

If you open http://www.brickv.com your browser will download an index.html and lots of JavaScript. After that everything is done in your browser and on your local PC, there is no communication with the internet whatsoever.

 

You can also find brickv.com on github: https://github.com/Tinkerforge/brickv.com if you download it from there you can just open the index.html with your browser, there is no webserver necessary!

 

This is currently just a small side project to test and debug the JavaScript Bindings in combination with HTML5 and modern browsers.

 

I tried it on the latest versions of Firefox, Chrome/Chromium and IE. In IE you need to allow access to local intranet sites, see last answer here: http://stackoverflow.com/questions/15114279/websocket-on-ie10-giving-a-securityerror.

 

If you want to help us develop a Web Brick Viewer, this is a very easy to understand project! It should be easy to get into. We would appreciate any help.

 

The version that is currently online is compatible to the Brick Daemon release candidate that we released in this thread. Before we make an official release we will add authentication to our protocol and the Brick Daemon, which will then also be added to the Web Brick Viewer.

 

At the moment the Web Brick Viewer is just a side project but the trend seems to go more and more towards smart phones and tablets instead of PCs. This means that it might be necessary for us to create access and configuration possibilities directly from Android/iOS/Windows Phone. So in the future it might become a replacement or supplement for the Desktop Brick Viewer.

 

brickv.com should adjust itself to the resolution of your device (smart phone vs tablet vs PC) and delivery a UI that is best suited for your device.

Link zu diesem Kommentar
Share on other sites

 

Perfekt! (Running on FF 27)  :D

 

Just a remark:

Using IE 8 seems not to work. The "About" and "Legal Info" Information are not viewable. Because i have no Stack at the IE 8 PC location i can not test the connection.

 

BTW: Do you have a Beta Firmware for Masterbrick which support Web-Sockets?

 

 

Der Loetkolben

Link zu diesem Kommentar
Share on other sites

Great work, but I have problems... When I connect to my raspberry pi only one bricklet is detected. The others are shown but Unknown. I changed the UID of most of these bricklets because I couldn't use enumerate since I have two bricklets of the same type in my stack and I wanted the bricklets to be self evident. The only bricklet which is detected is the temperature bricklet (UID also changed.) I atached a screenshot of the problem. I'm using Firefox 27.0.1. The temperature bricklet is displayed and works as expected.

 

Another thing (just an improvement) would be the connection dialog. It would be more useable if the connection would be open when you hit the Enter Key.

brickv-com-problem.thumb.JPG.db97b1318f1173ce60c0c5ee94984c0d.JPG

Link zu diesem Kommentar
Share on other sites

@Robin: As i said, the current version only supports Ambient Light, Barometer, Humidity and Temperature Bricklet. It is a very early alpha, i just started the project 4 days ago ;).

 

Connecting when pressing enter is a good idea.

 

It is a project that you can get into really easy. You can just clone the git, add some small features and make a pull request. After we accept the pull request it will automatically be available on brickv.com.

 

I was hoping to get some help from the community with this project after we officially release the JavaScript Bindings, we will see if it works out ;D.

Link zu diesem Kommentar
Share on other sites

Oh sorry, I dind't see it. Maybe because I read it on my mobile phone. Currently I have some trouble with my computer but I think I will try to add some bricklets.

 

Edit: I added support for the hall effect bricklet. Currently I'm installing GitHub for Windows so it will take some time until I will upload the files. I attached a screenshot. On the top of the graph should be the value of edge count but I couldn't figure out how to display the value of the bricklet in the graph and show the edge count on the top of the graph. Anyway, it works and it is pretty easy after looking around a bit. Good code ;)

 

Edit2: Done.

brickv-hall-effect.thumb.JPG.6ca3dabddb9455e0cfe7a18a1f15a3f7.JPG

Link zu diesem Kommentar
Share on other sites

I think my last big pull request: added Analog In, Rotary Poti and Temperature IR Bricklet support. The Temperature IR Bricklet does not show the ambient temperature in the graph. Is it possible to display two lines in one graph?

 

Edit: I think the Web Brick Viewer also should be able to detect updates. Of course it is not possible to flash a new firmware on a brick or blicklet with the Web Brick Viewer but it might display updates with a message such as "Updates available, use your Computers Brick Viewer". The main problem in this case would be that Web BrickV would lose its online independence. Maybe there should be an option in a .js file: search for updates. By default it could be false.

Link zu diesem Kommentar
Share on other sites

Of course it is not possible to flash a new firmware on a brick or blicklet with the Web Brick Viewer ...

 

Hello Robin,

 

this could be possible if the web-brickv connects to a brickd running on PC. In this case the web-brickv could instruct the brickd to start the commandline-brick-flasher.  ;D

 

 

Der Loetkolben.

Link zu diesem Kommentar
Share on other sites

Bricklet flashing is definitely possible with the web brickv. For Brick flashing we need access to USB devices, which is not directly possible with the browser (It could be done as Loeti says).

 

@Robin: I will add support for more then one graph in to the Graph-class tomorrow. Then it should be possible to display all the graphs that we also use in the normal brickv.

Link zu diesem Kommentar
Share on other sites

But I think this solution is very unsecure. A crashing browser and nobody knows what happend...

Or (again me) a hacker who modifies the software of the ethernet or wifi extension or (maybe in the future) the firmware of the RED Brick just with your webbrowser. There are also some driver issues when Bricks are in bootloader mode (such as being recognized as LEGO NXT) so I think the web browser would be very limited in debugging. The mess would be complete when you try to flash a brick from a remote client.

Another problem are the root privileges. Under Ubuntu I have to run BrickV with root privileges to access the USB to Serial Converter in Bootloader mode to flash a Brick. But it would be absolutely inresponsible to run BrickD with root privileges to offer a platform independent flashing solution over the webbrowser. So I think this solution can't be available on every platform which would make such a solution very unstable.

Flashing Bricklets might be possible, but I'm not shure if a Web Browser is the right choice to write directly on the hardware. Okay, theres the BrickD which could handle occuring errors but it feels wrong to use a webbrowser. It seems a bit like Scifi for me ;)

Link zu diesem Kommentar
Share on other sites

I think you are wrong in all cases :). The possibility to flash Bricklets is always there with the JavaScript Bindings. It just uses our normal API. We will add authentication before we release the JavaScript Bindings to be save in that regard.

 

Regarding the stability for flashing Bricklets: The web brickv can flash Bricklets exactly the same way as the normal brickv. There is really no difference, you can pick the file to flash from you local storage and flash it to the Bricklet without using the Internet in any  way or form.

 

If you want to fetch the current firmware from our server it can do that and then flash the Bricklet without internet access (exactly the same way that the normal brickv does it). I can't see why it would be worse in some way. I bet that all of the latest browsers are way more stable then our hacked together Brick Viewer ;).

 

To flash the Bricks without using root you can add your user to the group "dialout".

Link zu diesem Kommentar
Share on other sites

Okay, you got me. I'm currently adding Ananlog Out support to BrickV. But I have some trouble with the setMode function. When I set the mode, it seems that it isn't applied. Instead of setting the new mode the mode is resettet to normal mode. If I change the mode in the desktop BrickV the value is stored. I called:

this.ao.setMode(1);

which didn't work as well as

this.ao.setMode(Tinkerforge.BrickletAnalogOut.MODE_1K_TO_GROUND);

 

Is this an error in the binding or did I make some silly mistake? As I understood it is up to me if I use an integer or the constant because the constant just stores the integer and improves the readabilty of the code?

Link zu diesem Kommentar
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.


×
×
  • Neu erstellen...