ic卡和串口编程(100分)

  • 主题发起人 主题发起人 阿张
  • 开始时间 开始时间

阿张

Unregistered / Unconfirmed
GUEST, unregistred user!
大家好!先祝大家元旦快乐,马年鸿运。
我想知道:
[blue]有人对ST340读卡器熟悉吗?[/blue]我读写的时候,老是返回7004(即超时),
谁能指点一二。
本人对串口操作不熟悉,谁能告诉我哪里有你认为好用的,免费的,
资料详细,最好有DEMO的串口操作例子下载呢? (20分)
[red]##c:[/red]
typedef struct
{
char m_Comm_String[3];
char m_P3_String[10];
char m_Data_String[100];
}T_IC_CMD;
怎么转为DELPHI的RECORD呢? (20分)
---------------
##[brown]##[/brown]函数返回pchar型,但不知道多大,怎么给分配地址呢?(20分)
##[red]##[/red]谁有byte,pchar,类型操作的例子呢? (20分)
##[gold]##[/gold]哪位能给我2-10-16进制转换的函数哦,谁给我指导一下,ascall,bcd,等等的不同和
我的不懂呢? (20分)
越多越好哦,很感激帮助我进步的各位的(axding@163.net)
 
下载一个async32 ---- 一个串口控件,有DEMO程序;
可以搜索或到http://202.96.70.228/cakk/delphi/delphi.htm看看。
以下是C和DELPHI 的一些对应
unit Unit_dll;

interface
type

TZDP=record
hres:integer;
zres:integer;
direct:integer;
flag:char;
end;

CMD=record
PkgId:byte;
Address:array[0..1] of byte;
PkgLen:byte;
PkgCnt:array[0..127] of byte;
Jyh:array[0..1] of byte;
end;

SCMD=record
sPkgId:byte;
sAddress:array[0..1] of byte;
sPkgLen:byte;
sPkgCnt:array[0..127] of byte;
sJyh:array[0..1] of byte;
end;
TarrayImg=array[0..127,0..127] of byte;
ptArrayImg=^tarrayImg;

Tarray1=array[0..7]of byte;
ptarray1=^tarray1;

Tarray2=array of TZDP;
ptarray2=^tarray2;

Tarray3=array[0..127]of byte;
ptarray3=^tarray3;

Tarray4=array[0..255]of byte;
ptarray4=^tarray4;


PTbyte=^byte;
PTCmd=^cmd;
PTscmd=^scmd;
PTinteger=^integer;
PTboolean=^boolean;

function WriteBMP(name:string;img:tarrayimg): byte;cdecl;external 'io_dll.dll';
function InitCom(comport:integer) :boolean;cdecl;external 'io_dll.dll';
function ReleaseCom(comport:integer) :boolean;cdecl;external 'io_dll.dll';
function GetPkgByte(comport:integer;Tranbyte:PTbyte) :integer;cdecl;external 'io_dll.dll';
function SendPkgByte(comport:integer;Tranbyte:byte) :integer;cdecl;external 'io_dll.dll';
function GetPackage(comport:integer;cmd:PTCmd) :integer;cdecl;external 'io_dll.dll';
function SendPackage(comport:integer;SCMD:scmd) :integer;cdecl;external 'io_dll.dll';

function SensorReset(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorStatus(comport:integer;St0,St1:PTbyte) :integer;cdecl;external 'io_dll.dll';
function SensorEnroll(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorGenTzz(comport:integer) :integer;cdecl;external 'io_dll.dll';

function SensorDownMb(comport:integer; nummb:integer; mb:ptarray2;DampMbLock:integer) :integer;cdecl;external 'io_dll.dll';
function SensorDownTz(comport:integer;numtzd:integer; tzd:ptarray2;DampFinger:ptinteger) :integer;cdecl;external 'io_dll.dll';
function SensorUpMb(comport:integer;nummb:ptinteger;mb:ptarray2;DampMbLock:ptinteger) :integer;cdecl;external 'io_dll.dll';
function SensorUpTz(comport:integer;numtzd:ptinteger; tzd:ptarray2;DampFinger:ptinteger) :integer;cdecl;external 'io_dll.dll';

function SensorStore(comport:integer;address:integer) :integer;cdecl;external 'io_dll.dll';
function SensorLdBuf(comport:integer;address:integer) :integer;cdecl;external 'io_dll.dll';
function SensorVerify(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorQuickSearch(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorSearch(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorEraseOne(comport:integer;address:integer) :integer;cdecl;external 'io_dll.dll';
function SensorEraseAll(comport:integer) :integer;cdecl;external 'io_dll.dll';

function SensorGenImg(comport:integer) :integer;cdecl;external 'io_dll.dll';
function SensorUpImg(comport:integer;image:pTarrayImg;DampFinger:ptinteger) :integer;cdecl;external 'io_dll.dll'; //300pix/inch,0-180 gray

function SensorSetAddr(comport:integer; Addr0,Addr1:byte) :integer;cdecl;external 'io_dll.dll';
function SensorSignature(comport:integer;Sign:ptarray3) :integer;cdecl;external 'io_dll.dll';
function SensorSecuLevel(comport:integer;Level:byte) :integer;cdecl;external 'io_dll.dll';
function SensorDeviceKey(comport:integer;OldPwd,NewPwd:ptarray1) :integer;cdecl;external 'io_dll.dll';

function SensorFree(comport:integer) :integer;cdecl;external 'io_dll.dll';

//function SensorLoadPage(comport:integer;cc:ptarray4) :integer ;cdecl;external 'io_dll.dll';
//function SensorStorePage(comport:integer;cc:ptarray4) :integer;cdecl;external 'io_dll.dll';

//function YanZ(comport:integer;cont:ptboolean) :integer;cdecl;external 'io_dll.dll';
//function DenL(comport:integer;id:integer;cont:ptboolean) :integer;cdecl;external 'io_dll.dll';
//function Image(comport:integer;Image:array of byte;cont:ptboolean) :integer;cdecl;external 'io_dll.dll';
//function MoBan(comport:integer;id:integer;cont:ptboolean) :integer;cdecl;external 'io_dll.dll';
//function Verif(comport:integer;id:integer;cont:ptboolean) :integer;cdecl;external 'io_dll.dll';
//function SearchC(comport:integer;cont:ptboolean):integer;cdecl;external 'io_dll.dll';

//***********For SM-2A**************//
function SensorHighSet(comport:integer; dmperror:char;drawlevel,door,mbdoor,grade,intquick, frd:integer):integer;cdecl;external 'io_dll.dll';
function SensorLowSet(comport:integer; dmperror:char;drawlevel,door,mbdoor,grade,intquick, frd:integer):integer;cdecl;external 'io_dll.dll';

//************************************//

implementation

end.

#ifndef _PROTOCOL_
#define _PROTOCOL_

/*******************************************************/
/*---------------------- response----------------------*/
#define mRight 0x81
#define mReIn 0x82
#define mEot 0x83
#define mBusy 0x84 //Module response

#define hRight 0x81
#define hReIn 0x82
#define hEot 0x83 //Host response

/*---------------------- command----------------------*/
#define Reset 0x00
#define Status 0x01
#define Enroll 0x03
#define GenTzz 0x04
#define DownMb 0x05
#define DownTz 0x06
#define UpMb 0x07
#define UpTz 0x08
#define Store 0x09
#define LdBuf 0x0a
#define Verify 0x0b
#define QuickSearch 0x0c
#define Search 0x0d
#define EraseOne 0x0e
#define EraseAll 0x0f
#define GenImg 0x10
#define UpImg 0x11
#define SetAddr 0x12
#define Signature 0x13
#define SecuLevel 0x14
#define DeviceKey 0x15
#define Free 0x16
#define StorePage 0x17
#define LoadPage 0x18

#define SysLowSet 0x81
#define SysHighSet 0x82
/*--------------------PkgID----------------------*/
#define Cmd 0x1<<0
#define Data 0x1<<1
#define EndData 0x1<<3

struct TZDP
{
int hres;
int zres;
int direct;
char flag;
};
struct CMD
{
unsigned char PkgId;
unsigned char Address[2];
unsigned char PkgLen;
unsigned char PkgCnt[128];
unsigned char Jyh[2];
};
struct SCMD
{
unsigned char sPkgId;
unsigned char sAddress[2];
unsigned char sPkgLen;
unsigned char sPkgCnt[128];
unsigned char sJyh[2];

};
HANDLE HCOM[8];

/*--------------------function---------------------*/
bool InitCom(int comport);
void ReleaseCom(int comport);
int GetPkgByte(int comport,unsigned char *TranChar);
int SendPkgByte(int comport,unsigned char TranChar);
int GetPackage(int comport,CMD *cmd);
int SendPackage(int comport,SCMD scmd);

int SensorReset(int comport);
int SensorStatus(int comport,unsigned char* St0,unsigned char* St1);
int SensorEnroll(int comport);
int SensorGenTzz(int comport);
int SensorDownMb(int comport,int nummb,TZDP mb[],int DampMbLock);
int SensorDownTz(int comport,int numtzd,TZDP tzd[],int DampFinger);
int SensorUpMb(int comport,int* nummb,TZDP mb[],int* DampMbLock);
int SensorUpTz(int comport,int* numtzd,TZDP tzd[],int* DampFinger);

int SensorStore(int comport,int address);
int SensorLdBuf(int comport,int address);
int SensorVerify(int comport);
int SensorQuickSearch(int comport);
int SensorSearch(int comport);
int SensorEraseOne(int comport,int address);
int SensorEraseAll(int comport);

int SensorGenImg(int comport);
int SensorUpImg(int comport,unsigned char image[128][128],int* DampFinger); //300pix/inch,0-180 gray

int SensorSetAddr(int comport,unsigned char Addr0,unsigned char Addr1);
int SensorSignature(int comport,unsigned char Sign[128]);
int SensorSecuLevel(int comport,unsigned char Level);
int SensorDeviceKey(int comport,unsigned char OldPwd[8],unsigned char NewPwd[8]);

int SensorFree(int comport);
int SensorLoadPage(int comport,unsigned char cc[256]) ;
int SensorStorePage(int comport,unsigned char cc[256]);
int YanZ(int comport,bool *cont);
int DenL(int comport,int id,bool *cont);

int SensorHighSet(int comport,char dmperror,int drawlevel,int door,int mbdoor,int grade,int intquick,int frd);
int SensorLowSet(int comport,char dmperror,int drawlevel,int door,int mbdoor,int grade,int intquick,int frd);

unsigned char WriteBMP(char* file,unsigned char Input[128][128]);
/*********************************************************************/
#endif

这是一个将字符转换成为可以显示的HEX格式的2个char型数据;;

function TfrmMain.char2hex(ch:char):string;
begin
result:=shuzu[(integer(ch) div 16)+1];
result:=result+shuzu[(integer(ch) mod 16)+1];
end;


function TfrmMain.Hex2BCD(BCDByte:WORD):WORD;
begin
Result:=(BCDByte div 10)*16+ BCDByte mod 10;
END;

以上仅仅供参考。。。
 
function bintoint(value:string):longint;
var
i:i,size:integer;
begin
result:=0;
size:=length(value);
for i:=size downto 0 do
begin
if copy(value,i,1)='1' then
begin
result:=result+(1 shl i);
end;
end;
end;
 
大家好!
我一直在关注,还有谁有好提议呢,
我好分配分
 
对于直接用串口对单片机操作,建议用maxo的pcomm.dll,你会发现比较容易。
 
阿张同志要得也太多太基础的东西了,
看来你有必要看一下基础知识先。
请恕我无礼!
 
多人接受答案了。
 
后退
顶部