[linux-dvb] dvb-apps/util/[ca_]zap.c parameter parsing code

Graeme Christie graeme at sx.net.au
Thu Jun 29 12:49:44 CEST 2006


Hi all,

I'm just a ittle bit perplexed. The code in the dvb_apps repository for 
zap that parses the command line options,as far as I can tell, should 
(and does) always fail with the usage() message and drop out. Basically, 
the arpos and argc variables in the comparisons are around the wrong 
way, for example the current hg code reads:

while(argpos != argc) {

 if (!strcmp(argv[argpos], "-h")) {

     usage();

 } else if (!strcmp(argv[argpos], "-adapter")) {


   if ((argpos - argc) < 2) //<--- will always be true, as argpos is < argc

     usage();


  if (sscanf(argv[argpos+1], "%i", &adapter_id) != 1)

	usage();

  argpos+=2;

  } else if (!strcmp(argv[argpos], "-frontend")) {

  if ((argpos - argc) < 2)

 	 usage();

  if (sscanf(argv[argpos+1], "%i", &frontend_id) != 1)

	  usage();

  argpos+=2;

.
.
.

Easily fixed, by swapping the argpos and argc arguments in all the 
(argpos - argc) if statements ........ The perplexing thing is, that 
according to hg  it's been like this for 6 months ... essentially, this 
program has done nothing but print out the -h usage instructions for the 
last six months (as far as I remember at least , cz_zap has been renamed 
to zap now, and I odon't know how to look the history for the deleted 
folder up via the web interface) ? Doesn't anyone *ever* test these 
things before they commit them ....

Anyway, should I expect this utility to be working ? Once I fix the 
above issues with yestrdays tip I get :

zap -adapter 1 -out :dvr MAX
CAM Application type: 01
CAM Application manufacturer: 06ff
CAM Manufacturer code: 06ff
CAM Menu string: Irdeto Access
CAM supports the following ca system ids

Where it quite happily sits until I hit control C. Lots of typical dst 
debug still going on on the kernel logs, and strace seems to indicate 
it's just doing alot of calling some sleep function. I get the neaking 
feeling it should be showing me some ca system id stuff and then goign 
on to do wonderful things with /dev/adapter1/dvr0 ...

I'm using Manu's v4l-algo tree with a Twinhan VP-1030.

some dmesg output during the above command. It all looks reasonable to 
me, unless "resetting state machine" is a bad thing .... THe driver is 
so optimistic in it's logging (the logs are smattered with SUCCESS and 
exclamation remarks) it's hard to know when there is a problem.



===================================

 6 251 22 239 128 88 1 33

dst_ca_ioctl:  -->CA_GET_SLOT_INFO Success !

dst_ca_ioctl:  Getting Slot info

put_checksum:  Computing string checksum.

put_checksum:   -> string length : 0x07

put_checksum:   -> checksum      : 0xfb

dst_put_ci:  Put Command

dst(1) dst_comm_init: Initializing DST.

dst(1) dst_gpio_outb: mask=[ffffffff], enbb=[0001], outhigh=[0000]

dst(1) rdc_reset_state: Resetting state machine

dst(1) dst_gpio_outb: mask=[0002], enbb=[0002], outhigh=[0000]

dst(1) dst_gpio_outb: mask=[0002], enbb=[0002], outhigh=[0002]

writing [ 00 05 00 00 00 00 00 fb ]

dst(1) dst_gpio_outb: mask=[ffffffff], enbb=[0000], outhigh=[0000]

dst(1) dst_wait_dst_ready: dst wait ready after 2

ca_get_slot_info:  -->dst_put_ci SUCCESS !

ca_get_slot_info:  Slot info = [10]

===================================

 6 251 22 10 128 88 1 6

dst_ca_ioctl:  -->CA_GET_SLOT_INFO Success !

dst_ca_ioctl:  Getting Slot info

put_checksum:  Computing string checksum.

put_checksum:   -> string length : 0x07

put_checksum:   -> checksum      : 0xfb

dst_put_ci:  Put Command

dst(1) dst_comm_init: Initializing DST.

dst(1) dst_gpio_outb: mask=[ffffffff], enbb=[0001], outhigh=[0000]

dst(1) rdc_reset_state: Resetting state machine

dst(1) dst_gpio_outb: mask=[0002], enbb=[0002], outhigh=[0000]

dst(1) dst_gpio_outb: mask=[0002], enbb=[0002], outhigh=[0002]

writing [ 00 05 00 00 00 00 00 fb ]

dst(1) dst_gpio_outb: mask=[ffffffff], enbb=[0000], outhigh=[0000]

dst(1) dst_wait_dst_ready: dst wait ready after 2

ca_get_slot_info:  -->dst_put_ci SUCCESS !

ca_get_slot_info:  Slot info = [206]

===================================

 6 251 21 206 128 88 1 67

dst_ca_ioctl:  -->CA_GET_SLOT_INFO Success !

dst_ca_ioctl:  Getting Slot info

put_checksum:  Computing string checksum.

put_checksum:   -> string length : 0x07

put_checksum:   -> checksum      : 0xfb

dst_put_ci:  Put Command

dst(1) dst_comm_init: Initializing DST.

dst(1) dst_gpio_outb: mask=[ffffffff], enbb=[0001], outhigh=[0000]

dst(1) rdc_reset_state: Resetting state machine

dst(1) dst_gpio_outb: mask=[0002], enbb=[0002], outhigh=[0000]

dst(1) dst_gpio_outb: mask=[0002], enbb=[0002], outhigh=[0002]

writing [ 00 05 00 00 00 00 00 fb ]

dst(1) dst_gpio_outb: mask=[ffffffff], enbb=[0000], outhigh=[0000]












More information about the linux-dvb mailing list