首 页文章中心下载中心图文中心访客留言安防论坛产品推荐繁體中文
设为首页
加入收藏
联系我们
您当前的位置:金辉安防同盟 -> 文章中心 -> 一卡通 -> 文章内容 退出登录 用户管理
栏目导航
· 弱电基础 · 视频监控
· 电子防盗 · 楼宇对讲
· 一卡通 · 电脑网络
· 智能系统 · 视频会议
· 综合布线 · 公共广播
· 电缆电线 · 工程设计
· 工程施工 · 工程维护
· 实用工具 · 企业管理
· 营销分析 · 精英人物
· 安防法规 · 交易平台
· 招聘求职 · 新闻频道
热门文章
· [组图] 学会使用万用表
· [图文] 汽车加油加气站设计...
· PICO2000常见问题解...
· 工程施工规范样本
· [图文] 监控系统结构图
· 晶体管手册
· 英文版的施工组织计...
· [组图] 监控系统施工线路图...
· 安全防范工程费用概...
· [推荐] 部分监控专用摄像机...
相关文章
ATMEL公司生产的AT45D041芯片的存储卡
作者:不详  来源:北京航天金卡有限公司  发布时间:2006-7-20 9:30:02  发布人:老斑鸠

减小字体 增大字体

  1函数约定:
本接口函数针对北京航天金卡有限公司开发的通用读卡器JK-100开发,不能使用于其它读写器。
  本接口函数的操作对象为ATMEL公司生产的芯片AT45D041的存储卡,如需操作其它种类、版本的IC卡,请与公司联系。
  本接口函数的所有函数中的参数类型为PBYTE(unsigned char *)的参数,其值为一字符串,该字符串中的每两个字节的字符,表示某个字符的扩展ASCII值(十六进制),或者双字节字符(如汉字)的机器内码值。如:
  s ‘303132333435’表示’012345’,其中’30’表示字符’0’的ASCII值0x30,依此类推。
  s ‘hello world!’如写入卡中,应转化为’68656C6C6F20776F726C6421’。
  s ‘你好,世界!’则为’C4E3BAC3ACCAC0BDE7A3A1’。
  转换函数后述。如要将数字直接写入卡中,如写入’12345678’,不经过转换,则存入卡中的为BCD码’12’,’34’,’56’,’78’。
  因此,提供给函数的字符串参数和从函数返回的字符串参数值的长度都是且必须是偶数。目的是为了使函数具有更广泛的应用范围。以开发工具PowerBuilder为例,对字符串的处理是将0x00作为结束符。但是,在应用中,不免会经常用到0x00作为字符串的字符之一的情况。
  本接口函数中写入和读出的字符串参数长度不能超过80 * 2 bytes(转换后)。
  在调用函数前,参数reply_str的变量必须申请相应大小的内存空间,如space(256)。
  本接口函数返回值:返回值=1为执行正确,返回=0为执行错误,返回-1为通讯错误,另有其它代码含义后述。

  2 阅读对象:
  程序员,熟悉WIN32位编程,熟悉WIN32 API编程,熟悉IC卡操作。

  3 函数使用说明:
  3.1 int open_comm(int comm_id):
  功能:打开串口
  参数:comm_id:串口号1~4。
  3.2 int close_comm(void):
  功能:关闭串口
  3.3 int ins_status(void):
  功能:测卡片到位;
  返回:1、有卡,0、无卡。
  3.4 int s_poweron(void):
  功能:卡片上电
  3.5 int s_poweroff(void):
  功能:卡片下电
  3.6 int des(PBYTE clear,PBYTE key,PBYTE cipher):
  功能: 对数据进行标准DES加密。
参数: clear:明文
  key:密钥
  cipher:密文。

  3.7 int inverse_des(PBYTE cipher,PBYTE key,PBYTE clear):
  功能: 对数据进行标准DES解密。
参数: cipher:密文
  key:密钥
  clear:明文。
  3.8 int buffer_write(int buffer_no,PBYTE address,PBYTE data_str):
  功能: 写缓冲区。
参数: buffer_no:缓冲区号。1/缓冲区1, 2/缓冲区2。
  Address:页内地址。2 bytes。‘0000’~‘0108’。
data_str:写入的数据。

  3.9 int buffer_read(int buffer_no,PBYTE address,int length,PBYTE reply_str):
  功能: 读缓冲区。
参数: buffer_no:缓冲区号。1/缓冲区1,2/缓冲区2。
  Address:页内地址。2 bytes。‘0000’~‘0108’。
  Length:数据长度。
  reply_str:读出的数据。

  3.10 int btom_write (int buffer_no,PBYTE address,PBYTE data_str):
  功能: 通过指定的缓冲区向主存储区某一地址写数据。
参数: buffer_no:缓冲区号。1/缓冲区1,2/缓冲区2。
  address:主存储区地址。3 bytes。‘000000’~~~。
  data_str:写入的数据。

  3.11 int btomnoerase(int buffer_no,PBYTE address):
  功能: 将指定缓冲区的全部数据写入主存储区某一页中,不擦除主存储区。
  参数: buffer_no:缓冲区号。1/缓冲区1,2/缓冲区2。
Address:页地址。2 bytes。‘0000’~~~。

3.11 int btomwitherase(int buffer_no,PBYTE address):
功能: 将指定缓冲区的全部数据写入主存储区某一页中,首先擦除主存储区。
参数: buffer_no:缓冲区号。1/缓冲区1,2/缓冲区2。
Address:页地址。2 bytes。‘0000’~~~。

3.12 int main_read(PBYTE address,int length,PBYTE reply_str):
功能: 从指定地址的主存储区中直接读取数据。
参数: address:主存储区地址。3 bytes。‘000000’~~~。
length:数据长度。
Reply_str:读出的数据。

3.13 int maintobuff_c(int buffer_no,PBYTE address):
功能: 主存储区某一页中的数据与指定的缓存器数据进行比较。
参数: buffer_no:缓冲区号。1/缓冲区1,2/缓冲区2。
address:页地址。2 bytes。‘0000’~~~。
返回:0/执行错误,1/数据一致,2/数据不一致

3.14 int maintobuff_t(int buffer_no,PBYTE address):
功能: 主存储区某一页中的数据传送到指定的缓存器中。
参数: buffer_no:缓冲区号。1/缓冲区1,2/缓冲区2。
address:页地址。2 bytes。‘0000’~~~。

4 函数调用声明:
4.1 For Powbuilder5.0/6.0:
FUNCTION int open_comm(integer pord_id) LIBRARY 'AGM4M11.DLL';
FUNCTION int close_comm() LIBRARY 'AGM4M11.DLL';
FUNCTION int ins_status() LIBRARY 'AGM4M11.DLL';
FUNCTION int s_poweron() LIBRARY 'AGM4M11.DLL';
FUNCTION int s_poweroff() LIBRARY 'AGM4M11.DLL';
FUNCTION string hextoascii(string hex_str,integer length,ref string reply_str) LIBRARY 'AGM4M11.DLL';
FUNCTION string asciitohex(string asc_str,ref string reply_str) LIBRARY 'AGM4M11.DLL';
FUNCTION int buffer_write(integer buffer_no,string address,string data_str) LIBRARY 'AGM4M11.DLL';
FUNCTION int buffer_read(integer buffer_no,string address,integer length,ref string reply_str) LIBRARY 'AGM4M11.DLL';
FUNCTION int btom_write(integer buffer_no,string address,string data_str) LIBRARY 'AGM4M11.DLL';
FUNCTION int btomnoerase(integer buffer_no,string address) LIBRARY 'AGM4M11.DLL';
FUNCTION int btomwitherase(integer buffer_no,string address) LIBRARY 'AGM4M11.DLL';
FUNCTION int main_read(string address,integer length,ref string reply_str) LIBRARY 'AGM4M11.DLL';
FUNCTION int maintobuff_c(integer buffer_no,string address) LIBRARY 'AGM4M11.DLL';
FUNCTION int maintobuff_t(integer buffer_no,string address) LIBRARY 'AGM4M11.DLL';

4.2 For Visual Basic5.0/6.0
Public Declare Function open_comm Lib 'AGM4M11.DLL' (ByVal pord_id As Long) As Long
Public Declare Function close_comm Lib 'AGM4M11.DLL' () As Long
Public Declare Function ins_status Lib 'AGM4M11.DLL' () As Long
Public Declare Function s_poweron Lib 'AGM4M11.DLL' () As Long
Public Declare Function s_poweroff Lib 'AGM4M11.DLL' () As Long
Public Declare Function hextoascii Lib 'AGM4M11.DLL' (ByVal hex_str As String,ByVal length As Integer,ByVal reply_str As String) As String
Public Declare Function asciitohex Lib 'AGM4M11.DLL' (ByVal asc_str As String,ByVal reply_str As String) As String
Public Declare Function buffer_write Lib 'AGM4M11.DLL' (ByVal buffer_no As Integer,ByVal address As String,ByVal data_str As String) As Long
Public Declare Function buffer_read Lib 'AGM4M11.DLL' (ByVal buffer_no As Integer,ByVal address As String,ByVal length As Integer,ByVal reply_str As String) As Long
Public Declare Function btom_write Lib 'AGM4M11.DLL' (ByVal buffer_no As Integer,ByVal address As String,ByVal data_str As String) As Long
Public Declare Function btomnoerase Lib 'AGM4M11.DLL' (ByVal buffer_no As Integer,ByVal address As String) As Long
Public Declare Function btomwitherase Lib 'AGM4M11.DLL' (ByVal buffer_no As Integer,ByVal address As String) As Long
Public Declare Function main_read Lib 'AGM4M11.DLL' (ByVal address As String,ByVal length As Integer,ByVal reply_str As String) As Long
Public Declare Function maintobuff_c Lib 'AGM4M11.DLL' (ByVal buffer_no As Integer,ByVal address) As Long
Public Declare Function maintobuff_t Lib 'AGM4M11.DLL' (ByVal buffer_no As Integer,ByVal address) As Long
4.3 For Visual FoxPro5.0/6.0
declare integer open_comm in AGM4M11.DLL integer pord_id
declare integer close_comm in AGM4M11.DLL
declare integer ins_status in AGM4M11.DLL
declare integer s_poweron in AGM4M11.DLL
declare integer s_poweroff in AGM4M11.DLL
declare integer register_status in AGM4M11.DLL string reply_str
declare string hextoascii in AGM4M11.DLL string hex_str,integer length,string reply_str
declare string asciitohex in AGM4M11.DLL string asc_str,string reply_str
declare integer buffer_write in AGM4M11.DLL integer buffer_no,string address,string data_str
declare integer buffer_read in AGM4M11.DLL integer buffer_no,string address,integer length,string reply_str
declare integer btom_write in AGM4M11.DLL integer buffer_no,string address,string data_str
declare integer btomnoerase in AGM4M11.DLL integer buffer_no,string address
declare integer btomwitherase in AGM4M11.DLL integer buffer_no,string address
declare integer main_read in AGM4M11.DLL string address,integer length,string reply_str
declare integer maintobuff_c in AGM4M11.DLL integer buffer_no,string address
declare integer maintobuff_t in AGM4M11.DLL integer buffer_no,string address
declare integer auto_rewrite in AGM4M11.DLL integer buffer_no,string address

[] [返回上一页] [打 印] [收 藏]
上一篇文章:93c46读写程序
下一篇文章:智能卡内部文件系统
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 管理登录
Copyright © 2004~2008 Jhsafe.Com. All Rights Reserved .