Changeset 71


Ignore:
Timestamp:
05/17/09 07:08:18 (12 years ago)
Author:
rorothetroll
Message:

All : preliminary support for the smartreader+. I had to add some parameter to some

of the function to carry over the reader type (mouse or smartreader).
you can now set the Protocol to smartreader in the [reader] section of oscam.server
I will change the smartreader+ frequency by setting it in command mode, sending the command
to set the reader frequency and other params. I used the one provided in the small text file I gor
(Smartreader_integraters_manual.txt). you can also find the same info here : http://www.rdi-board.com/showthread.php?t=82134
Hopefuly thi infos are correct and my code should work as it uses the already existing function to read/write on the port.

Now we need some testers

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/csctapi/cardterminal.c

    r8 r71  
    7171}
    7272
    73 char CardTerminal_Init (CardTerminal * ct, unsigned short pn)
     73char CardTerminal_Init (CardTerminal * ct, unsigned short pn, int reader_type)
    7474{
    7575    char ret;
     
    7878   
    7979    /* Create a new IO_Serial */
    80     ct->io = IO_Serial_New ();
     80    ct->io = IO_Serial_New (reader_type);
    8181   
    8282    /* Memory error */
  • trunk/csctapi/cardterminal.h

    r8 r71  
    6868/* Intialice a CardTerminal in a given port */
    6969extern char
    70 CardTerminal_Init (CardTerminal * ct, unsigned short pn);
     70CardTerminal_Init (CardTerminal * ct, unsigned short pn, int reader_type);
    7171
    7272/* Send a CT-BCS command to a CardTerminal */
  • trunk/csctapi/ctapi.c

    r8 r71  
    5050 */
    5151
    52 char CT_init (unsigned short ctn, unsigned short pn)
     52char CT_init (unsigned short ctn, unsigned short pn, int reader_type)
    5353{
    5454    CardTerminal *ct;
     
    6969        {   
    7070            /* Initialize CardTerminal */
    71             ret = CardTerminal_Init (ct, pn);
     71            ret = CardTerminal_Init (ct, pn, reader_type);
    7272           
    7373            /* Add CardTerminal to list */
  • trunk/csctapi/ctapi.h

    r8 r71  
    2121extern char CT_init (
    2222      unsigned short Ctn,                  /* Terminal Number */
    23       unsigned short pn                    /* Port Number */
     23      unsigned short pn,                    /* Port Number */
     24      int reader_type                        /* reader type (mouse, smartreader)
    2425      );
    2526
  • trunk/csctapi/defines.h

    r8 r71  
    9191#define RTYP_DB2COM1    3
    9292#define RTYP_DB2COM2    4
     93#define RTYP_SMART  5
    9394#endif /* DEFINES_H */
  • trunk/csctapi/io_serial.c

    r70 r71  
    164164 */
    165165
    166 IO_Serial * IO_Serial_New (void)
     166IO_Serial * IO_Serial_New (int reader_type)
    167167{
    168168    IO_Serial *io;
     
    172172    if (io != NULL)
    173173        IO_Serial_Clear (io);
     174   
     175    io->reader_type=reader_type;
    174176   
    175177    return io;
     
    508510      return FALSE;
    509511#endif
    510 
     512   
    511513   //   printf("IO: Setting properties: com%d, %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", io->com, props->input_bitrate, props->bits, props->parity == IO_SERIAL_PARITY_EVEN ? "Even" : props->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", props->stopbits, props->dtr, props->rts);
    512514   memset (&newtio, 0, sizeof (newtio));
     
    515517   extern int mhz;
    516518   extern int reader_irdeto_mode;
     519
     520   if(io->reader_type==RTYP_SMART)
     521   {
     522#ifdef DEBUG_IO
     523      printf("IO: SMARTREADER .. switching to frequency to %2.2fMHz\n", (float)mhz/100.0);
     524#endif
     525      if(!IO_Serial_Set_Smartreader_Freq(io,mhz))
     526      {
     527#ifdef DEBUG_IO
     528         printf("IO: SMARTREADER .. ERROR switching to 6MHz\n");
     529#endif
     530         return FALSE;
     531      }
     532   }
     533
    517534   if (mhz == 600)
    518535   {
     536     
    519537      /* for 6MHz */
    520538      if (reader_irdeto_mode)
     
    11031121        return TRUE;
    11041122}
     1123
     1124
     1125bool IO_Serial_Set_Smartreader_Freq(IO_Serial * io, int freq)
     1126 {
     1127   struct termios term;
     1128   struct termios orig;
     1129   unsigned int u;
     1130   unsigned char fi_di[4]={0x01, 0x01, 0x74, 0x01};
     1131   unsigned char fr[3]={0x02, 0x00, 0x00};
     1132   unsigned char nn[2]={0x03, 0x00};
     1133   unsigned char pr[2]={0x04, 0x00};
     1134   unsigned char in[2]={0x05, 0x00};
     1135   
     1136   orig=term;
     1137     
     1138   /* set smartreader in CMD mode */
     1139   tcgetattr(io->fd, &term);
     1140   
     1141   term.c_cflag &= ~CSIZE;
     1142   term.c_cflag |= CS5;
     1143   cfsetospeed(&term, 9600);
     1144   cfsetispeed(&term, 9600);
     1145   tcsetattr(io->fd, TCSANOW, &term);
     1146   freq*=10;
     1147   fr[1]=(unsigned char)((freq & 0xff00)>>8);
     1148   fr[2]=(unsigned char)(freq & 0x00ff);
     1149
     1150   // printf("fr = %02x %02x %02x\n" , fr[0],fr[1],fr[2]);
     1151   
     1152   // send the commands
     1153   IO_Serial_Write (io, 0, 4, fi_di);
     1154   IO_Serial_Flush(io);
     1155   
     1156   IO_Serial_Write (io, 0, 3, fr);
     1157   IO_Serial_Flush(io);
     1158
     1159   IO_Serial_Write (io, 0, 2, nn);
     1160   IO_Serial_Flush(io);
     1161
     1162   IO_Serial_Write (io, 0, 3, pr);
     1163   IO_Serial_Flush(io);
     1164
     1165   IO_Serial_Write (io, 0, 2, in);
     1166   IO_Serial_Flush(io);
     1167     
     1168   /* set smartreader in DATA mode */
     1169   tcgetattr(io->fd, &orig);
     1170   orig.c_cflag &= ~CSIZE;
     1171   orig.c_cflag |= CS8;
     1172   tcsetattr(io->fd, TCSANOW, &orig);
     1173
     1174   return TRUE;
     1175 }
     1176 
  • trunk/csctapi/io_serial.h

    r67 r71  
    7575    bool usbserial;         /* Is serial USB device */
    7676    int wr;
     77    int reader_type;
    7778}
    7879IO_Serial;
     
    8586//extern void IO_Serial_Reopen (IO_Serial * io);
    8687extern void IO_Serial_Flush (IO_Serial * io);
    87 extern IO_Serial *IO_Serial_New (void);
     88extern IO_Serial *IO_Serial_New (int reader_type);
    8889extern void IO_Serial_Delete (IO_Serial * io);
    8990
     
    105106extern bool IO_Serial_Read (IO_Serial * io, unsigned timeout, unsigned size, BYTE * data);
    106107extern bool IO_Serial_Write (IO_Serial * io, unsigned delay, unsigned size, BYTE * data);
    107 extern bool IO_Serial_Read_MacOSX (IO_Serial * io, unsigned timeout, unsigned size, BYTE * data);
    108 extern bool IO_Serial_Write_MAcOSX (IO_Serial * io, unsigned delay, unsigned size, BYTE * data);
    109108
    110109/* Serial port atributes */
     
    112111extern void IO_Serial_GetPnPId (IO_Serial * io, BYTE * pnp_id, unsigned *length);
    113112
     113/* smartreader Frequency set */
     114extern bool IO_Serial_Set_Smartreader_Freq(IO_Serial * io, int freq);
     115
    114116#endif /* IO_SERIAL */
  • trunk/globals.h

    r57 r71  
    113113#define R_MOUSE         0x1 // Reader smartcard mouse
    114114#define R_INTERN        0x2 // Reader smartcard intern
     115#define R_SMART     0x5 // Smartreader+
    115116#define R_CAMD35        0x10    // Reader cascading camd 3.5x
    116117#define R_CAMD33        0x11    // Reader cascading camd 3.3x
  • trunk/module-monitor.c

    r70 r71  
    269269                  case R_MOUSE   : ctyp="mouse";    break;
    270270                  case R_INTERN  : ctyp="intern";   break;
     271                  case R_SMART   : ctyp="smartreader";    break;
    271272                  case R_CAMD35  : ctyp="camd 3.5x";break;
    272273                  case R_CAMD33  : ctyp="camd 3.3x";break;
  • trunk/oscam-config.c

    r70 r71  
    990990  {
    991991    if (!strcmp(value, "mouse"))       rdr->typ=R_MOUSE;
     992    if (!strcmp(value, "smartreader"))       rdr->typ=R_SMART;
    992993    if (!strcmp(value, "internal"))    rdr->typ=R_INTERN;
    993994    if (!strcmp(value, "intern"))      rdr->typ=R_INTERN;
  • trunk/oscam.c

    r70 r71  
    540540                     else
    541541                     {
    542                        if (reader[ridx].typ==R_MOUSE)
     542                       if (reader[ridx].typ==R_MOUSE || reader[ridx].typ==R_SMART)
    543543                         cs_log("reader started (pid=%d, device=%s, detect=%s%s, mhz=%d)",
    544544                                pid, reader[ridx].device,
  • trunk/reader-common.c

    r57 r71  
    2929  {
    3030    case R_MOUSE:
     31    case R_SMART:
    3132      rc=PORT_STD;
    3233#ifdef TUXBOX
     
    235236  cs_ptyp=D_DEVICE;
    236237  snprintf(oscam_device, sizeof(oscam_device), "%s", device);
    237   if ((rc=CT_init(1, reader_device_type(device, typ)))!=OK)
     238  if ((rc=CT_init(1, reader_device_type(device, typ),reader[ridx].typ))!=OK)
    238239    cs_log("Cannot open device: %s", device);
    239240  cs_debug("ct_init on %s: %d", device, rc);
Note: See TracChangeset for help on using the changeset viewer.