[PATCH] Allow bccmd psset to get words along with bytes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello guys,

This patch allows bccmd psset input to be compatible with psget output, psget returns words not bytes, but when you want to get that back into psset it complains. This patch fixes the problem by allowing words to be input.

Here's the output that shows it works:

[root@laptop:bluez-4.61]$ tools/bccmd psset -r -s psi 0x0031 0x3714 0x0100 0x411e 0x7100 0x00f4 0x4410 0x0100 0x4123 0x7100 0x00f8 0x4e11 0x0100 0x4123 0x6100 0x00fc 0x5d10 0x0100 0x4123 0x5100 0x0000 0x6914 0x0100 0x4b23 0x4000 0x0004 0x7317 0x0100 0x4123 0x3000 0x000a 0x731c 0x0100 0x4123 0x2000 0x000e 0x7321 0x0100 0x4123 0x1000 0x0014

[root@laptop:bluez-4.61]$ tools/bccmd psget 0x0031
Radio power table: 0x3714 0x0100 0x411e 0x7100 0x00f4 0x4410 0x0100 0x4123 0x7100 0x00f8 0x4e11 0x0100 0x4123 0x6100 0x00fc 0x5d10 0x0100 0x4123 0x5100 0x0000 0x6914 0x0100 0x4b23 0x4000 0x0004 0x7317 0x0100 0x4123 0x3000 0x000a 0x731c 0x0100 0x4123 0x2000 0x000e 0x7321 0x0100 0x4123 0x1000 0x0014

Cheers,
Manuel
--- ../bluez-4.59/tools/bccmd.c	2009-02-01 23:30:43.000000000 -0200
+++ tools/bccmd.c	2010-03-29 16:47:04.000000000 -0300
@@ -823,16 +823,32 @@ static int cmd_psset(int transport, int 
 		break;
 
 	default:
-		if (argc != length * 2) {
+		if (argc != length * 2 && argc != length) {
 			errno = EINVAL;
 			return -1;
 		}
 
-		for (i = 0; i < length * 2; i++)
-			if (!strncasecmp(argv[0], "0x", 2))
+		if (argc == length * 2) {
+		    for (i = 0; i < length * 2; i++)
+			if (!strncasecmp(argv[0], "0x", 2)){
 				array[i + 6] = strtol(argv[i] + 2, NULL, 16);
+			}
 			else
 				array[i + 6] = atoi(argv[i]);
+		}
+		else {
+		    for (i = 0; i < length; i++){
+			uint16_t val = 0;
+
+			if (!strncasecmp(argv[0], "0x", 2))
+			    val = strtol(argv[i] + 2, NULL, 16);
+			else
+			    val = atoi(argv[i]);
+
+			array[i*2 + 7] = val % 0x100;
+			array[i*2 + 6] = (val / 0x100);
+		    }
+		}
 		break;
 	}
 

[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux