googlearchive / chrome-nfc

Chrome App NFC Library
Other
213 stars 69 forks source link

Mac Issues #6

Open normanb opened 10 years ago

normanb commented 10 years ago

It seems that Chrome can find the NFC device on a Mac, but then it dies.

14:57:22.981 Enumerated 1 devices chrome-nfc.js:27 Array[1] 0: Object device: 1 productId: 8704 vendorId: 1839 proto: Object length: 1 proto: Array[0] : : chrome-nfc.js:27 Uncaught Error: Invalid value for argument 1. Property 'handle': Property is required, Property 'device': Unexpected property. extensions::schemaUtils:34 NFC.device.open() = 1 chrome-nfc.js:21 Uncaught TypeError: Cannot read property '0' of null

Any ideas?

beaufortfrancois commented 10 years ago

Can you try this in a terminal and let me know if it works for you?

sudo chmod -x /usr/sbin/pcscd
sudo pkill pcscd
normanb commented 10 years ago

Hi, that has just killed my connectivity to the NFC device! Any ideas? I would like to get this working if possible.

Thanks.

On Mon, Mar 17, 2014 at 1:59 AM, François Beaufort <notifications@github.com

wrote:

Can you try this in a terminal and let me know if it works for you?

sudo chmod -x /usr/sbin/pcscd sudo pkill pcscd

Reply to this email directly or view it on GitHubhttps://github.com/GoogleChrome/chrome-nfc/issues/6#issuecomment-37791736 .

normanb commented 10 years ago

I have restart pcscd manually

pcscd --foreground --debug --apdu

I am seeing this in the debug.

/SourceCache/SmartCardServices_Executables/SmartCardServices-55105/src/PCSC/readerfactory.c:260:RFAddReader() RFAddReader: ACS ACR122U init failed: -2146435067

which seems to be because pcscd starts itself when the device is connected.

alexvanboxel commented 10 years ago

Hi norman,

could you define "Killed my connectivity to the NFC device"?

I'm asking you this because what Francois suggested was killing the PC/SC demon. In general this demon monopolises all control of smartcard and NFC readers. By killing the daemon all SC/NFC readers are left to itself and are free to be consumed by raw USB API's, like the chrome USB lib.

So if you mean it killed NFC connectivity outside of Chrome, thats ok. You can't do both at the same time. Or you use PC/SC or you use Chrome USB (but not both at the same time!)

If you want to stop experimenting with the Chrome USB and need to re-enable pcscd, just do

sudo chmod +x /usr/sbin/pcscd

and restart your Mac.

normanb commented 10 years ago

it stopped the device working, when I plugged it in the red light on the device didn't come in when I plugged it in.

On Mon, Mar 17, 2014 at 11:57 AM, Alex Van Boxel notifications@github.comwrote:

Hi norman,

could you define "Killed my connectivity to the NFC device"?

I'm asking you this because what Francois suggested was killing the PC/SC demon. In general this demon monopolises all control of smartcard and NFC readers. By killing the daemon all SC/NFC readers are left to itself and are free to be consumed by raw USB API's, like the chrome USB lib.

So if you mean it killed NFC connectivity outside of Chrome, thats ok. You can't do both at the same time.

Reply to this email directly or view it on GitHubhttps://github.com/GoogleChrome/chrome-nfc/issues/6#issuecomment-37848457 .

alexvanboxel commented 10 years ago

Hi norman,

this is normal, the red light came on because the PC/SC daemon took over the reader.

Now concerning the Mac. I've checked out the library and it doesn't seem to work for me either. I'll try to look at it tomorrow and see if I can get it running on my Mac.

beaufortfrancois commented 10 years ago

@yjlou Do you have any hint on what's happening there?

getDevices callback returns null even after killing the pcscd Mac daemon.

yjlou commented 10 years ago

Hi Norman,

I don't have a Mac on hand. Is there any kernel module using the NFC reader? You could run "lsmod" and list the output to us. If you see something like "nfc" or "pn532", try to "sudo rmmod nfc" and "sudo rmmod pn532" to release the device. If this works, you may want to change your system configuration to remove the PN532 kernel module.

beaufortfrancois commented 10 years ago

Sadly lsmod doesn't exist on Mac OS. The equivalent seems to be kextstat but when I grep it I don't find anything related to "nfc" or "pn532". The closest I get is com.apple.driver.AppleUSBCardReader. Not sure it helps...

alexvanboxel commented 10 years ago

Guys, I've been looking at the issue and I wonder why it even works on ChromeOS... the reason it doesn't work is the the devices returned by:

https://developer.chrome.com/apps/usb#method-getDevices

is of type Device

But the method:

https://developer.chrome.com/apps/usb#method-claimInterface

expects a ConnectionHandle, this handler is returned by

https://developer.chrome.com/apps/usb#method-findDevices

So replacing the getDevices by findDevices in the code makes it work.

The big question here is, why does it work on ChromeOS?

beaufortfrancois commented 10 years ago

Thank you @alexvanboxel! Nice catch!

I've submitted a PR for that at #8 that @yjlou can approve it. It basically reverts my change of renaming findDevices to getDevices

normanb commented 10 years ago

great, I will test this tomorrow and report back. Thanks for the help.

On Thu, Mar 20, 2014 at 3:02 AM, François Beaufort <notifications@github.com

wrote:

Thank you @alexvanboxel https://github.com/alexvanboxel! Nice catch!

I've submitted a PR for that at #8https://github.com/GoogleChrome/chrome-nfc/pull/8that @yjlou https://github.com/yjlou can approve it. It basically reverts my change of renaming findDevices to getDevices

Reply to this email directly or view it on GitHubhttps://github.com/GoogleChrome/chrome-nfc/issues/6#issuecomment-38146216 .

normanb commented 10 years ago

I tested it on a mac and I get

14:48:20.156 Enumerated 1 devices chrome-nfc.js:27 Array[1] chrome-nfc.js:27 14:48:20.163 claimed chrome-nfc.js:27 Object chrome-nfc.js:28 14:48:20.167 tiny reply! chrome-nfc.js:66 Object chrome-nfc.js:66 0 devices remaining chrome-nfc.js:25 14:48:20.172 released chrome-nfc.js:25 14:48:20.173 closed chrome-nfc.js:25 NFC.device.open() = 1 chrome-nfc.js:21 Uncaught TypeError: Cannot read property 'productId' of undefined

I will look into this, this seems like something I can solve :)

normanb commented 10 years ago

it looks like chrome is finding my device, however this is not being passed back to find devices. I can dig into it a little more.

16:49:45.960 Enumerated 1 devices chrome-nfc.js:27chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js Array[1] chrome-nfc.js:27chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js 16:49:45.966 claimed chrome-nfc.js:27chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js Object

  1. handle: 15
  2. productId: 8704
  3. vendorId: 1839
  4. proto: Object

chrome-nfc.js:28chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js 16:49:45.969 tiny reply! chrome-nfc.js:66chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js Object chrome-nfc.js:66chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js 0 devices remaining chrome-nfc.js:25chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js 16:49:45.973 released chrome-nfc.js:25chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js 16:49:45.974 closed chrome-nfc.js:25chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js NFC.device.open() = 1 chrome-nfc.js:21chrome-extension://bjikgcclhgdgkpgjdhlmpenlafigfemp/chrome-nfc.js Uncaught TypeError: Cannot read property 'productId' of undefined

On Thu, Mar 20, 2014 at 11:25 AM, Norman Barker norman@cloudant.com wrote:

great, I will test this tomorrow and report back. Thanks for the help.

On Thu, Mar 20, 2014 at 3:02 AM, François Beaufort < notifications@github.com> wrote:

Thank you @alexvanboxel https://github.com/alexvanboxel! Nice catch!

I've submitted a PR for that at #8https://github.com/GoogleChrome/chrome-nfc/pull/8that @yjlou https://github.com/yjlou can approve it. It basically reverts my change of renaming findDevices to getDevices

Reply to this email directly or view it on GitHubhttps://github.com/GoogleChrome/chrome-nfc/issues/6#issuecomment-38146216 .

beaufortfrancois commented 10 years ago

I still had to run this below to make it work by the way.

sudo chmod -x /usr/sbin/pcscd
sudo pkill pcscd

If you don't execute this, you have the reader detected but you're not able to read/write.

yjlou commented 10 years ago

Just like Francois said, this looks like chrome.usb.claimInterface() failed. Please check if the dev permission is proper.

And, thanks for the good catch. I should have caught that, but not. Thanks.

On Mon, Mar 24, 2014 at 1:56 AM, François Beaufort <notifications@github.com

wrote:

I still had to run this below to make it work by the way.

sudo chmod -x /usr/sbin/pcscd sudo pkill pcscd

If you don't execute this, you have the reader detected but you're not able to read/write.

Reply to this email directly or view it on GitHubhttps://github.com/GoogleChrome/chrome-nfc/issues/6#issuecomment-38422436 .

normanb commented 10 years ago

what do you mean by dev permission is proper?

yjlou commented 10 years ago

sorry. device permission. either the udev rules or a program is using that.

On Mon, Mar 24, 2014 at 8:46 PM, normanb notifications@github.com wrote:

what do you mean by dev permission is proper?

Reply to this email directly or view it on GitHubhttps://github.com/GoogleChrome/chrome-nfc/issues/6#issuecomment-38528242 .

Zertz commented 10 years ago

@normanb did you ever figure out the fix to your issue? I'm running into exactly the same problem.

normanb commented 10 years ago

HI,

no it never worked for me, I still have an NFC Reader/Writer so I am interested.

Norman

From: Zertz notifications@github.com To: GoogleChrome/chrome-nfc chrome-nfc@noreply.github.com, Cc: normanb norman@cloudant.com Date: 05/13/2014 08:17 PM Subject: Re: [chrome-nfc] Mac Issues (#6)

@normanb did you ever figure out the fix to your issue? I'm running into exactly the same problem.

— Reply to this email directly or view it on GitHub.

Zertz commented 10 years ago

@normanb This definitely isn't an issue with our code, but rather the OS is taking over control of the reader, which stops Chrome from being able to access it. I didn't investigate much on the Mac, but I managed to make some progress on Windows (8.1, all the latest updates). The basic idea is that the red light must not be on when launching the Chrome app.

I managed to write a tag, but having issues reading it back. The library thinks my tags are Mifare Ultralight when they're actually NTAG203.

I'll keep you posted.

rafaelcaceres commented 9 years ago

sudo chmod -x /usr/sbin/pcscd sudo pkill pcscd

This stop working after update to yosemite. Any ideas?

jethroguce commented 9 years ago

I have an ACR122 Device but I'm getting errors, I am running OS X 10.10.2 screen shot 2015-03-26 at 9 39 43 pm

celevra commented 9 years ago

under yosemite, try to execute

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.ifdreader.plist
harryhow commented 8 years ago

I have the same issue with @jethroguce , thanks for @celevra solution, It works for me!! yay!

screen shot 2016-03-09 at 4 58 04 pm