聚丰项目 > 无人商店(提交)
利用RFID技术,识别商品标签,对商品进行购买授权,包括商品入库,商品信息修改,商品购买授权等步骤,实现最为简单的无人商店。
leo星
分享leo星
团队成员
梁星 硬件工程师
利用wifi模块进行联网,主读头RD915M、开发板RS232通讯分别与硬件控制板连接,把读到的数据传回开发板,开发板通过wifi把数据传给mysql服务器,服务器上对商品信息进行核对,结果下发到开发板,开发板控制硬件控制板进行开门,商品授权等动作。
#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#define PRESET_VALUE 0xFFFF
#define POLYNOMIAL 0x8408
unsigned int uiCrc16Cal(unsigned char const * pucY, unsigned char ucX)
{
unsigned char ucI,ucJ;
unsigned short int uiCrcValue = PRESET_VALUE;//short int 是16位长的用来保存CRC16返回值的
for(ucI = 0; ucI < ucX; ucI++)
{
uiCrcValue = uiCrcValue ^ *(pucY + ucI);//异或运算相同为0不同1
for(ucJ = 0; ucJ < 8; ucJ++)
{
if(uiCrcValue & 0x0001)
{
uiCrcValue = (uiCrcValue >> 1) ^ POLYNOMIAL;
}
else
{
uiCrcValue = (uiCrcValue >> 1);
}
}
}
return uiCrcValue;
}
int main(void)
{
u8 t;
unsigned short int crc16;
unsigned char lsb,msb;
//unsigned char buf_ReadEPC[5] = {0x04,0x00,0x01,0x00,0x00};//读取标签的EPC号 5
//unsigned char buf_readerget[]={0x04,0x00,0x21,0x00,0x00};//读取读写器信息 5
//unsigned char buf_getTID[]={0x06,0x00,0x01,0x00,0x06,0xFA,0x34};//查询TID 7
//unsigned char buf_readresver[13]={0x0C,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x3E,0xA4};//读取保留区数据 13
unsigned char buf_writeresver[21]={0x14,0x00,0x03,0x04,0x00,0x00,0x00,0x11,0x22,0x33,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9C,0xB5};//写入保留区数据 21
//unsigned char buf_WriteEPC[22]={0x15,0x00,0x04,0x06,0x00,0x00,0x00,0x00,0xE2,0x80,0x68,0x10,0x20,0x00,0x00,0x01,0x0D,0xD1,0x5E,0xF4,0x05,0x93};//写入EPC号 22
delay_init(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2
uart_init(9600); //串口初始化为9600
LED_Init(); //初始化与LED连接的硬件接口
crc16=uiCrc16Cal(buf_writeresver,19);
lsb=crc16 & 0x00ff;
msb=crc16 >> 8;
buf_writeresver[19] = lsb;
buf_writeresver[20] = msb;
while(1)
{
delay_ms(2000);
for(t=0;t<21;t++)
{
USART1->DR=buf_writeresver[t];
while((USART1->SR&0X40)==0);//等待发送结束
}
}
}
与读头RD915通讯需要进行CRC16校验
东西太多了,提供链接大家自己下载看吧 链接:http://pan.baidu.com/s/1micL6VA 密码:8ckh