Skip to content

Commit

Permalink
Remove NxpRdLib source and pull it directly from NXP during the build…
Browse files Browse the repository at this point in the history
… process.
  • Loading branch information
svvitale committed Mar 3, 2015
1 parent 7e905c0 commit 2dce64f
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Mifare.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ int Mifare_init(Mifare *self, PyObject *args, PyObject *kwds) {
phStatus_t status;

/* Initialize the Reader BAL (Bus Abstraction Layer) component */
status = phbalReg_R_Pi_spi_Init(&self->data.balReader, sizeof(phbalReg_R_Pi_spi_DataParams_t));
status = phbalReg_RpiSpi_Init(&self->data.balReader, sizeof(phbalReg_RpiSpi_DataParams_t));
if (PH_ERR_SUCCESS != status)
{
PyErr_Format(InitError, "SPI Init failed: %04x", status);
Expand Down
6 changes: 3 additions & 3 deletions Mifare.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
/* Status code definitions */
#include <ph_Status.h>

#include <phbalReg_RpiSpi.h>

/* Reader Library Headers */
/* Generic ISO14443-3A Component of
* Reader Library Framework */
Expand All @@ -55,16 +57,14 @@
* Ultralight-C cards. */
#include <phKeyStore.h>

#include <phpalSli15693.h>
#include <phpalSli15693_Sw.h>
#include <phpalFelica.h>
#include <phpalI14443p3b.h>

#define UID_BUFFER_SIZE 20
#define UID_ASCII_BUFFER_SIZE ((UID_BUFFER_SIZE * 2) + 1)

typedef struct {
phbalReg_R_Pi_spi_DataParams_t balReader;
phbalReg_RpiSpi_DataParams_t balReader;
phhalHw_Rc523_DataParams_t hal;
phpalI14443p4_Sw_DataParams_t I14443p4;
phpalMifare_Sw_DataParams_t palMifare;
Expand Down
80 changes: 80 additions & 0 deletions get_nxpRdLib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

blue='\033[0;34m'
NC='\033[0m' # No Color

prereq() {
echo -e "[${blue}Installing prerequisites${NC}]"
sudo apt-get update
sudo apt-get -y install libglib2.0 glib-networking-services libreadline6-dev libglib2.0-dev glib-networking-services python2.7-dev build-essential autoconf libtool
}

neardal() {
echo -e "[${blue}Downloading NeardAL${NC}]"
curl -L https://github.com/connectivity/neardal/archive/0.14.tar.gz | tar --overwrite -xz
cd neardal-0.14

echo -e "[${blue}Running autogen.sh${NC}]"
./autogen.sh

echo -e "[${blue}Configuring NeardAL${NC}]"
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var

echo -e "[${blue}Building NeardAL${NC}]"
make

echo -e "[${blue}Installing NeardAL${NC}]"
sudo make install

cd ..
}

wiringpi() {
echo -e "[${blue}Downloading wiringPi${NC}]"
git clone git://git.drogon.net/wiringPi
git reset --hard 72b2af231be337d45a557ce6ca3ed1eeb6675ffd

echo -e "[${blue}Building and Installing wiringPi${NC}]"
cd wiringPi
./build

echo -e "[${blue}Running ldconfig${NC}]"
sudo ldconfig

cd ..
}

nxp() {
echo -e "[${blue}Downloading NXP Reader Library${NC}]"
wget http://www.nxp.com/redirect/explore-nfc-dev_latest -O nxp.zip
unzip -o nxp.zip
tar --overwrite -xzf neard-explorenfc_0.1.orig.tar.gz
cd neard-explorenfc-0.1

export WIRINGPI_CFLAGS=-I/usr/local/include
export WIRINGPI_LIBS=-L/usr/local/lib\ -lwiringPi

echo -e "[${blue}Running bootstrap${NC}]"
./bootstrap

echo -e "[${blue}Configuring NXP Reader Library${NC}]"
./configure --prefix=/usr --sysconfdir=/etc

echo -e "[${blue}Building NXP Reader Library${NC}]"
cd nxprdlib
make
}

all() {
prereq
neardal
wiringpi
nxp
}

if [[ $# -eq 0 ]]; then
all
else
$@
fi

17 changes: 4 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,20 @@

class build_nxppy(build):
def run(self):

startingDir = os.getcwd()

os.chdir( os.path.join('NxpRdLib_PublicRelease', 'build') )

def compile():
call( r"sed -i 's/^blacklist spi-bcm2708/#&/' /etc/modprobe.d/raspi-blacklist.conf", shell=True )
call( 'modprobe spi-bcm2708', shell=True )
call( 'cmake .', shell=True )
call( 'make', shell=True )
call( './get_nxpRdLib.sh', shell=True )

self.execute(compile, [], 'compiling NxpRdLib')

os.chdir( startingDir )

# Run the rest of the build
build.run(self)

nxppy = Extension('nxppy',
sources = ['Mifare.c', 'nxppy.c'],
include_dirs = ['NxpRdLib_PublicRelease/types', 'NxpRdLib_PublicRelease/intfs', 'NxpRdLib_PublicRelease/comps/phpalSli15693/src/Sw'],
include_dirs = ['neard-explorenfc-0.1/nxprdlib/types',
'neard-explorenfc-0.1/nxprdlib/intfs'],
extra_compile_args=['-O1'],
extra_link_args=['NxpRdLib_PublicRelease/build/libnxprd.a']
extra_link_args=['neard-explorenfc-0.1/nxprdlib/libnxprdlib.a', '-lwiringPi']
)

short_description = 'A python extension for interfacing with the NXP PN512 NFC Reader. Targeted specifically for Raspberry Pi and the EXPLORE-NFC module'
Expand Down

0 comments on commit 2dce64f

Please sign in to comment.