rfid php sdk,RFID用户id到PHP

这是我的python程序,它读取RFID的用户ID,如何将其连接到php程序,以便将用户ID保存在变量$user中。我是一个要使用我的用户id访问数据库的单个用户id

我也用树莓皮3b# Requires Adafruit_Python_PN532

import binascii

import socket

import time

import signal

import sys

import Adafruit_PN532 as PN532

# PN532 configuration for a Raspberry Pi GPIO:

# GPIO 18, pin 12

CS = 18

# GPIO 23, pin 16

MOSI = 23

# GPIO 24, pin 18

MISO = 24

# GPIO 25, pin 22

SCLK = 25

# Configure the key to use for writing to the MiFare card. You probably

#don't

# need to change this from the default below unless you know your card

#has a

# different key associated with it.

CARD_KEY = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]

# Number of seconds to delay after reading data.

DELAY = 5

# Prefix, aka header from the card

HEADER = b'BG'

def close(signal, frame):

sys.exit(0)

signal.signal(signal.SIGINT, close)

# Create and initialize an instance of the PN532 class

pn532 = PN532.PN532(cs=CS, sclk=SCLK, mosi=MOSI, miso=MISO)

pn532.begin()

pn532.SAM_configuration()

print('PN532 NFC RFID 13.56MHz Card Reader')

while True:

# Wait for a card to be available

uid = pn532.read_passive_target()

# Try again if no card found

if uid is None:

continue

# Found a card, now try to read block 4 to detect the block type

print('')

print('Card UID 0x{0}'.format(binascii.hexlify(uid)))

# Authenticate and read block 4

if not pn532.mifare_classic_authenticate_block(uid, 4,

PN532.MIFARE_CMD_AUTH_B, CARD_KEY):

print('Failed to authenticate with card!')

continue

data = pn532.mifare_classic_read_block(4)

if data is None:

print('Failed to read data from card!')

continue

# Check the header

if data[0:2] != HEADER:

print('Card is not written with proper block data!')

continue

# Parse out the block type and subtype

print('User Id: {0}'.format(int(data[2:8].decode("utf-8"), 16)))

time.sleep(DELAY);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
RFID 标签 读写操作 DLL SDK 开发指南 V3.5 SDK开发指南 本SDK 包是公司为方便用户开发应用程序而开发的软件开发包。 SDK 以动态链接库文件 形式提供给用户使用。 用户使用本公司系列读写器进行用户应用软件开发时,根据本公司提供的SDK 开发包, 用户可以高效、正确地完成DRF 系列读写器应用软件的开发。 SDK 支持VC、 VB、 C#、 VB.NET、 C++ Builder 和Delphi 的开发。 使用函数注意事项: 1.对标签操作时(包括读标签,写标签),最好在主从模式下使用, 因为读写器 UART 通讯是半双工的,定 时模式下,此时读卡器定时读标签并上传数据,这时容易跟上位机发送的命令冲突而造成读取成功率下降, 如果要在定时模式下使用的话,最好先发送停读标签命令,再来操作。此时如若要恢复到定时模式,要发 送复位读头命令以再次进入到定时模式。 2.如果要读单标签, 使用我们的 DEMO 软件,到参数设置那里把读写器首先要设置到单标签模式。 3.如果要读多标签, 使用我们的 DEMO 软件,到参数设置那里把读写器首先要设置到多标签模式。 1、 OpenComm 函数原型: HANDLE OpenComm(int portNo); 功能说明: 打开串口。 返回值: 成功时返回串口句柄,失败时返回 INVALID_HANDLE_VALUE(-1) 参数: ●——portNo: 串口号 调用例程: HANDLE hCom = OpenComm(1); // 打开串口 1 if(hCom != INVALID_HANDLE_VALUE) AfxMessageBox(“打开串口成功!” ); else AfxMessageBox(“打开串口失败!” );

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值