Debugging from Web - Embedded boards - javascript

So excited to asks experts on this platform. I don't know where my question fits but anyone familiar with ARM mbed or dev.ti.com?
Let me give you a clue. On these website they provide an online IDE (just like desktop version) on which you can build an "Embedded Software" and download, run and Debug on some target board like (TIVA C, STM32 etc.) connected to PC. As far as i know javascript on web page doesn't have any access to local machine. So how does it access computer ports and computer drivers etc?
WEB Experts please give me a clue like how browser is allowed to access local computer resources??

In most cases, you're correct - Javascript running in your browser does not have access to many of the resources needed for reprogramming and debugging a development board.
However, there are a few ways to work around this:
1. Build development boards that can work with the hardware APIs the browser already allows access to.
This usually involves using APIs in unexpected ways. The integrated debug firmware on all mbed boards emulates a USB disk drive. The user can download the firmware file from the mbed site and then copy it onto the disk drive to install the firmware on the development board.
There are also some more creative (mis)uses of hardware APIs. For example, this Chibitronics board relies on the browser sending the new firmware via audio output. I have also heard about - but cannot find a suitable link to - an example of repurposing the U2F protocol to do double duty as a firmware update mechanism.
Because this approach repurposes existing APIs, it is generally widely supported, but requires extra work on the device side to fit a square peg into a round hole.
2. Install a native application/extension that accesses hardware and allows the website to access the hardware through the extension.
This is the approach used by TI Cloud Tools, Arduino Create, and Codebender. Once a user has installed a companion application, that application allows the website to access anything that a normal IDE would be able to access.
In a sense, this approach is very similar to building a native application with a very cloud-centric UI.
3. Extend browsers to add new hardware APIs that can be used to program development boards.
The WebBluetooth and WebUSB draft standards add new APIs to allow Javascript to access BLE and USB devices directly, which can then be used to communicate directly with connected USB debug hardware or BLE bootloaders.
micro:bit is currently testing a beta program that uses WebUSB to directly program and communicate with micro:bit boards.
These APIs are only implemented in Chrome, so they are not a universal solution. Additionally, due to security restrictions and driver issues, not all existing hardware is compatible with WebUSB.

As far as i know javascript on web page doesn't have any access to local machine. So how does it access computer ports and computer drivers etc?
You can access your local machine through a server. For example to ask it for a certain file or to run some commands/code through an API you define.
How browser is allowed to access local computer resources?
The browser is a program on your machine. The programming language(s) in which the browser was built provides interfaces to communicate with your system on a low level.
It's worth mentioning that the browser and the web application it renders are not the same and do not communicate in the same way with your system.

Related

Chrome app vs extension? What else allows access to the tabs open in the browser?

I'm making an app that requires access to the tabs the user has open at the time. I haven't found a way to access this information without deploying my app using Chrome itself.
However, making an extension limits the UI severely (and my app requires a nice, organized UI). However, I understand Chrome apps are about to be discontinues. What other alternative do I have?
Chrome offers extensions as a way to gain access to the internals of the Chrome browser. As mentioned, apps are being discontinued. You can no longer publish new apps which are not specifically for Chrome OS. There are no other API alternatives to gain direct access to the internals of Chrome.
As with any program that is running on a multiprocess operating system or windowing system, your application can use OS and windowing system specific methodologies to snoop on other processes/windows. How to do that is OS/windowing system specific and is way beyond a single Stack Overflow question/answer. However, there is an alternative available that is specifically intended for the case which you describe.
Use Native Messaging
For what you want: Access to internal Chrome information (e.g. the open tabs) while maintaining full control of your user interface (to the extent available in your OS of choice), the documented methodology available to you is to use Native Messaging. You will need to create a Chrome extension to provide access to Chrome internal information. You can communicate that information to the OS native application, which you also create, using the native messaging API. As with most such APIs, it is just a communications channel. You will need to create a message format/protocol which covers your needs.

Alternative for java applet which needs to communicate with browser via javascript

In our web application, we using a Java applet to invoke MS.Word application by jacob jar e.g. Word to open, edit, and when it saves automatically it uploaded to the server.
Google Chrome will no longer support NPAPI, so soon we can not run our applet in Chrome anymore.
So, any suggestions for an alternative for the Java applet. We want to make the same experience for the user, just like before.
We have the same problem. With Webstart is not longer possible to do that communication. We are going to use Websockets between webstart application and browser. Our first attempt is to start a websockets server in the webstart and make browser connect to localhosts. If this is not possible for security limitations in the browsers then we are going to do it through the webserver, browser and webstart application connecting to the webserver and exchanging messages.
I can see 2 distinct possibilities.
Create a standalone application that "wraps" your web application using a technology such as electron. You can then do your browser to desktop integration as you like. This will require an install on the client.
Launch a webstart application (or it could really be any installation that happens on the client). It will need to start a webserver, or connect to a webserver and communicate via http.
I'm saddened by the loss of the Applet. It is a technology not easily replaced. And another methods seem somewhat like 'workarounds'. There is no easy, cross-browser way to break out of the browser sandbox and access the system.
For myself, the loss of the Applet has simply meant that automating some of these processes has become too difficult and it is just better to find an alternative way of achieving a similar end result.
A small note: If you are starting a local webserver, be mindful of security. It can be accessed by other processes on the system. Wouldn't it be fun to open word on anyone's system by sending a request to a port!

How to use the browser as the GUI for an offline application?

I want to be able to create an offline program that can use the browser as GUI. I'm not particularly good at GUI programming in general, and overall it seems that using HTML and CSS to structure a GUI would be the easiest.
Cross browser method is preferred, but I will most likely use Google Chrome
I need to be able to open an external program, possibly with command line arguments
Javascript seems like the best language for this, however as far as I know it isn't possible to launch programs with it.
This is on Windows 7.
That's a good idea and is done by a several popular softwares.
The best way is to make your offline program run a web server that the browser will be able to access.
ie: Your program starts a web server on localhost:5555 and then you'll be able to request http://localhost:5555/users in Javascript, from your browser.
Another approach could be using a UI framework like AngularJS + local storage. I'm working on an app right now that will be used online (connected to the web), online locally (connected to a local server that is not connected to the web), and offline.
You could build a single-page web app and let Angular manage all the "urls".

How can I access to USB stick from website?

I'm planning to make a login system by USB, so if you put in a USB-drive and open a specific webpage, the website asks the USB-drive for the code (e.g. by a JavaScript file, a redirect or something like that).
The problem is, because of sandboxing, you can't load or redirect to local files. I don't know a solution for this problem. Can you guys help me? I don't need specific code, just an example or something in that way.
Maybe you can read up on USB-HID. Wikipedia:
The USB human interface device class (USB HID class) is a part of the USB specification for computer peripherals: it specifies a device class (a type of computer hardware) for human interface devices such as keyboards, mice, game controllers and alphanumeric display devices.
Here are some references:
USB HID (Human Interface Device)
node-hid - Access USB HID devices from node.js
DepthJS: 'Allows any web page to interact with the Microsoft Kinect using Javascript'.
A related Stackoverflow question:
Write data to USB HID using Javascript, HTML5, or any cross platform language (supports Android)
One other possibility is to check out the Chrome HID (Human Interface Device) APIs:
Interacting with USB HID devices from web apps – via Chrome Apps, see below
Relevant Chrome API docs
Please note that for the time being, you cannot interact directly with the USB device (i.e. you cannot access any WebAPI offering that kind of fine-grained control).
Building a Chrome App (different from a Chrome Extension) may help; This article may point you in the right direction, since it also provides sample code.
The only way I can think of is putting a html file on the usb stick that essentially generates some sort of login token and gives you a link or a form to a login processor. You can then access the webpage by opening the local file first which will redirect you to the actual webpage.
This local script may include a javascript from the server to get some challenge-response-data which it hashes somehow (perhaps in combination with a password) and puts it into the form data.
Web PKI authentication from Modern Browsers may be achieved by using Browser Extension. One such extension is Signer.Digital browser extension. Use below Javascript promises from the APIs provided by Signer.Digital extension.
SignerDigital.getSelectedCertificate() to register user's certificate
SignerDigital.signHash(hash) to sign token at browser and verify at server
For all Javascript APIs refer to SO Answer https://stackoverflow.com/a/63173083/9659885
Disclaimer : I work for a company supporting the application below
Hello, you may try to use Nexu open-source application for communication with smartcards or USB tokens. It also support PKCS 12 keystores.
For example, the application is connected to the DSS webpage on the website of European Commission : see the link.

web application development with j2me

The main reason I'd like to use j2me is that one of its main advantages is that it can access the phone's resources through its various APIs. However, due to newer phones having web browsers like Safari, Opera, and Windows IE, it would be advantageous to build a web application so a user wouldn't have to download some software onto their phone. Is there a way I could build a web application that can also acquire resource information about the phone? Or maybe have j2me converted to Javascript (if that's even possible)?
You can make a link that would send an SMS, but other than that, there's no cross-platform api for accessing phone internals from browser, as far as I know.
So, if you've got to access phone's resources, you'll have to write a real app.
The webkit engine on recent Series60 phones has been given access to at least some phone resources.
Nokai calls it Web Runtime or WRT.
http://www.forum.nokia.com/Resources_and_Information/Documentation/

Categories