Changeset 8033


Ignore:
Timestamp:
01/02/13 20:10:46 (9 years ago)
Author:
Admin
Message:

Remove device_out_endpoint from config. Instead, you can now specify the reader type in front of the device string separated by a ";".
Possibilites are "SR" (Argolis Smartreader), "Infinity" (Infinity USB Smart), "TripleP1" (Argolis TripleReader Port 1), "TripleP2" (Argolis TripleReader Port 2) or "TripleP3" (Argolis TripleReader Port 3). Example is device=TripleP1;Serial:00000001. If you dont specify the reader type, it defaults to the Argolis Smartreader.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/csctapi/ifd_smartreader.c

    r8007 r8033  
    4949    libusb_device_handle *usb_dev_handle;
    5050    enum smartreader_chip_type type;
    51     uint8_t in_ep;  // 0x01
    52     uint8_t out_ep; // 0x82
     51    uint8_t in_ep;
     52    uint8_t out_ep;
    5353    int32_t index;
    5454    /** usb read timeout */
     
    7373};
    7474
     75struct s_reader_types {
     76    char *name;
     77    uint8_t in_ep;
     78    uint8_t out_ep;
     79    int32_t index;
     80    int32_t interface; 
     81}
     82
     83static const reader_types[] = {
     84    {"SR", 0x01, 0x82, INTERFACE_A, 0},
     85    {"Infinity", 0x01, 0x81, INTERFACE_A, 0},
     86    {"TripleP1", 0x02, 0x81, INTERFACE_A, 0},
     87    {"TripleP2", 0x04, 0x83, INTERFACE_B, 1},
     88    {"TripleP3", 0x06, 0x85, INTERFACE_C, 2}
     89};
     90
    7591static int32_t init_count = 0;
    7692
     
    151167}
    152168
    153 static bool smartreader_check_endpoint(libusb_device *usb_dev,uint8_t out_endpoint,uint8_t in_endpoint)
     169static bool smartreader_check_endpoint(libusb_device *usb_dev,uint8_t in_endpoint,uint8_t out_endpoint)
    154170{
    155171    struct libusb_device_descriptor usbdesc;
     
    187203}
    188204
    189 static struct libusb_device* find_smartreader(const char *busname,const char *dev_name, uint8_t out_endpoint, uint8_t in_endpoint)
     205static struct libusb_device* find_smartreader(const char *busname,const char *dev_name, uint8_t in_endpoint, uint8_t out_endpoint)
    190206{
    191207  int32_t dev_found = 0;
     
    237253                    if(!strcmp(trim(iserialbuffer),dev_name)) {
    238254                        cs_log("Found reader with serial %s at %03d:%03d",dev_name,libusb_get_bus_number(dev),libusb_get_device_address(dev));
    239                         if(smartreader_check_endpoint(dev,out_endpoint,in_endpoint))
     255                        if(smartreader_check_endpoint(dev,in_endpoint,out_endpoint))
    240256                            dev_found=1;
    241257                    }
     
    245261                cs_debug_mask(D_DEVICE, "SR: Checking FTDI device: %03d on bus %03d",libusb_get_device_address(dev),libusb_get_bus_number(dev));
    246262                // check for smargo endpoints.
    247                 if(smartreader_check_endpoint(dev,out_endpoint,in_endpoint))
     263                if(smartreader_check_endpoint(dev,in_endpoint,out_endpoint))
    248264                    dev_found=1;
    249265            }
     
    265281}
    266282
    267 void smartreader_init(struct s_reader *reader,uint8_t out_endpoint,uint8_t in_endpoint)
    268 {
    269     reader->sr_config->usb_dev = NULL;
    270     reader->sr_config->usb_dev_handle=NULL;
    271     reader->sr_config->usb_read_timeout = 10000;
    272     reader->sr_config->usb_write_timeout = 10000;
    273 
    274     reader->sr_config->type = TYPE_BM;    /* chip type */
    275     reader->sr_config->baudrate = -1;
    276     reader->sr_config->bitbang_enabled = 0;  /* 0: normal mode 1: any of the bitbang modes enabled */
    277 
    278     reader->sr_config->writebuffer_chunksize = 64;
    279     reader->sr_config->max_packet_size = 0;
    280 
    281     reader->sr_config->interface = INTERFACE_ANY;
    282     reader->sr_config->index = INTERFACE_A;
    283     reader->sr_config->in_ep = in_endpoint;
    284     reader->sr_config->out_ep = out_endpoint;
     283void smartreader_init(struct s_reader *reader, char *rdrtype)
     284{
     285    int32_t i;
     286    reader->sr_config->usb_dev = NULL;
     287    reader->sr_config->usb_dev_handle=NULL;
     288    reader->sr_config->usb_read_timeout = 10000;
     289    reader->sr_config->usb_write_timeout = 10000;
     290   
     291    reader->sr_config->type = TYPE_BM;    /* chip type */
     292    reader->sr_config->baudrate = -1;
     293    reader->sr_config->bitbang_enabled = 0;  /* 0: normal mode 1: any of the bitbang modes enabled */
     294   
     295    reader->sr_config->writebuffer_chunksize = 64;
     296    reader->sr_config->max_packet_size = 0;
     297    if(rdrtype){
     298        for(i = 0; i < sizeof(reader_types)/sizeof(struct s_reader_types); ++i){
     299            if(!strcmp(reader_types[i].name, rdrtype)){
     300                reader->sr_config->in_ep = reader_types[i].in_ep;
     301                reader->sr_config->out_ep = reader_types[i].out_ep;             
     302                reader->sr_config->index = reader_types[i].index;
     303                reader->sr_config->interface = reader_types[i].interface;
     304                return;
     305            }
     306        }
     307        rdr_log(reader, "Smartreader: The defined reader type %s is unknown. Using default Smartreader values.", rdrtype);
     308    }
     309    reader->sr_config->in_ep = 0x01;
     310    reader->sr_config->out_ep = 0x82;   
     311    reader->sr_config->index = INTERFACE_A;
     312    reader->sr_config->interface = 0;
    285313}
    286314
     
    900928        reader->sr_config->type = TYPE_4232H;
    901929
    902     // Set default interface on dual/quad type chips
    903     switch(reader->sr_config->type) {
    904         case TYPE_2232C:
    905         case TYPE_2232H:
    906         case TYPE_4232H:
    907             if (!reader->sr_config->index)
    908                 reader->sr_config->index = INTERFACE_A;
    909             break;
    910         default:
    911             break;
    912     }
    913 
    914930    // Determine maximum packet size
    915931    reader->sr_config->max_packet_size = smartreader_determine_max_packet_size(reader);
     
    10641080static int32_t SR_Init (struct s_reader *reader)
    10651081{
    1066     uint8_t out_endpoint;
    1067     uint8_t in_endpoint;
    10681082    int32_t ret;
    1069     char device[128];
    1070     char *busname, *dev, *search = ":", *saveptr1 = NULL;
    1071     // split the device name from the reader conf into devname and busname
    1072     memcpy(device,reader->device,128);
    1073     busname=strtok_r(device,search, &saveptr1);
    1074     dev=strtok_r(NULL,search, &saveptr1);
     1083    char device[strlen(reader->device)+1];
     1084    char *rdrtype, *busname, *dev, *search = ":", *saveptr1 = NULL;
     1085    memcpy(device,reader->device,strlen(reader->device)+1);
     1086    // split the device name from the reader conf into devname and busname. rdrtype is optional   
     1087    rdrtype=strtok_r(device,";", &saveptr1);
     1088    busname=strtok_r(NULL,":", &saveptr1);
     1089    dev=strtok_r(NULL,":", &saveptr1);
     1090    if(!busname){
     1091        rdrtype=NULL;
     1092        memcpy(device,reader->device,strlen(reader->device)+1);
     1093        busname=strtok_r(device,":", &saveptr1);
     1094        dev=strtok_r(NULL,search, &saveptr1);
     1095    }
     1096
    10751097    if(!busname || !dev) {
    10761098        rdr_log(reader, "Wrong device format (%s), it should be Device=bus:dev",reader->device);
     
    10791101    if (!reader->sr_config && !cs_malloc(&reader->sr_config, sizeof(struct s_sr_config)))
    10801102        return ERROR;
    1081     cs_writelock(&sr_lock);
     1103   
    10821104    rdr_debug_mask(reader, D_DEVICE, "SR: Looking for device %s on bus %s",dev,busname);
    1083 
     1105    smartreader_init(reader, rdrtype);
     1106
     1107        cs_writelock(&sr_lock);
     1108       
    10841109    if(!init_count) {
    10851110     ret = libusb_init(NULL);
     
    10901115     }
    10911116    }
    1092     init_count++;
    1093 
    1094     //Overwrite default endpoint if config has a value for it
    1095     if(reader->device_endpoint != 0)
    1096       out_endpoint = reader->device_endpoint;
    1097     else
    1098         out_endpoint = 0x82;
    1099 
    1100      // ToDo in endpoint hard coded, should be configurable
    1101      switch (out_endpoint) {
    1102      case 0x82: // Single smartreader
    1103     in_endpoint = 0x1;
    1104     break;
    1105      case 0x81: // Triple reader 1st
    1106     in_endpoint = 0x2;
    1107     break;
    1108      case 0x83: // Triple reader 2nd
    1109     in_endpoint = 0x4;
    1110     break;
    1111      case 0x85: // Triple reader 3rd
    1112     in_endpoint = 0x6;
    1113     break;
    1114      default:   // previous default set in smartreader_init()
    1115     in_endpoint = 0x2;
    1116     break;
    1117      }
    1118 
    1119     rdr_log(reader, "Using 0x%02X/0x%02X as endpoint for smartreader hardware detection", out_endpoint, in_endpoint);
    1120 
    1121     smartreader_init(reader,out_endpoint,in_endpoint);
    1122 
    1123     reader->sr_config->usb_dev=find_smartreader(busname,dev,out_endpoint,in_endpoint);
     1117    init_count++;   
     1118   
     1119    rdr_log(reader, "Using 0x%02X/0x%02X as endpoint for smartreader hardware detection", reader->sr_config->in_ep, reader->sr_config->out_ep);
     1120
     1121    reader->sr_config->usb_dev=find_smartreader(busname,dev,reader->sr_config->in_ep,reader->sr_config->out_ep);
    11241122    if (!reader->sr_config->usb_dev) {
    11251123        --init_count;
     
    11301128    }
    11311129
    1132     //The smartreader has different endpoint addresses
    1133     //compared to a real FT232 device, so change them here,
    1134     //also a good way to compare a real FT232 with a smartreader
    1135     //if you enumarate usb devices
    1136     reader->sr_config->in_ep = in_endpoint;
    1137     reader->sr_config->out_ep = out_endpoint;
    1138 
    1139     rdr_debug_mask(reader, D_DEVICE, "SR: Opening smartreader device %s on bus %s endpoint in 0x%02X out 0x%02X",dev,busname,in_endpoint,out_endpoint);
     1130    rdr_debug_mask(reader, D_DEVICE, "SR: Opening smartreader device %s on bus %s endpoint in 0x%02X out 0x%02X",dev,busname,reader->sr_config->in_ep,reader->sr_config->out_ep);
    11401131
    11411132    if ((ret=smartreader_usb_open_dev(reader))) {
     
    11441135            libusb_exit(NULL);
    11451136        cs_writeunlock(&sr_lock);
    1146         rdr_log(reader, "unable to open smartreader device %s in bus %s endpoint in 0x%02X out 0x%02X (ret=%d)\n", dev,busname,in_endpoint,out_endpoint,ret);
     1137        rdr_log(reader, "unable to open smartreader device %s in bus %s endpoint in 0x%02X out 0x%02X (ret=%d)\n", dev,busname,reader->sr_config->in_ep,reader->sr_config->out_ep,ret);
    11471138        return ERROR;
    11481139    }
  • trunk/globals.h

    r8025 r8033  
    12081208#endif
    12091209#ifdef WITH_LIBUSB
    1210     uint8_t         device_endpoint;                // usb endpoint for Infinity USB Smart in smartreader mode.
    12111210    struct s_sr_config *sr_config;
    12121211#endif
  • trunk/module-webif-pages.c

    r8010 r8033  
    12031203            <TR><TD>##TPLHELPPREFIX##server#enable##TPLHELPSUFFIX##Enable:</A></TD><TD><input name=\"enable\" type=\"hidden\" value=\"0\"><input name=\"enable\" type=\"checkbox\" value=\"1\" ##ENABLED##></TD></TR>\n\
    12041204            <TR><TD>##TPLHELPPREFIX##server#device##TPLHELPSUFFIX##Device:</A></TD><TD><input name=\"device\" type=\"text\" size=\"63\" maxlength=\"127\" value=\"##DEVICE##\"></TD></TR>\n\
    1205             <TR><TD>##TPLHELPPREFIX##server#device_out_endpoint##TPLHELPSUFFIX##Device out Endpoint:</A></TD><TD>##DEVICEEP##</TD></TR>\n\
    12061205            <TR><TD>##TPLHELPPREFIX##server#group##TPLHELPSUFFIX##Group:</A></TD><TD><input name=\"group\" type=\"text\" size=\"20\" maxlength=\"100\" value=\"##GRP##\"></TD></TR>\n\
    12071206            <TR><TD>##TPLHELPPREFIX##server#fallback##TPLHELPSUFFIX##Fallback:</A></TD><TD><input name=\"fallback\" type=\"hidden\" value=\"0\"><input name=\"fallback\" type=\"checkbox\" value=\"1\" ##FALLBACKCHECKED##></TD></TR>\n\
     
    13171316                <TR><TD>##TPLHELPPREFIX##server#sc8in1_dtrrts_patch##TPLHELPSUFFIX##SC8in1 DTR/RTS Patch:</A><input name=\"sc8in1_dtrrts_patch\" type=\"hidden\" value=\"0\"></TD><TD><input name=\"sc8in1_dtrrts_patch\" type=\"checkbox\" value=\"1\" ##SC8IN1DTRRTSPATCHCHECKED##></TD></TR>\n\
    13181317                ##TPLREADERCOOLSTREAMBIT##"
    1319 
    1320 #define TPLREADERCONFIGDEVICEEPBIT "\
    1321                 <SELECT name=\"device_out_endpoint\">\n\
    1322                     <OPTION value=\"\" ##DEVICEOUTEP0##>default</OPTION>\n\
    1323                     <OPTION value=\"0x82\" ##DEVICEOUTEP1##>0x82 - Smargo Smartreader Plus</OPTION>\n\
    1324                     <OPTION value=\"0x81\" ##DEVICEOUTEP2##>0x81 - Smargo Triple Port 1</OPTION>\n\
    1325                     <OPTION value=\"0x83\" ##DEVICEOUTEP3##>0x83 - Smargo Triple Port 2</OPTION>\n\
    1326                     <OPTION value=\"0x85\" ##DEVICEOUTEP4##>0x85 - Smargo Triple Port 3</OPTION>\n\
    1327                 </SELECT>\n"
    13281318
    13291319#define TPLREADERCOOLSTREAMBIT "\
     
    24472437    ,{"ENABLELEDBIT", TPLENABLELEDBIT, "LEDSUPPORT"}
    24482438#endif
    2449 #ifdef WITH_LIBUSB
    2450     ,{"READERCONFIGDEVICEEPBIT", TPLREADERCONFIGDEVICEEPBIT, "WITH_LIBUSB"}
    2451 #endif
    24522439#ifdef WITH_COOLAPI
    24532440    ,{"READERCOOLSTREAMBIT", TPLREADERCOOLSTREAMBIT, "WITH_COOLAPI"}
  • trunk/module-webif.c

    r8024 r8033  
    15291529        tpl_addVar(vars, TPLADD, "CCCVERSIONSELECTED7", "selected");
    15301530    }
    1531 #endif
    1532 
    1533 #ifdef WITH_LIBUSB
    1534     if(!rdr->device_endpoint) {
    1535         tpl_addVar(vars, TPLADD, "DEVICEOUTEP0", "selected");
    1536     } else if (rdr->device_endpoint == 0x82) {
    1537         tpl_addVar(vars, TPLADD, "DEVICEOUTEP1", "selected");
    1538     } else if (rdr->device_endpoint == 0x81) {
    1539         tpl_addVar(vars, TPLADD, "DEVICEOUTEP2", "selected");
    1540     } else if (rdr->device_endpoint == 0x83) {
    1541            tpl_addVar(vars, TPLADD, "DEVICEOUTEP3", "selected");
    1542     } else if (rdr->device_endpoint == 0x85) {
    1543         tpl_addVar(vars, TPLADD, "DEVICEOUTEP4", "selected");
    1544     }
    1545     tpl_addVar(vars, TPLADD, "DEVICEEP", tpl_getTpl(vars, "READERCONFIGDEVICEEPBIT"));
    1546 #else
    1547     tpl_addVar(vars, TPLADD, "DEVICEEP", "not avail LIBUSB");
    15481531#endif
    15491532
  • trunk/oscam-config-reader.c

    r7908 r8033  
    5252        return;
    5353    }
    54 
    55 #ifdef WITH_LIBUSB
    56     if (!strcmp(token, "device_out_endpoint")) {
    57         if (strlen(value) > 0) {
    58             sscanf(value, "0x%2X", &i);
    59             rdr->device_endpoint = i;
    60         } else {
    61             rdr->device_endpoint = 0;
    62         }
    63         return;
    64     }
    65 #endif
    6654
    6755    if (!strcmp(token, "key")) {
     
    12831271            fprintf(f, "\n");
    12841272
    1285 #ifdef WITH_LIBUSB
    1286             if (isphysical)
    1287                 if (rdr->device_endpoint || cfg.http_full_cfg)
    1288                     fprintf_conf(f, "device_out_endpoint", "0x%2X\n", rdr->device_endpoint);
    1289 #endif
    1290 
    12911273            if (rdr->ncd_key[0] || rdr->ncd_key[13] || cfg.http_full_cfg) {
    12921274                fprintf_conf(f, "key", "%s", ""); // it should not have \n at the end
Note: See TracChangeset for help on using the changeset viewer.