Is it possible to control hardware from Javascript in a web
application in the same or similar way as Silverlight does?
Thank you
Which bit of the hardware does Silverlight control?
We're working on an application that controls peripherals (webcam,
printer, cashier drawer, ...). I am not doing the hardware side,
a .NET guy is and he's using Silverlight at my suggestion because that
is what seemed to be best way to handle the job after a little bit of
research I did on the subject.
My question comes because if Silverlight is capable of doing it I am
pretty sure that it does it using Javascript (although I could be
wrong). If that is the case I would like to know how it can be done
with straight Javascript.
I also found an article explaining that although not simple, it is
possible to do it: http://blog.kevinhoyt.org/?p=361
> We're working on an application that controls peripherals (webcam,
> printer, cashier drawer, ...).
I sure hope there is absolutely no way to do that with plain old javascript running on your every
day browser.
Rui Maciel
Silverlight can control a cashier drawer? I'd really like to see that.
> I am not doing the hardware side,
> a .NET guy is and he's using Silverlight at my suggestion because that
> is what seemed to be best way to handle the job after a little bit of
> research I did on the subject.
>
> My question comes because if Silverlight is capable of doing it I am
> pretty sure that it does it using Javascript
No it is not. If it does it that is.
> (although I could be
> wrong). If that is the case I would like to know how it can be done
> with straight Javascript.
No, it can't.
"rf" <r...@z.invalid> wrote in message
news:5LWfo.5221$Yv....@viwinnwfe01.internal.bigpond.com...
Silverlight can run trusted applications which have more power than non
trusted, and with trusted silverlight application
"COM automation enables access to devices and other system capabilities
such as a Universal Serial Bus security card reader."
ref :
http://www.microsoft.com/silverlight/faq/.
However silverlight is a plug-in and this functionality doesn't come thru
the standard browser JS interpreter.
Pepe,
En el navegador pelao y mondao no existe ningún objeto a través del
cual puedas acceder al hardware. Te puedes imaginar que no estaría
bien que una página web cualquiera pudiese hacerlo...
Cuando instalas un plugin al navegador, el plugin crea objetos nuevos
que extienden su funcionalidad y que puedes usar desde el contexto de
JavaScript. Si te sirven para lo que quieres, como -al parecer- es el
caso de SilverLight, perfecto. Pero si no instalas algún plugin
específicamente para ese fin, no, no hay manera de hacerlo, no en un
navegador tal y como viene instalado por defecto.
Espero no haberme colado al presuponer que vas a poder leer esto en la
lengua de Cervantes :-)
Saludos,
--
Jorge.
Gracias Jorge. Con tu respuesta y la de news.virginmedia.com se me han
clarificado bastante las ideas.
Muchas gracias. ;)
Based on the other answers I got I believe you got your wish. :)
I don't think this is done yet but I am almost 100% sure the .NET
developer has already tested a few things to see if it was possible
and the project is still in full swing so I guess it is going to be
done in the near future.
> No it is not. If it does it that is.
Based on other answers it seems that JS is not capable of doing this
by itself. Bummer! :)
> No, it can't.
Ditto.
Thank you very much for your answer. It has helped me understand
tremendously how this is possible with Silverlight and not JS.
>> Silverlight can control a cashier drawer? I'd really like to see that.
>
> I don't think this is done yet but I am almost 100% sure the .NET
> developer has already tested a few things to see if it was possible
> and the project is still in full swing so I guess it is going to be
> done in the near future.
That being true then it is yet another reason why everyone should avoid Silverlight.
Rui Maciel
.NET validates type safety and memory access, and typically equates this
with security.
but, AFAIK, it doesn't really lock down APIs or valiate application
behavior, and this is a possible problem area (one can at least hope they
blocked off "obvious" things, like some of the stuff that made VBScript so
damn problematic...).
it is like, I have a JavaScript variant (or a half-assed JavaScript-like
language, either way...) I am using for scripting some in my apps, but it
has some features which are important for my uses, but would be terrible in
a web-browser, such as the ability to fairly directly make use of C API's,
... (a project feature was to bypass the need to write boilerplate to expose
C-level and OS-level APIs to the script language, and machinery is also in
place for patching it together with the C typesystem, ...). this is done
largely via a "magic object" which "contains" the C toplevel.
a cost, though, is that if such a feature were available in a browser, it
would be a terrible security risk.
or such...
There's a lot of good reasons to avoid it, but this is not one of
them. Say it allowed you to create, configure and and expose a cashier
object with e.g. a drawerOpen() function, and say that that object
only worked for a certain page/domain/url, what security risk would
that pose ?
--
Jorge.
Pepe,
Ten en cuenta que también sería posible hacer todo esto sin
SilverLight ni ningún otro plugin, arrancando una aplicación helper en
la máquina local que mediara con el hardware, que podría ser un
servidor que puedes perfecta y muy muy fácilmente escribir en
javascript con Node.js, de manera que abrir el cajón simplemente se
convertiría en una RPC, que se activaría facilísimamente sólo con
acceder mediante un XHR a una url del tipo http://localhost:PORT/command?openDrawer
desde la aplicación web. Por ejemplo, esto abriría el cajón:
<a href="http://localhost:8080/command?openDrawer >Open it</a>
Creo que sería una solución *mejor* que usar SL, por que, ya puestos a
tener que instalar cosas adicionales, lo mismo te daría que fuese un
plugin para el navegador que el .exe de un helper, no ?
--
Jorge.
If you're using JScript through Internet Explorer (with low security
settings)or an HTML Application it is possible to do what you're
asking if a COM interface is exposed.
Among all the possible choices, that would probably be the most
unwise... :-/
--
Jorge.
Before an application uses any of the Silverlight code the client must
accept it and install Silverlight (or some Silverlight part) for the
code to work. IMHO that is more or less like whenever a user accepts
the a new update for Windows, Adobe, or any other company. Are there
risks? Certainly. But so it is having a PC connected to the Internet.
What we are doing here is making an application that is browser based
and runs in an intranet (obviously, not everybody owns a cashier
drawer to tinker with).
I am not a security expert, far from it, but I guess you can always
secure your network, independently of some part of your application
having access to some of the hardware attached to a given terminal.
Sé que el programador de .NET tiene que instalar "algo" en el cliente
antes de poder comunicar con el hardware, así que me imagino que lo
que está haciendo más o menos lo que estás escribiendo. De todas
formas soy bastante nuevo trabajando con PCs y sobre todo con
Javascript y la tecnología de la red, como seguramente ya te habrás
imaginado, así que no sé muy bien qué es lo que está haciendo el otro
programador. No trabajamos en la misma oficina y no intercambiamos
mucha información.
Well, if you like the Mission Impossible movies, how about 2 people
working at the same time, one controlling the application to open the
drawer and another one getting the money and closing the drawer right
away? ;)
Of course the question was regarding the possibility and not the
wisdom.