Discussion:
[PATCH] dvb-apps/util/szap/czap.c "ERROR: cannot parse service data"
klaas de waal
2010-01-24 10:58:37 UTC
Permalink
The czap utility (dvb-apps/util/szap/czap.c) cannot scan the channel
configuration file when compiled on Fedora 12 with gcc-4.4.2.

The czap output is:

[***@myth2 szap]$ ./czap -c ~/.czap/ziggo-channels.conf Cartoon
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
reading channels from file '/local/klaas/.czap/ziggo-channels.conf'
1 Cartoon:356000000:INVERSION_AUTO:6875000:FEC_NONE:QAM_64:1660:1621
ERROR: cannot parse service data

Problem is tha the "sscanf" function uses the "%a[^:]" format
specifier. According to "man sscanf" you need to define _GNU_SOURCE if
you want this to work because it is a gnu-only extension.
Adding a first line "#define _GNU_SOURCE" to czap.c and recompiling
solves the problem.

The czap output is now:

[***@myth2 szap]$ ./czap -c ~/.czap/ziggo-channels.conf Cartoon
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
reading channels from file '/local/klaas/.czap/ziggo-channels.conf'
1 Cartoon:356000000:INVERSION_AUTO:6875000:FEC_NONE:QAM_64:1660:1621
1 Cartoon: f 356000000, s 6875000, i 2, fec 0, qam 3, v 0x67c, a 0x655
status 00 | signal 0000 | snr b7b7 | ber 000fffff | unc 00000098 |
status 1f | signal d5d5 | snr f3f3 | ber 000006c0 | unc 0000009b | FE_HAS_LOCK
status 1f | signal d5d5 | snr f4f4 | ber 00000000 | unc 00000000 | FE_HAS_LOCK

This is done on a Linux 2.6.32.2 kernel with a TT C-1501 DVB-C card.

Signed-off-by: Klaas de Waal <***@gmail.com>

-------------------------------------------------------------------------------------------

diff -r 61b72047a995 util/szap/czap.c
--- a/util/szap/czap.c Sun Jan 17 17:03:27 2010 +0100
+++ b/util/szap/czap.c Sun Jan 24 11:40:43 2010 +0100
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
Manu Abraham
2010-01-24 21:14:48 UTC
Permalink
Hi Klaas,
Post by klaas de waal
The czap utility (dvb-apps/util/szap/czap.c) cannot scan the channel
configuration file when compiled on Fedora 12 with gcc-4.4.2.
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
reading channels from file '/local/klaas/.czap/ziggo-channels.conf'
=A01 Cartoon:356000000:INVERSION_AUTO:6875000:FEC_NONE:QAM_64:1660:16=
21
Post by klaas de waal
ERROR: cannot parse service data
Problem is tha the "sscanf" function uses the "%a[^:]" format
specifier. According to "man sscanf" you need to define _GNU_SOURCE i=
f
Post by klaas de waal
you want this to work because it is a gnu-only extension.
Adding a first line "#define _GNU_SOURCE" to czap.c and recompiling
solves the problem.
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
reading channels from file '/local/klaas/.czap/ziggo-channels.conf'
=A01 Cartoon:356000000:INVERSION_AUTO:6875000:FEC_NONE:QAM_64:1660:16=
21
Post by klaas de waal
=A01 Cartoon: f 356000000, s 6875000, i 2, fec 0, qam 3, v 0x67c, a 0=
x655
Post by klaas de waal
status 00 | signal 0000 | snr b7b7 | ber 000fffff | unc 00000098 |
status 1f | signal d5d5 | snr f3f3 | ber 000006c0 | unc 0000009b | FE=
_HAS_LOCK
Post by klaas de waal
status 1f | signal d5d5 | snr f4f4 | ber 00000000 | unc 00000000 | FE=
_HAS_LOCK
Post by klaas de waal
This is done on a Linux 2.6.32.2 kernel with a TT C-1501 DVB-C card.
---------------------------------------------------------------------=
----------------------
Post by klaas de waal
diff -r 61b72047a995 util/szap/czap.c
--- a/util/szap/czap.c =A0Sun Jan 17 17:03:27 2010 +0100
+++ b/util/szap/czap.c =A0Sun Jan 24 11:40:43 2010 +0100
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
=A0#include <sys/types.h>
=A0#include <sys/stat.h>
=A0#include <sys/ioctl.h>
There seems to be other instances where _GNU_SOURCE needs to be
defined, from a quick look. Care to send a patch against the entire
dvb-apps tree ?

Regards,
Manu
klaas de waal
2010-01-25 21:41:59 UTC
Permalink
Post by Manu Abraham
Hi Klaas,
Post by klaas de waal
The czap utility (dvb-apps/util/szap/czap.c) cannot scan the channel
configuration file when compiled on Fedora 12 with gcc-4.4.2.
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
reading channels from file '/local/klaas/.czap/ziggo-channels.conf'
=A01 Cartoon:356000000:INVERSION_AUTO:6875000:FEC_NONE:QAM_64:1660:1=
621
Post by Manu Abraham
Post by klaas de waal
ERROR: cannot parse service data
Problem is tha the "sscanf" function uses the "%a[^:]" format
specifier. According to "man sscanf" you need to define _GNU_SOURCE =
if
Post by Manu Abraham
Post by klaas de waal
you want this to work because it is a gnu-only extension.
Adding a first line "#define _GNU_SOURCE" to czap.c and recompiling
solves the problem.
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
reading channels from file '/local/klaas/.czap/ziggo-channels.conf'
=A01 Cartoon:356000000:INVERSION_AUTO:6875000:FEC_NONE:QAM_64:1660:1=
621
Post by Manu Abraham
Post by klaas de waal
=A01 Cartoon: f 356000000, s 6875000, i 2, fec 0, qam 3, v 0x67c, a =
0x655
Post by Manu Abraham
Post by klaas de waal
status 00 | signal 0000 | snr b7b7 | ber 000fffff | unc 00000098 |
status 1f | signal d5d5 | snr f3f3 | ber 000006c0 | unc 0000009b | F=
E_HAS_LOCK
Post by Manu Abraham
Post by klaas de waal
status 1f | signal d5d5 | snr f4f4 | ber 00000000 | unc 00000000 | F=
E_HAS_LOCK
Post by Manu Abraham
Post by klaas de waal
This is done on a Linux 2.6.32.2 kernel with a TT C-1501 DVB-C card.
--------------------------------------------------------------------=
-----------------------
Post by Manu Abraham
Post by klaas de waal
diff -r 61b72047a995 util/szap/czap.c
--- a/util/szap/czap.c =A0Sun Jan 17 17:03:27 2010 +0100
+++ b/util/szap/czap.c =A0Sun Jan 24 11:40:43 2010 +0100
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
=A0#include <sys/types.h>
=A0#include <sys/stat.h>
=A0#include <sys/ioctl.h>
There seems to be other instances where _GNU_SOURCE needs to be
defined, from a quick look. Care to send a patch against the entire
dvb-apps tree ?
Regards,
Manu
Hi Manu,

I did have a reasonably good look at the code and at the compilation
log created with "-pedantic" added to the CFLAGS but although there
are a lot of GNU extensions used I think they will compile correct. I
do not think that the _GNU_SOURCE definitions need to be added
anywhere.

Having said that, I am not even happy anymore with the _GNU_SOURCE in
czap.c although it does solve the problem.

I have now added "std=3Dgnu99 -Wformat" to the default CFLAGS in
Make.rules. This flags the use of the "a" format specifier as used in
the sscanf statement in czap.c as an error, although it works when
_GNU_SOURCE is defined.
I have now modified the czap.c to use the "m" format specifier which
does just what the 'a" used to do.
This works OK, it does not give compilation messages and it does not
require _GNU_SOURCE so I think it is a better solution. Hope you like
it.

Regards,
Klaas.

Signed-off-by: Klaas de Waal <***@gmail.com>

-----------------------------------------------------------------------=
--------------------

diff -r 61b72047a995 Make.rules
--- a/Make.rules Sun Jan 17 17:03:27 2010 +0100
+++ b/Make.rules Mon Jan 25 22:27:05 2010 +0100
@@ -1,6 +1,7 @@
# build rules for linuxtv.org dvb-apps

-CFLAGS ?=3D -g -Wall -W -Wshadow -Wpointer-arith -Wstrict-prototypes
+CFLAGS ?=3D -g -Wall -W -Wshadow -Wpointer-arith -Wstrict-prototypes \
+-std=3Dgnu99 -Wformat

ifneq ($(lib_name),)

diff -r 61b72047a995 util/szap/czap.c
--- a/util/szap/czap.c Sun Jan 17 17:03:27 2010 +0100
+++ b/util/szap/czap.c Mon Jan 25 22:27:05 2010 +0100
@@ -141,7 +141,7 @@
}
printf("%3d %s", chan_no, chan);

- if ((sscanf(chan, "%a[^:]:%d:%a[^:]:%d:%a[^:]:%a[^:]:%d:%d\n",
+ if ((sscanf(chan, "%m[^:]:%d:%m[^:]:%d:%m[^:]:%m[^:]:%d:%d\n",
&name, &frontend->frequency,
&inv, &frontend->u.qam.symbol_rate,
&fec, &mod, vpid, apid) !=3D 8)

Loading...