Using serial ports in Google Chrome packaged apps in Windows

4,100 views
Skip to first unread message

Роман Осипов

unread,
Jul 17, 2012, 9:01:15 AM7/17/12
to chromi...@chromium.org
Does anybody know what are names of serial ports in Google Chrome packaged apps API for Windows? COM1, \\.\COM1 and many others do not work

Paul Kinlan

unread,
Jul 17, 2012, 10:11:38 AM7/17/12
to Роман Осипов, chromi...@chromium.org
Hi,

You should be able to enumerate the list of valid ports using the getPorts API call. http://code.google.com/chrome/extensions/trunk/apps/experimental.serial.html#method-getPorts

P


On Tue, Jul 17, 2012 at 2:01 PM, Роман Осипов <roman...@gmail.com> wrote:
Does anybody know what are names of serial ports in Google Chrome packaged apps API for Windows? COM1, \\.\COM1 and many others do not work

--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-apps/-/EjH6cPOPgOQJ.
To post to this group, send email to chromi...@chromium.org.
To unsubscribe from this group, send email to chromium-app...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/?hl=en.



--
Paul Kinlan
Developer Advocate @ Google for Chrome and HTML5
Skype: paul.kinlan

Роман Осипов

unread,
Jul 18, 2012, 12:09:56 AM7/18/12
to chromi...@chromium.org
Thanks, but method getPorts is absent in the stable Chrome, it is a feature of the Canary branch, but returns always empty array. Its interesting, but writing to the serial port in Linux works well, may be using serial ports is not realized yet in Windows?

Paul Kinlan

unread,
Jul 18, 2012, 2:14:40 PM7/18/12
to Роман Осипов, chromi...@chromium.org
This API is not available on anything but Dev and Canary channel, the serial API will only work in the new app mode.

Tony Wong

unread,
Nov 19, 2012, 9:36:37 AM11/19/12
to chromi...@chromium.org, Роман Осипов
I am using chrome beta version 25.0.1329.0 beta-m trying to build a simple packaged app to connect to windows COM1 port.
However, i keep failing as i can't even list available port using chrome.serial.getPorts function. can anyone shed some light here?

Renato Mangini

unread,
Nov 19, 2012, 11:04:21 AM11/19/12
to Tony Wong, chromi...@chromium.org, Роман Осипов

But what exactly happens? Can you send the error message and a small piece of code?


Renato Mangini | Chrome Developer Advocate | man...@google.com | +55 11 3797-1155



--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.

Tony Wong

unread,
Nov 19, 2012, 7:49:47 PM11/19/12
to chromi...@chromium.org, Tony Wong, Роман Осипов
I am trying to send a command to my POS pole display via serial port "COM4" under windows xp.

I tried to write it in c# windows application and it works just fine:
using (SerialPort port = new SerialPort("COM4", 9600, Parity.None, 8))
 {
          byte[] bytesToSend = new byte[6] { 0x1B, 0x46, 0x41, 0x42, 0x45, 0x0D };
          port.Open();
          port.Write(bytesToSend, 0, 6);
}

Now, I would like to re-write the above code into chrome package app:

var bufView =new ArrayBuffer(6);
bufView[0] = 0x1B;
bufView[1] = 0x46;
bufView[2] = 0x41;
bufView[3] = 0x42;
bufView[4] = 0x45;
bufView[5] = 0x0D;

chrome.serial.open("COM4", {bitrate:9600},function(cInfo) {                          
                chrome.serial.write(cInfo.connectionId , bufView , function() { });                
});

It just doesn't work. Then I tried to use getPorts function under chrome serial API to test if the API supports Windows XP:

chrome.serial.getPorts(function(ports) {
              for (var i=0; i<ports.length; i++) {
                console.log(ports[i]);
              }
});

It doesn't work either. The ports.length will always return 0 despite the fact that I have 4 serial ports on Windows XP......
Looks like the serial API isn't platform independent?!

Best,
Tony

Emanuele Ziglioli

unread,
Nov 19, 2012, 8:16:26 PM11/19/12
to chromi...@chromium.org, Tony Wong, Роман Осипов

chrome.serial.getPorts(function(ports) {
              for (var i=0; i<ports.length; i++) {
                console.log(ports[i]);
              }
});

It doesn't work either. The ports.length will always return 0 despite the fact that I have 4 serial ports on Windows XP......

On Windows 7 I don't gen any output either. Just undefined
 
Looks like the serial API isn't platform independent?!

Sure it is, but have you got any result on any windows platform?
The windows implementation should be here:

I've just started learning and playing with Chrome extensions and packaged apps and am really excited due to hardware apis and crossplatform support.
First I've tried running the serial demo as a hosted web app but it doesn't look like the object chrome.serial is present.
I find it easier to develop an app as a hosted (crx-less) app as opposed to a packaged app.
You can't just reload (F5) and packaged app, can you?
so ideally I would develop first a hosted app with these experimental apis.

Tony Wong

unread,
Nov 19, 2012, 9:18:57 PM11/19/12
to chromi...@chromium.org
It seems to me that no one has ever successfully using the chrome serial API on windows platform.

may be there are some bugs in the API.....

Emanuele Ziglioli

unread,
Nov 19, 2012, 9:40:53 PM11/19/12
to chromi...@chromium.org
Yeah, it'd be difficult to debug into Chrome's native C++ code. I wonder if we could use Eclipse with CDT.

All I can see so far is that the call to chrome.serial.getPorts() returns an array of length 0.
Running Chrome as an administrator doesn't help either.
In Device Manager I see:
USB Serial Port (COM6)
Driver Provider: FTDI
Driver Date: 10/04/2012
Driver Version: 2.8.24.0
Digital Signer: Microsoft Windows Hardware Compatibility Publisher

We normally use terminal programs such as sterm, and others, or Java APIs such as RxTx and SerialIO.

Tony Wong

unread,
Nov 19, 2012, 9:50:22 PM11/19/12
to chromi...@chromium.org
Accessing serial devices from chrome packaged app is an excellent feature that allow us to use web technology to play with peripheral devices.

I hope google team will take a look at this problem seriously as that is really critical for developer like us.... or it may be a simple bug fix ....


On Tuesday, July 17, 2012 9:01:15 PM UTC+8, Роман Осипов wrote:

Tony Wong

unread,
Nov 19, 2012, 10:00:41 PM11/19/12
to chromi...@chromium.org
oh! I see. but the reply is funny:

"I'll try to take a look at this soon, but I have to find my serial-port adapter for my Windows machine (which I took home and then lost)."

May be we can buy him a new serial-port adapter!!!

Emanuele Ziglioli

unread,
Nov 19, 2012, 10:05:12 PM11/19/12
to chromi...@chromium.org
not sure how much testing has been done on Windows, if any. Other comments in the code:

// 1. You have an Arduino or compatible board attached to your machine and
// properly appearing as the first virtual serial port ("first" is very loosely
// defined as whichever port shows up in serial.getPorts). We've tested only
// the Atmega32u4 Breakout Board and Arduino Leonardo; note that both these
// boards are based on the Atmel ATmega32u4, rather than the more common
// Arduino '328p with either FTDI or '8/16u2 USB interfaces. TODO: test more
// widely.

Emanuele Ziglioli

unread,
Nov 19, 2012, 10:09:14 PM11/19/12
to chromi...@chromium.org
By the way, here are some instructions on how to debug Chromium within Eclipse.
It looks challengine, but I could spend a couple of hours one of these evenings:

Renato Mangini

unread,
Nov 20, 2012, 10:42:07 AM11/20/12
to Tony Wong, chromi...@chromium.org, Роман Осипов
chrome.serial.getPorts(function(ports) {
              for (var i=0; i<ports.length; i++) {
                console.log(ports[i]);
              }
});

It doesn't work either. The ports.length will always return 0 despite the fact that I have 4 serial ports on Windows XP......
Looks like the serial API isn't platform independent?!

Well, it should be. Could you please report a bug about getPorts returning nothing and send me the URL? I will make sure the right engineer looks at it asap.

Thanks!

Renato Mangini

unread,
Nov 20, 2012, 10:51:50 AM11/20/12
to Emanuele Ziglioli, chromi...@chromium.org, Tony Wong, Роман Осипов

Some comments inline:

On Mon, Nov 19, 2012 at 11:16 PM, Emanuele Ziglioli <the...@emanueleziglioli.it> wrote:

I've just started learning and playing with Chrome extensions and packaged apps and am really excited due to hardware apis and crossplatform support.
First I've tried running the serial demo as a hosted web app but it doesn't look like the object chrome.serial is present.

You can't. The new APIs available to packaged apps, in special the device access ones, are not available to hosted apps. 

I find it easier to develop an app as a hosted (crx-less) app as opposed to a packaged app.
You can't just reload (F5) and packaged app, can you?

Not with F5, but you just right click on any window of your packaged app and you get the "Reload App" option, as long as you are in Developer mode (checkbox on top of chrome://extensions page). And if you set an ID to your window in chrome.app.window.create(), even the size and position will keep the same when reloading. Same for the DevTools/inspector window, if it was open when you reloaded.
 
so ideally I would develop first a hosted app with these experimental apis.

You might have your reasons, but I prefer developing local instead of having to change files in a server. Last time I was in a plane, I could implement a simple app completely offline, which would be much harder using hosted apps.


Tony Wong

unread,
Nov 20, 2012, 11:00:03 AM11/20/12
to Renato Mangini, chromi...@chromium.org, Роман Осипов

Emanuele Ziglioli

unread,
Nov 20, 2012, 5:08:42 PM11/20/12
to chromi...@chromium.org, Emanuele Ziglioli, Tony Wong, Роман Осипов

Oi Renato,



You can't. The new APIs available to packaged apps, in special the device access ones, are not available to hosted apps. 

Yeah, I just wanted to try. I'm still trying to understand the various differences between extensions, hosted apps and packaged apps (good article here: https://developers.google.com/chrome/web-store/articles/apps_vs_extensions). Correct me if I'm wrong. Hosted apps are like web apps but they can work offline. Plus, they can do more than a traditional web app, provided users grant them permissions. So the fact that hosted apps cannot access hardware is just a formality, am I wrong?

If 'packaged apps' fly, I'm planning to use them to replace our current java based GUIs (hopefully mobile platforms will be supported too eventually).
We need hardware support in order to access serial ports. And we need offline support for when our users in the field don't have access to the internet.
But I'd like to make their user experience from online to offline as seamless as possible. It'll be hard enough to explain what a Chrome extension, a hosted app or an offline app is.  Not sure how we're going to do it.
 
 

Not with F5, but you just right click on any window of your packaged app and you get the "Reload App" option, as long as you are in Developer mode (checkbox on top of chrome://extensions page). And if you set an ID to your window in chrome.app.window.create(), even the size and position will keep the same when reloading. Same for the DevTools/inspector window, if it was open when you reloaded.

Thanks for the tip.
 
You might have your reasons, but I prefer developing local instead of having to change files in a server. Last time I was in a plane, I could implement a simple app completely offline, which would be much harder using hosted apps.


I'm running off a local appengine development server. I've been experimenting with a crx-less hosted app (for which chrome.serial isn't available) and with packaged app in developer mode.
We're not planning on publishing our apps to the marketplace, a self-hosted solution on our appengine server is quite compelling. I've been reading on how to control self-updating for hosted apps, hopefully the same will apply to packaged apps.

Thank you very much :-)
Emanuele



 

Sungguk Lim

unread,
Nov 21, 2012, 5:55:35 AM11/21/12
to chromi...@chromium.org, Renato Mangini, Роман Осипов
Hi all

I already reported this issue, but there's no response yet.

it seems this issue has low priority.

Chrome.Serial API doesn't work in MS Windows. no matter what version is


2012년 11월 21일 수요일 오전 1시 0분 14초 UTC+9, Tony Wong 님의 말:

Renato Mangini

unread,
Nov 21, 2012, 5:19:56 PM11/21/12
to Emanuele Ziglioli, chromi...@chromium.org, Tony Wong, Роман Осипов

Hey, Emanuele,

Comments inline:

wrong. Hosted apps are like web apps but they can work offline. Plus, they can do more than a traditional web app, provided users grant them permissions. So the fact that hosted apps cannot access hardware is just a formality, am I wrong?

The packaged app is packaged (obviously :-))  in a signed crx and all its executable code is guaranteed to live inside that signed packaged.

The hosted app, on the other hand, usually has most of its code living in a remote server. Safety was one of the most important, if not the most, aspects we considered when designing the Chrome packaged apps programming model. For example, If the hosted app had the same APIs as a packaged app, even a well intentioned developer could be at risk if he hosts his hosted app in an unsafe hosting service. Not with packaged apps.


If 'packaged apps' fly, I'm planning to use them to replace our current java based GUIs (hopefully mobile platforms will be supported too eventually).
We need hardware support in order to access serial ports. And we need offline support for when our users in the field don't have access to the internet.
But I'd like to make their user experience from online to offline as seamless as possible. It'll be hard enough to explain what a Chrome extension, a hosted app or an offline app is.  Not sure how we're going to do it.

That's an excellent use case. I'm not sure why you will have to explain that to your users, though. Currently, because the platform is a developer preview, you need to launch packaged apps from a Chrome new tab page. In the near future, you will be able to launch it in a much more natural way.

We're not planning on publishing our apps to the marketplace, a self-hosted solution on our appengine server is quite compelling. I've been reading on how to control self-updating for hosted apps, hopefully the same will apply to packaged apps.

Do you want to publish it to selected users only, right? Are these users tied to a particular Google Apps domain, or it's just an arbitrary list? Packaged apps will self-update in a seamless way, but they must be published in CWS. Google Apps domains have some specificities, though.


Emanuele Ziglioli

unread,
Nov 22, 2012, 4:54:10 AM11/22/12
to chromi...@chromium.org, Emanuele Ziglioli, Tony Wong, Роман Осипов

Hi Renato

 

The packaged app is packaged (obviously :-))  in a signed crx and all its executable code is guaranteed to live inside that signed packaged.

The hosted app, on the other hand, usually has most of its code living in a remote server. Safety was one of the most important, if not the most, aspects we considered when designing the Chrome packaged apps programming model. For example, If the hosted app had the same APIs as a packaged app, even a well intentioned developer could be at risk if he hosts his hosted app in an unsafe hosting service. Not with packaged apps.

thanks for the explanation
 
But I'd like to make their user experience from online to offline as seamless as possible. It'll be hard enough to explain what a Chrome extension, a hosted app or an offline app is.  Not sure how we're going to do it.

That's an excellent use case. I'm not sure why you will have to explain that to your users, though. Currently, because the platform is a developer preview, you need to launch packaged apps from a Chrome new tab page. In the near future, you will be able to launch it in a much more natural way.

I was thinking: currently customers use our web site. When they need to work offline or for a access to hardware they will have to switch to a packaged app. That can be confusing, that switching back and forth. With Google Gears in the past that was meant to happen seamlessly, or that was the idea at least.

 

We're not planning on publishing our apps to the marketplace, a self-hosted solution on our appengine server is quite compelling. I've been reading on how to control self-updating for hosted apps, hopefully the same will apply to packaged apps.

Do you want to publish it to selected users only, right? Are these users tied to a particular Google Apps domain, or it's just an arbitrary list? Packaged apps will self-update in a seamless way, but they must be published in CWS. Google Apps domains have some specificities, though.

I thought one could specify a target server for self updating (at least with hosted apps).
Our app would only make sense for customers who need to operate the hardware that we make and sell (wildlife tracking devices).

So hopefully support for serial ports on Windows will be fixed soon ;-)

Emanuele




 

Renato Mangini

unread,
Nov 23, 2012, 8:48:51 AM11/23/12
to Emanuele Ziglioli, chromi...@chromium.org, Tony Wong, Роман Осипов
That's an excellent use case. I'm not sure why you will have to explain that to your users, though. Currently, because the platform is a developer preview, you need to launch packaged apps from a Chrome new tab page. In the near future, you will be able to launch it in a much more natural way.

I was thinking: currently customers use our web site. When they need to work offline or for a access to hardware they will have to switch to a packaged app. That can be confusing, that switching back and forth. 


Can't they just use the packaged app as the entry point to your app? If it is not feasible to convert all your site to the packaged apps programming model and CSP restrictions but you still want to use some features of packaged apps, as it seems to be your case, you can have your user initially go to the packaged app (a great user experience when in a flaky or non-existent connection). Then, if the user is online, an option would show your website inside a <webview> with the use cases that only exist in the web site.

If you are not familiar with the webview element, watch next week's Chrome Office Hours where I and Pete LePage will talk about it.

Emanuele Ziglioli

unread,
Nov 24, 2012, 5:21:37 AM11/24/12
to chromi...@chromium.org, Emanuele Ziglioli, Tony Wong, Роман Осипов
 

Can't they just use the packaged app as the entry point to your app? If it is not feasible to convert all your site to the packaged apps programming model and CSP restrictions but you still want to use some features of packaged apps, as it seems to be your case, you can have your user initially go to the packaged app (a great user experience when in a flaky or non-existent connection). Then, if the user is online, an option would show your website inside a <webview> with the use cases that only exist in the web site.


Thanks for the tips, we'll explore all those options 
 
If you are not familiar with the webview element, watch next week's Chrome Office Hours where I and Pete LePage will talk about it.

+1!

Ciao,
Emanuele

 

William Cooley

unread,
Nov 29, 2012, 8:30:40 PM11/29/12
to chromi...@chromium.org, Emanuele Ziglioli, Tony Wong, Роман Осипов
I am working on developing a Chrome app or extension that uses the serial API to communicate with a simple 20x4 serial LCD that is connected via USB.
The app would connect to a web service running on Google App engine using the Channel API (https://developers.google.com/appengine/docs/python/channel/overview).
The web service would send messages to the packaged app and this would then display the message on the serial LCD.
After reading this thread I get the impression that my packaged app can not simply use the existing Channel API code.
Could I get some pointers on how I could do this?

Sungguk Lim

unread,
Dec 4, 2012, 8:32:59 PM12/4/12
to chromi...@chromium.org, Emanuele Ziglioli, Tony Wong, Роман Осипов
Hi guys,
I am a guy who suffer from this issue, 
and I cannot wait any longer until Google fix this issue, 
So I fixed this issue by myself. and I'll upload my patch soon. 
please let me know if you need Chrome binary(fixed this issue).


2012년 11월 30일 금요일 오전 10시 30분 40초 UTC+9, William Cooley 님의 말:

Ben Wells

unread,
Dec 4, 2012, 8:45:45 PM12/4/12
to Sungguk Lim, chromi...@chromium.org, Emanuele Ziglioli, Tony Wong, Роман Осипов
Can you upload a CL so everyone benefits? Chromium is an open source project.

Sungguk Lim

unread,
Dec 12, 2012, 1:54:34 PM12/12/12
to chromi...@chromium.org, Sungguk Lim, Emanuele Ziglioli, Tony Wong, Роман Осипов, benw...@chromium.org
Dear all, my patch is accepted,
Now you can receive proper ports thru getPorts() function
You might want to download and run Chromium nightly build for windows  in here (http://download-chromium.appspot.com/

if anybody find another issue about Chrome.Serial API,  please let me know..   

2012년 12월 5일 수요일 오전 10시 45분 45초 UTC+9, Ben Wells 님의 말:

Stefan Roesch

unread,
Jul 3, 2013, 7:28:51 PM7/3/13
to chromi...@chromium.org, Sungguk Lim, Emanuele Ziglioli, Tony Wong, Роман Осипов, benw...@chromium.org
Has anyone successfully written a packaged app client that communicates with google appengine channels via the sockets api?

Joe Marini

unread,
Jul 4, 2013, 5:57:04 PM7/4/13
to Stefan Roesche, Роман Осипов, Emanuele Ziglioli, chromi...@chromium.org, benw...@chromium.org, Sungguk Lim, Tony Wong

I don't think AppEngine currently supports sockets.

--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.

To post to this group, send email to chromi...@chromium.org.

Paulo Kraeski

unread,
Oct 9, 2014, 7:33:03 AM10/9/14
to chromi...@chromium.org, wct...@gmail.com, roman...@gmail.com
Hi Tony,

It's 2014 now and I'm the same position, need to send data to a COM4 display from a EPOS system running on Chrome. I'm wondering if you've finally managed to make this work via chrome.serial API or using another solution?

I'm currently just doing some research on the whole thing but I'd appreciate if you could share your experience on how you've dealt with this issue. :)

Gamadril

unread,
Oct 9, 2014, 9:13:35 AM10/9/14
to chromi...@chromium.org, wct...@gmail.com, roman...@gmail.com
There were several changes of the serial API some time ago, so just try it out. I had no problems with it on OSX and Windows XP when writing a STM mcu flasher.
Here is some code that might be useful: https://github.com/Gamadril/stm-serial-flasher/blob/master/js/app/api/ChromeSerial.js. You can remove Stapes dependency, since the API is not using it's event system and works only with passed callbacks. requirejs can also be removed. jsdoc comments are in the Serial.js file https://github.com/Gamadril/stm-serial-flasher/blob/master/js/app/api/Serial.js

good luck

Reilly Grant

unread,
Oct 9, 2014, 1:25:42 PM10/9/14
to Paulo Kraeski, chromi...@chromium.org, wct...@gmail.com, roman...@gmail.com
Remember to check chrome.runtime.lastError != undefined in the callback for any extension API call. This object will contain a message string describing the error. Sometimes the error is not very informative, too many APIs return "Failed," but at least it will tell you whether Chrome believes it successfully sent the data or not.

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.

Isaac Sadaqah

unread,
Nov 21, 2014, 11:26:51 PM11/21/14
to chromi...@chromium.org
I also keep getting Failed to connect to the port. On Windows XP, Chrome 35. getDevices lists the port correctly on COM1. But I am not able to connect to it. Did anybody manage to connect to POS printer using serial API on Windows so far?

Sungguk Lim

unread,
Nov 21, 2014, 11:32:42 PM11/21/14
to chromi...@chromium.org
@Issac, Why don't you update your chrome first? There's no big change since last year. But it's good to update first.
I am a author of an Beagle Term(which is RS232 terminal). and serial.api is fine from Windows, Mac and Linux.


2014년 11월 22일 토요일 오후 1시 26분 51초 UTC+9, Isaac Sadaqah 님의 말:
Reply all
Reply to author
Forward
0 new messages