Adria Zenq
Joined: 20 Sep 2007 Posts: 2
|
Re: "mcr.c" driver. |
Posted: Tue Sep 25, 2007 2:05 pm |
|
|
I do modify the mcr.c code for read in any direction, but donĀ“t work with any magnetic card:
Code: | int mcr_read (char* track2=0x00)
{
int error = 0;
int1 dataBit = 0;
char i=0;
int1 LtoR=0, RtoL = 0;
char countbit = 4;
int1 reverse = 0;
int1 set_one_time=0;
int1 ST2 = 1;
int1 ST2_old = 1;
int1 firstOne2= 0;
int1 parity2 = 0;
int count2 = 0;
int index2 = 0;
int LRC2 = 0;
while(input(MCR_CARD_PRESENT))
{
LtoR=0;
RtoL=0;
index2=0;
reverse=0;
for(i=0;i<40;i++)
{
Track2[i]=0x00;
}
}
while(!input(MCR_CARD_PRESENT))
{
if(track2 != 0 && index2 < 40)
{
ST2 = input(MCR_STROBE2);
if(ST2 == 0 && ST2_old == 1)
{
ST2_old = 0;
if(firstOne2 == 1)
{
if(count2 == countbit)
{
count2 = 0;
if(reverse)
{
if(!input(MCR_DATA2))
bit_set(*(track2+index2), 0);
}
if(index2==0 && !LtoR && !RtoL && !set_one_time)
{
if(*(track2)==0x0B)
LtoR=1;
else
{
if(!LtoR && !RtoL)
{
index2=39;
RtoL = 1;
reverse=1;
}
}
set_one_time=1;
}
if(LtoR && !RtoL)
{
if(*(track2+index2-1) == '?' && LRC2 != *(track2+index2))
{
error |= MCR_ERR_LRC2;
}
else
{
LRC2 ^= *(track2+index2);
}
*(track2+index2) += 0x30;
if(!input(MCR_DATA2) != parity2 && *(track2+index2) != '0')
{
error |= MCR_ERR_PARITY2;
}
parity2 = 1;
++index2;
}
//REVERSE DECODE
if(RtoL && !LtoR)
{
*(track2+index2) &= 0x0F;
*(track2+index2) += 0x30;
--index2;
}
}
else
{
dataBit = !input(MCR_DATA2);
parity2 ^= dataBit;
if( !reverse )
{
if(count2==0)
{
if(dataBit)
bit_set(*(track2+index2), 0);
else
bit_clear(*(track2+index2), 0);
}
if(count2==1)
{
if(dataBit)
bit_set(*(track2+index2), 1);
else
bit_clear(*(track2+index2), 1);
}
if(count2==2)
{
if(dataBit)
bit_set(*(track2+index2), 2);
else
bit_clear(*(track2+index2), 2);
}
if(count2==3)
{
if(dataBit)
bit_set(*(track2+index2), 3);
else
bit_clear(*(track2+index2), 3);
}
}
//REVERSE BITS
if( reverse )
{
if(count2==0)
{
if(dataBit)
bit_set(*(track2+index2), 4);
else
bit_clear(*(track2+index2), 4);
}
if(count2==1)
{
if(dataBit)
bit_set(*(track2+index2), 3);
else
bit_clear(*(track2+index2), 3);
}
if(count2==2)
{
if(dataBit)
bit_set(*(track2+index2), 2);
else
bit_clear(*(track2+index2), 2);
}
if(count2==3)
{
if(dataBit)
bit_set(*(track2+index2), 1);
else
bit_clear(*(track2+index2), 1);
}
}
++count2;
}
}
else
{
if(!input(MCR_DATA2))
{
firstOne2 = 1;
bit_set(*(track2+index2), 0);
++count2;
}
}
}
else if(ST2 == 1)
{
ST2_old = 1;
}
}
}
return error;
} |
Somebody help me? Thanks! |
|