Ignore:
Timestamp:
01/11/10 19:30:52 (12 years ago)
Author:
alno
Message:

WebIf:

  • Merging revisions 1180-1185 of trunk
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/monitor-improvement/csctapi/io_serial.c

    r1180 r1189  
    520520
    521521   /* Set the bitrate */
    522    if(io->reader_type==RTYP_SMART)
    523    {
    524 #ifdef DEBUG_IO
    525       printf("IO: SMARTREADER .. switching to frequency to %2.2fMHz\n", (float)io->mhz/100.0);
    526 #endif
    527       if(!IO_Serial_Set_Smartreader_Freq(io))
    528       {
    529 #ifdef DEBUG_IO
    530          printf("IO: SMARTREADER .. ERROR switching to 6MHz\n");
    531 #endif
    532          return FALSE;
    533       }
    534    }
    535 
    536522#ifdef OS_LINUX
    537523   if (io->mhz == io->cardmhz)
     
    10641050        return TRUE;
    10651051}
    1066 
    1067 
    1068 bool IO_Serial_Set_Smartreader_Freq(IO_Serial * io)
    1069  {
    1070    struct termios term;
    1071    struct termios orig;
    1072    int freq = io->mhz;
    1073    unsigned char fi_di[4]={0x01, 0x01, 0x74, 0x01};
    1074    unsigned char fr[3]={0x02, 0x00, 0x00};
    1075    unsigned char nn[2]={0x03, 0x00};
    1076    unsigned char pr[2]={0x04, 0x00};
    1077    unsigned char in[2]={0x05, 0x00};
    1078    
    1079    orig=term;
    1080      
    1081    /* set smartreader in CMD mode */
    1082    tcgetattr(io->fd, &term);
    1083    
    1084    term.c_cflag &= ~CSIZE;
    1085    term.c_cflag |= CS5;
    1086    cfsetospeed(&term, 9600);
    1087    cfsetispeed(&term, 9600);
    1088    tcsetattr(io->fd, TCSANOW, &term);
    1089    
    1090    // our freq comes in as 358, 357 or 600 so it needs this to be in KHz for the FR command
    1091    freq*=10;
    1092    fr[1]=(unsigned char)((freq & 0xff00)>>8);
    1093    fr[2]=(unsigned char)(freq & 0x00ff);
    1094 
    1095    // Irdeto card supposedly need NN set to 1 .. to be confirmed
    1096    if(io->cardmhz == 600)
    1097       nn[1]=0x01;
    1098      
    1099    // send the commands
    1100    IO_Serial_Write (io, 0, 4, fi_di);
    1101    IO_Serial_Flush(io);
    1102    
    1103    IO_Serial_Write (io, 0, 3, fr);
    1104    IO_Serial_Flush(io);
    1105 
    1106    IO_Serial_Write (io, 0, 2, nn);
    1107    IO_Serial_Flush(io);
    1108 
    1109    IO_Serial_Write (io, 0, 2, pr);
    1110    IO_Serial_Flush(io);
    1111 
    1112    IO_Serial_Write (io, 0, 2, in);
    1113    IO_Serial_Flush(io);
    1114      
    1115    /* set smartreader in DATA mode */
    1116    tcgetattr(io->fd, &orig);
    1117    orig.c_cflag &= ~CSIZE;
    1118    orig.c_cflag |= CS8;
    1119    tcsetattr(io->fd, TCSANOW, &orig);
    1120 
    1121    return TRUE;
    1122  }
    11231052 
Note: See TracChangeset for help on using the changeset viewer.