Commit Graph

33 Commits

Author SHA1 Message Date
Martin Endler
8f2ba026cf Merge branch 'master' of git://github.com/santigimeno/node-pcsclite into master
# Conflicts:
#	package.json
2017-01-26 19:16:06 +01:00
Martin Endler
114f8372a1 added IOCTL_CCID_ESCAPE constant to reader object to support escape command 2016-11-17 23:52:27 +01:00
Santiago Gimeno
c83a39e10d src: fix deadlock in CardReader
Move the `uv_mutex_unlock` before the `uv_thread_join` as it could
perfectly lock with `CardReader::HandlerFunction` `uv_mutex_unlock`.
2016-09-23 13:13:58 +02:00
Santiago Gimeno
57a74befbe src: improve reader status reporting logic
- Avoid sending twice the same status.
- Discard SCARD_E_UNKNOWN_READER error as it's happening when the reader is
  disconnected and the disconnection will be detected by the pcsclite.cpp
  status thread.
2015-12-22 15:08:35 +01:00
Santiago Gimeno
0bcf3d8436 src: multiple thread synchronization improvements
- Allow up to 4 the number of times SCardCancel is called before waiting for
  the status `thread` to finish.
- Destroy the mutexes and conds only in the destructors.
- Check that the thread handles are still valid before calling join on them.
2015-12-22 14:59:03 +01:00
Florian Ramillien
06d31638e2 src: handle last event before exit status threads
- Avoid 2 consecutive calls to uv_async_send when exiting the cardreader.cpp
  check status thread.
- Fix mutex unlock location in cardreader.cpp check status thread.

PR-URL: https://github.com/santigimeno/node-pcsclite/pull/46
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2015-12-22 14:35:55 +01:00
Santiago Gimeno
4650a529f7 Revert "src: handle last event before exiting status threads"
This reverts commit 3800c39291.
2015-09-26 16:13:46 +02:00
Florian Ramillien
3800c39291 src: handle last event before exiting status threads
- Avoid 2 consecutive calls to uv_async_send when exiting the cardreader.cpp
  check status thread.
- Fix mutex unlock location in cardreader.cpp check status thread.

PR-URL: https://github.com/santigimeno/node-pcsclite/pull/46
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2015-09-26 14:46:45 +02:00
Santiago Gimeno
0a3eaafb2b src: fix reader disconnection logic
- A reader disconnection can't be detected by SCardGetStatusChange in the reader
  (cardreader.cpp) but by detecting that the reader doesn't appear in the list of
  readers retrieved in pcsclite.cpp.
- The list of readers is now stored in an object where the keys are the names of
  the readers. When a reader disconnection is detected, the reader is closed
  triggering the 'end' event. Then the reader is removed from the readers list.
2015-09-26 14:35:59 +02:00
Sebastian Arena
8f3309520d src: check dwEventState and not dwCurrentState
- As the new state is returned in the former.
2015-09-26 14:35:50 +02:00
Santiago Gimeno
32d0cb0289 src: fix cardreader thread synchronization
- Make sure while handling AsyncResult in HandleReaderStatusChange
  (JS thread), the AsyncResult is not overwritten in HandlerFunction
  (SCardGetStatusChange thread).
2015-09-26 14:32:02 +02:00
Santiago Gimeno
b373413669 src: fix double free crashes
- After upgrading to nan2 the buffers returned in some of the functions were
  being released because of Nan:NewBuffer. See:
  https://github.com/nodejs/nan/blob/master/doc/buffers.md#api_nan_new_buffer
2015-09-01 14:47:23 +02:00
Florian Ramillien
806a6b397c src: set pioRecvPci in SCardTransmit to NULL
- It fixes an error on SCardTransmit for windows: RPC_X_BAD_STUB_DATA / 0x06F7
  and does not affect other platforms.

PR-URL: https://github.com/santigimeno/node-pcsclite/pull/38
Reviewed-By: Ludovic Rousseau <ludovic.rousseau+github@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2015-09-01 14:32:47 +02:00
Santiago Gimeno
37b557fe56 src: upgrade to nan@2.x.x
- To support nodejs/iojs@3.x.x
2015-08-12 12:07:51 +02:00
Santiago Gimeno
0c5e07e0e5 src: migrate pthreads to uv_threads
- So it can be compatible in every platform supported by libuv.
- Use attached threads instead of detached.
- Remove all CardReader 'status' listeners before emitting the
  'end' event.
2015-05-27 16:09:29 +02:00
Santiago Gimeno
da61bae08a src: add SCARD_EJECT_CARD definition
- And remove duplicated SCARD_STATE_CHANGED definition.
2015-05-27 16:08:52 +02:00
Santiago Gimeno
86083a3ad0 src: LONG should be converted to v8::Number 2015-01-16 16:21:38 +01:00
Santiago Gimeno
f85250beb0 src: add error_msg to create pretty pcsc errors 2014-09-23 18:31:58 +02:00
Santiago Gimeno
2909f5e127 src: return after throwing an exception 2014-09-23 11:32:36 +02:00
Santiago Gimeno
2693556591 src: fix linux error and a warning 2014-09-11 16:49:22 +02:00
Santiago Gimeno
44a89dbbf6 src: fix OS X compilation issues 2014-09-11 07:32:20 -07:00
Santiago Gimeno
3c8b2c9f4b src: add disposition parameter to disconnect 2014-08-06 12:06:17 +02:00
Santiago Gimeno
26faed6dec src: refactor to use nan
- Now it supports latest 0.8.x, 0.10.x and 0.11.x
2014-08-05 10:10:00 +02:00
Santiago Gimeno
c6faeb3db3 src: remove unused variable 2014-07-29 12:18:38 +02:00
Santiago Gimeno
279bc112ce src: improve SCardConnect interface
- We can optionally pass the share_mode and preferred_protocol options. They are
  optional to keep backwards compatibility.
- Update README
- Define constants in C++ land.
2014-07-29 12:18:20 +02:00
Santiago Gimeno
cd01cd4788 src: remove fprintf's 2014-07-28 13:36:02 +02:00
Santiago Gimeno
c3d947860c Implement SCardControl 2014-07-28 11:49:35 +02:00
Santiago Gimeno
3cb970a04b Use the protocol parameter in CardReader.transmit
- We were simply hard-coding the T=0 protocol.
2013-10-16 17:03:18 +02:00
Santiago Gimeno
040f91c7b9 Change SCARD_READERSTATE initialization
- To remove some compiler warnings
2013-10-15 17:31:01 +02:00
Santiago Gimeno
194351d13d Add support for node v0.10.x
- It fixes issue #4.
2013-10-15 17:30:20 +02:00
Santiago Gimeno
1844bf1f3a Initialize SCARD_READERSTATE
- Not doing so was leading to random memory corruption errors.
2013-08-08 13:45:05 +02:00
Santiago Gimeno
3f2a1b5e4e CardReader status event should return the ATR
- Of the inserted card.
- Refactoring of the code that creates a Buffer instance into a
  separate function.
- Update the example and README
- It fixes bug #2
2013-07-05 17:25:18 +02:00
Santiago Gimeno
b40f9a2f88 Initial Implementation 2013-06-20 16:37:28 +02:00