Bug 233045 - devel/libnfc: Fix (enable) pn532 module use over UART
Summary: devel/libnfc: Fix (enable) pn532 module use over UART
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Romain Tartière
URL:
Keywords: easy
Depends on:
Blocks:
 
Reported: 2018-11-06 22:10 UTC by Alexander Sieg
Modified: 2019-02-22 02:14 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (romain)
koobs: merge-quarterly?


Attachments
patch file for the Port (369 bytes, patch)
2018-11-06 22:10 UTC, Alexander Sieg
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Sieg 2018-11-06 22:10:25 UTC
Created attachment 199030 [details]
patch file for the Port

Adding this compiler flags is necessary so that the pn532 module can be use over uart. With out this patch this is not possible as the necessary define for the serial baud rate is hidden in sys/_termios.h behind the __BSD_VISIBLE flag.
Comment 1 Romain Tartière freebsd_committer 2019-02-21 21:44:41 UTC
Every once a while, I come back to this issue, wonder how this should be done by the autotools, and get lots in the libnfc code.

After another attempt today, I can't see the problem this patch is supposed to fix.

configure reports:

Selected drivers:
   acr122_pcsc...... no
   acr122_usb....... yes
   acr122s.......... yes
   arygon........... yes
   pn53x_usb........ yes
   pn532_uart....... yes  <-------- What you are trying to fix
   pn532_spi.......  no
   pn532_i2c........ no


And the build complete successfully (this is on FreeBSD 12.0).

Can you please provide more details about your setup, what you are trying to do, how you do it and what is the result?
Comment 2 Alexander Sieg 2019-02-21 23:06:50 UTC
The problem is the the pn532 module is try to communicate at 115200 baud [1] but this baud is hide behind the __BSD_VISIBLE flag in sys/_termios.h. The problem dose not become visible at compile time but only at runtime as the library is not able to connect to any pn532 module using UART, because it can't set the necessary baud on the serial interface. 

Here[2] the preprocessor flag is used to enable the necessary speed for communication with the module, but this flag is not set unless the __BSD_VISIBLE is set as it is defined in sys/_termios.h in line 208 [3]


[1] https://github.com/nfc-tools/libnfc/blob/master/libnfc/drivers/pn532_uart.c#L51
[2]https://github.com/nfc-tools/libnfc/blob/master/libnfc/buses/uart.c#L211
[3]https://svnweb.freebsd.org/base/stable/12/sys/sys/_termios.h?revision=339434&view=markup#l208
Comment 3 Romain Tartière freebsd_committer 2019-02-22 02:11:40 UTC
Okay, I though it was a build failure.  I guess the autotools should still do something magic that adds -D__BSD_VISIBLE somewhere, but this fix is straightforward.

I should have asked for details sooner, I was looking in the wrong direction.

Thank you for the details, I will commit your patch soon.
Comment 4 commit-hook freebsd_committer 2019-02-22 02:14:04 UTC
A commit references this bug:

Author: romain
Date: Fri Feb 22 02:13:45 UTC 2019
New revision: 493539
URL: https://svnweb.freebsd.org/changeset/ports/493539

Log:
  Fix pn532 module use over UART

  Some macros are only visible if __BSD_VISIBLE is defined.  When absent, libnfc
  compiles successfuly, but some features are broken.  This fix PN532 over UART.

  PR:		233045
  Reported by:	alex@xanderio.de

Changes:
  head/devel/libnfc/Makefile
Comment 5 Romain Tartière freebsd_committer 2019-02-22 02:14:39 UTC
Committed, thanks!

Sorry for the delay