Parallel port access using Google native Client (N

2019-07-19 07:01发布

问题:

I am trying to write a Chrome app that would support printing to old printers connected to the computer via the parallel port. I found out that Chrome apps can not use any kind of NPAPI plugins so those are out of the question. The remaining option seems to be NaCl or PPAPI plugin. But does PPAPI or pepper or NaCl (I am not very familiar with any of them and am probably using them in the wrong context) support access to the parallel port? Can a PPAPI plugin be written, which supports parallel port communication? Thanks for your time and efforts.

回答1:

You can usually write to the parallel port like to a file. (it's a few decades since I did this the last time myself though)

in Linux use /dev/lp0 as file name
see also https://superuser.com/questions/301753/how-do-i-print-directly-to-lpt-port-in-ubuntu

in Windows LPT0

see also
* https://developers.google.com/native-client/dev/devguide/coding/file-io

EDIT
I thought chrome packaged apps are allowed to access the local file system.
If that is limited to a sandboxed area it may not allow access to the parallel port.
Using NaCl seems to support unlimited access to local files, so this will probably work.



回答2:

Packaged apps have access to the USB ports, along with serial ports. http://developer.chrome.com/apps/api_index If you are writing a javascript app, you might be able to access this functionality without writing a native client app, however if you are writing in C/C++ a subset of these APIs are available using the Pepper APIs.