Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing hardware

2 views
Skip to first unread message

pepe

unread,
Sep 1, 2010, 8:49:39 AM9/1/10
to
Hello,

Is it possible to control hardware from Javascript in a web
application in the same or similar way as Silverlight does?

Thank you

rf

unread,
Sep 1, 2010, 9:02:23 AM9/1/10
to

"pepe" <pepe.h...@gmail.com> wrote in message
news:7df5c561-bb0b-44af...@d8g2000yqf.googlegroups.com...

> Hello,
>
> Is it possible to control hardware from Javascript in a web
> application in the same or similar way as Silverlight does?

Which bit of the hardware does Silverlight control?


pepe

unread,
Sep 2, 2010, 10:05:22 AM9/2/10
to
On Sep 1, 9:02 am, "rf" <r...@z.invalid> wrote:
> "pepe" <pepe.hipol...@gmail.com> wrote in message

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

Rui Maciel

unread,
Sep 2, 2010, 11:28:53 AM9/2/10
to
pepe wrote:

> 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

rf

unread,
Sep 2, 2010, 7:50:13 PM9/2/10
to
pepe wrote:
> On Sep 1, 9:02 am, "rf" <r...@z.invalid> wrote:
>> "pepe" <pepe.hipol...@gmail.com> wrote in message
>>
>> news:7df5c561-bb0b-44af...@d8g2000yqf.googlegroups.com...
>>
>>> Hello,
>>
>>> Is it possible to control hardware from Javascript in a web
>>> application in the same or similar way as Silverlight does?
>>
>> Which bit of the hardware does Silverlight control?
>
> We're working on an application that controls peripherals (webcam,
> printer, cashier drawer, ...).

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.


news.virginmedia.com

unread,
Sep 3, 2010, 8:12:44 AM9/3/10
to

"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.

Ry Nohryb

unread,
Sep 3, 2010, 8:45:31 AM9/3/10
to

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.

pepe

unread,
Sep 3, 2010, 9:36:56 AM9/3/10
to

Gracias Jorge. Con tu respuesta y la de news.virginmedia.com se me han
clarificado bastante las ideas.

Muchas gracias. ;)

pepe

unread,
Sep 3, 2010, 9:38:49 AM9/3/10
to

Based on the other answers I got I believe you got your wish. :)

pepe

unread,
Sep 3, 2010, 9:41:14 AM9/3/10
to
> 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.


> 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.

pepe

unread,
Sep 3, 2010, 9:42:55 AM9/3/10
to
On Sep 3, 8:12 am, "news.virginmedia.com" <pchris...@yahoo.co.uk>
wrote:


Thank you very much for your answer. It has helped me understand
tremendously how this is possible with Silverlight and not JS.

Rui Maciel

unread,
Sep 3, 2010, 10:33:09 AM9/3/10
to
pepe wrote:

>> 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

BGB / cr88192

unread,
Sep 3, 2010, 11:22:48 AM9/3/10
to

"Rui Maciel" <rui.m...@gmail.com> wrote in message
news:4c810727$0$6947$a729...@news.telepac.pt...

.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...


Ry Nohryb

unread,
Sep 3, 2010, 12:24:22 PM9/3/10
to

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.

Ry Nohryb

unread,
Sep 3, 2010, 12:46:40 PM9/3/10
to

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.

Michael Haufe ("TNO")

unread,
Sep 3, 2010, 1:32:15 PM9/3/10
to

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.

Ry Nohryb

unread,
Sep 3, 2010, 6:00:18 PM9/3/10
to
On Sep 3, 7:32 pm, "Michael Haufe (\"TNO\")"

<t...@thenewobjective.com> wrote:
>
> 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.

pepe

unread,
Sep 4, 2010, 12:43:12 PM9/4/10
to

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.

pepe

unread,
Sep 4, 2010, 12:49:35 PM9/4/10
to
> 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 tipohttp://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.

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.

pepe

unread,
Sep 4, 2010, 12:50:41 PM9/4/10
to
> 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.

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? ;)

Michael Haufe ("TNO")

unread,
Sep 4, 2010, 2:29:32 PM9/4/10
to


Of course the question was regarding the possibility and not the
wisdom.

0 new messages