2006-04-13 20:40:03

by Brand, Chris

[permalink] [raw]
Subject: [Bluez-users] Bccmd patch

I discovered a couple of things :
1. bccmd has some nice features that aren't mentioned in its "usages".
2. bccmd psset didn't work for keys with a size > 32 bits (because the
OPT_PSKEY macro returned an error if you specified more than one value
for the key, but it expected a list of bytes if the length is more than
1 or 2).
=20
Here's a patch (against bluez-utils version 2.25) :
--- bccmd.c.old 2006-04-08 00:01:10.000000000 +0000

+++ bccmd.c 2006-04-10 19:21:13.000000000 +0000

@@ -199,9 +209,9 @@

}

}

-#define OPT_RANGE(range) \

- if (argc < (range)) { errno =3D EINVAL; return -1; } \

- if (argc > (range)) { errno =3D E2BIG; return -1; }

+#define OPT_RANGE(min, max) \

+ if (argc < (min)) { errno =3D EINVAL; return -1; } \

+ if (argc > (max)) { errno =3D E2BIG; return -1; }

static struct option help_options[] =3D {

{ "help", 0, 0, 'h' },

@@ -227,7 +237,7 @@

#define OPT_HELP(range, help) \

opt_help(argc, argv, (help)); \

argc -=3D optind; argv +=3D optind; optind =3D 0; \

- OPT_RANGE((range))

+ OPT_RANGE((range), (range))

static int cmd_builddef(int transport, int argc, char *argv[])

{

@@ -510,10 +520,10 @@

return optind;

}

-#define OPT_PSKEY(range, stores, reset, help) \

+#define OPT_PSKEY(min, max, stores, reset, help) \

opt_pskey(argc, argv, (stores), (reset), (help)); \

argc -=3D optind; argv +=3D optind; optind =3D 0; \

- OPT_RANGE((range))

+ OPT_RANGE((min), (max))

static int cmd_psget(int transport, int argc, char *argv[])

{

@@ -524,7 +534,7 @@

memset(array, 0, sizeof(array));

- OPT_PSKEY(1, &stores, &reset, NULL);

+ OPT_PSKEY(1, 1, &stores, &reset, NULL);

if (strncasecmp(argv[0], "0x", 2)) {

pskey =3D atoi(argv[0]);

@@ -599,7 +609,7 @@

memset(array, 0, sizeof(array));

- OPT_PSKEY(2, &stores, &reset, NULL);

+ OPT_PSKEY(2, 81, &stores, &reset, NULL);

if (strncasecmp(argv[0], "0x", 2)) {

pskey =3D atoi(argv[0]);

@@ -702,7 +712,7 @@

uint16_t pskey, stores =3D CSR_STORES_PSRAM;

int i, err, reset =3D 0;

- OPT_PSKEY(1, &stores, &reset, NULL);

+ OPT_PSKEY(1, 1, &stores, &reset, NULL);

if (strncasecmp(argv[0], "0x", 2)) {

pskey =3D atoi(argv[0]);

@@ -739,7 +749,7 @@

uint16_t pskey =3D 0x0000, length, stores =3D CSR_STORES_DEFAULT;

int err, reset =3D 0;

- OPT_PSKEY(0, &stores, &reset, NULL);

+ OPT_PSKEY(0, 0, &stores, &reset, NULL);

while (1) {

memset(array, 0, sizeof(array));

@@ -785,7 +795,7 @@

char *str, val[7];

int i, err, reset =3D 0;

- OPT_PSKEY(0, &stores, &reset, NULL);

+ OPT_PSKEY(0, 0, &stores, &reset, NULL);

while (1) {

memset(array, 0, sizeof(array));

@@ -854,7 +864,7 @@

char *str, val[7];

int err, reset =3D 0;

- OPT_PSKEY(1, &stores, &reset, NULL);

+ OPT_PSKEY(1, 1, &stores, &reset, NULL);

psr_read(argv[0]);

@@ -933,13 +943,13 @@

{ "disabletx", cmd_disabletx, "", "Disable TX on the device" },

{ "enabletx", cmd_enabletx, "", "Enable TX on the device" },

{ "memtypes", cmd_memtypes, NULL, "Get memory types" },

- { "psget", cmd_psget, "<key>", "Get value for PS key" },

- { "psset", cmd_psset, "<key> <value>", "Set value for PS key" },

- { "psclr", cmd_psclr, "<key>", "Clear value for PS key" },

- { "pslist", cmd_pslist, NULL, "List all PS keys" },

- { "psread", cmd_psread, NULL, "Read all PS keys" },

- { "psload", cmd_psload, "<file>", "Load all PS keys from PSR file" },

- { "pscheck", cmd_pscheck, "<file>", "Check PSR file" },

+ { "psget", cmd_psget, "[-r] [-s <store>] <key>", "Get value for PS
key" },

+ { "psset", cmd_psset, "[-r] [-s <store>] <key> <value>", "Set value
for PS key" },

+ { "psclr", cmd_psclr, "[-r] [-s <store>] <key>", "Clear value for PS
key" },

+ { "pslist", cmd_pslist, "[-r] [-s <store>]", "List all PS keys" },

+ { "psread", cmd_psread, "[-r] [-s <store>]", "Read all PS keys" },

+ { "psload", cmd_psload, "[-r] [-s <store>] <file>", "Load all PS keys
from PSR file" },

+ { "pscheck", cmd_pscheck, "[-r] [-s <store>] <file>", "Check PSR file"
},

{ NULL }

};

@@ -977,6 +987,7 @@

}

}

printf("\n");

+ printf("\tor by hex value\n");

}

static struct option main_options[] =3D {


--=20
Chris Brand
Senior Software Engineer
WideRay
604-233-1105
=20


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users


2006-06-26 12:23:19

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-users] Bccmd patch

Hi Chris,

> I would have thought that it should be in both the manpage and the
> usage.

the bccmd is a dangerous tool and I prefer people think twice before
they actually use it. So they have at least to read the manual page
first before they are going to render their devices useless.

> > Please update the manpage to include them there.
>
> Patch attached (against 3.1).

The patch has been applied to the CVS. Do you mind adding some
explanation of the possible stores shortcuts?

Regards

Marcel



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2006-06-20 12:08:07

by Sumeet VERMA

[permalink] [raw]
Subject: Re: [Bluez-users] Bccmd patch

Hi Marcel
I am unable to access CVS from my PC. Is there some other way to download
the package which does not have a check for dbus.

Thanks in Advance,

Sumeet



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Marcel
Holtmann
Sent: Tuesday, June 20, 2006 3:20 PM
To: BlueZ users
Subject: Re: [Bluez-users] Bccmd patch


Hi Chris,

> > please create a patch against the latest CVS (or
> > bluez-utils-3.1) and attach it.
>
> Here it is against bluez-utils-3.1

I applied the OPT_RANGE changes, but I didn't apply the usage() change.
Please update the manpage to include them there. It is a better place.

Regards

Marcel




_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users



_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2006-06-20 09:50:13

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-users] Bccmd patch

Hi Chris,

> > please create a patch against the latest CVS (or
> > bluez-utils-3.1) and attach it.
>
> Here it is against bluez-utils-3.1

I applied the OPT_RANGE changes, but I didn't apply the usage() change.
Please update the manpage to include them there. It is a better place.

Regards

Marcel




_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

2006-06-19 18:09:04

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-users] Bccmd patch

Hi Chris,

> I didn't see any response to this patch - resending to ensure that it
> didn't get missed.
>
> I discovered a couple of things :
> 1. bccmd has some nice features that aren't mentioned in its "usages".
> 2. bccmd psset didn't work for keys with a size > 32 bits (because the
> OPT_PSKEY macro returned an error if you specified more than one value
> for the key, but it expected a list of bytes if the length is more than
> 1 or 2).
>
> Here's a patch (against bluez-utils version 2.25) :

please create a patch against the latest CVS (or bluez-utils-3.1) and
attach it. Your mail client is messing up whitespaces and newlines.

Regards

Marcel




_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users