From 14bab992742b4b1fa0bb1353c2b105dfcaa1caa9 Mon Sep 17 00:00:00 2001
From: "Paolo G. Giarrusso"
Date: Sat, 8 Aug 2020 16:31:38 +0200
Subject: [PATCH] smc: support writing FP values like fan speed
Needed to help with https://github.com/hholtmann/smcFanControl/issues/77.
---
smc-command/smc.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/smc-command/smc.c b/smc-command/smc.c
index 379c71d..284247b 100755
--- a/smc-command/smc.c
+++ b/smc-command/smc.c
@@ -648,6 +648,7 @@ void usage(char* prog)
printf(" -k : key to manipulate\n");
printf(" -l : list all keys and values\n");
printf(" -r : read the value of a key\n");
+ printf(" -p : write the specified integer value to a floating point key\n");
printf(" -w : write the specified value to a key\n");
printf(" -v : version\n");
printf("\n");
@@ -684,7 +685,7 @@ int main(int argc, char *argv[])
UInt32Char_t key = { 0 };
SMCVal_t val;
- while ((c = getopt(argc, argv, "fthk:lrw:v")) != -1)
+ while ((c = getopt(argc, argv, "fthk:lp:rw:v")) != -1)
{
switch(c)
{
@@ -708,6 +709,17 @@ int main(int argc, char *argv[])
printf("%s\n", VERSION);
return 0;
break;
+ case 'p':
+ op = OP_WRITE;
+ {
+ float fval;
+ fval = strtof(optarg, NULL);
+
+ val.dataSize = 4;
+ memcpy(val.bytes, &fval, sizeof(fval));
+ memcpy(val.dataType, DATATYPE_FLT, sizeof(val.dataType));
+ }
+ break;
case 'w':
op = OP_WRITE;
{