{"action":"created","issue":{"url":"https://api.github.com/repos/nfc-tools/libnfc/issues/305","labels_url":"https://api.github.com/repos/nfc-tools/libnfc/issues/305/labels{/name}","comments_url":"https://api.github.com/repos/nfc-tools/libnfc/issues/305/comments","events_url":"https://api.github.com/repos/nfc-tools/libnfc/issues/305/events","html_url":"https://github.com/nfc-tools/libnfc/issues/305","id":98342897,"number":305,"title":"nfc-emulate-tag example - SIGINT hang up on windows","user":{"login":"thnimacio","id":13585134,"avatar_url":"https://avatars.githubusercontent.com/u/13585134?v=3","gravatar_id":"","url":"https://api.github.com/users/thnimacio","html_url":"https://github.com/thnimacio","followers_url":"https://api.github.com/users/thnimacio/followers","following_url":"https://api.github.com/users/thnimacio/following{/other_user}","gists_url":"https://api.github.com/users/thnimacio/gists{/gist_id}","starred_url":"https://api.github.com/users/thnimacio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thnimacio/subscriptions","organizations_url":"https://api.github.com/users/thnimacio/orgs","repos_url":"https://api.github.com/users/thnimacio/repos","events_url":"https://api.github.com/users/thnimacio/events{/privacy}","received_events_url":"https://api.github.com/users/thnimacio/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-31T08:35:08Z","updated_at":"2015-08-18T07:10:43Z","closed_at":null,"body":"Abording the emulation of an nfc tag (via STR+C) leads to the SIGINT cennected function \"intr_hdlr\", calling \"nfc_abort_command\", \"nfc_close\" and \"nfc_exit\".\r\nThe\" nfc_close\" command leads to a windows API call \"PurgeComm\" (in /contrib/win32/libnfc/buses/uart.c -> \"uart_flush_input\") that does not return.\r\n\r\nTested with libnfc 1.7.0 rc6, rc7 and libnfc master (pulled last week) on windows XP and windows 7, all giving the same issue."},"comment":{"url":"https://api.github.com/repos/nfc-tools/libnfc/issues/comments/132097468","html_url":"https://github.com/nfc-tools/libnfc/issues/305#issuecomment-132097468","issue_url":"https://api.github.com/repos/nfc-tools/libnfc/issues/305","id":132097468,"user":{"login":"thnimacio","id":13585134,"avatar_url":"https://avatars.githubusercontent.com/u/13585134?v=3","gravatar_id":"","url":"https://api.github.com/users/thnimacio","html_url":"https://github.com/thnimacio","followers_url":"https://api.github.com/users/thnimacio/followers","following_url":"https://api.github.com/users/thnimacio/following{/other_user}","gists_url":"https://api.github.com/users/thnimacio/gists{/gist_id}","starred_url":"https://api.github.com/users/thnimacio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thnimacio/subscriptions","organizations_url":"https://api.github.com/users/thnimacio/orgs","repos_url":"https://api.github.com/users/thnimacio/repos","events_url":"https://api.github.com/users/thnimacio/events{/privacy}","received_events_url":"https://api.github.com/users/thnimacio/received_events","type":"User","site_admin":false},"created_at":"2015-08-18T07:10:43Z","updated_at":"2015-08-18T07:10:43Z","body":"The example \"nfc-emulate-tag.exe\" is calling the function \"nfc_target_init\" to start the tag emulation. Using a PN532 NFC-Shield connected via uart/serial the driver calls the windows API function \"ReadFile\" with zero timeout (in \"uart.c\", \"uart_receive\"-function). I am able to scan the tag with a smartphone. But if I want to abort the tag emulation pressing CTR+C (SIGINT) the program hangs up while calling \"nfc_close\". It hangs up because the windows API call \"PurgeComm\" (called in \"uart_flush_input\"-function) does not return. I'm not familar with windows API programming but maybe calling PurgeComm while another ReadFile function is blocking the same handle is not allowed.\r\n\r\nI created a post in the developer forum where I tested a simple but ugly workaround before creating this issue that can be found here:\r\nhttp://forums.nfc-tools.org/topic/1410/pn532-uart-hang-up-on-windows-using-nfcemulatetag-example/"}}