CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

"mcr.c" driver.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Adria Zenq



Joined: 20 Sep 2007
Posts: 2

View user's profile Send private message

"mcr.c" driver.
PostPosted: Thu Sep 20, 2007 5:49 am     Reply with quote

Dear PCM Programmer,

is possible apply the driver "mcr.c" for reading on any direction?

Thank you.
Adria Zenq



Joined: 20 Sep 2007
Posts: 2

View user's profile Send private message

Re: "mcr.c" driver.
PostPosted: Tue Sep 25, 2007 2:05 pm     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group