mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-21 19:42:24 +01:00
1cc202a987
Signed-off-by: Michiel van Wessem <michiel@slackbuilds.org>
70 lines
1.5 KiB
Diff
70 lines
1.5 KiB
Diff
--- temper-1.0/temper.c 2009-10-17 08:26:46.000000000 +0100
|
|
+++ temper-1.0.new/temper.c 2011-02-06 16:49:24.511084503 +0000
|
|
@@ -49,7 +49,7 @@
|
|
|
|
t = calloc(1, sizeof(*t));
|
|
t->device = dev;
|
|
- t->debug = debug;
|
|
+ t->debug = 0;
|
|
t->timeout = timeout;
|
|
t->handle = usb_open(t->device);
|
|
if(!t->handle) {
|
|
@@ -190,7 +190,7 @@
|
|
int
|
|
TemperGetTemperatureInC(Temper *t, float *tempC)
|
|
{
|
|
- char buf[256];
|
|
+ unsigned char buf[256];
|
|
int ret, temperature, i;
|
|
|
|
TemperSendCommand(t, 10, 11, 12, 13, 0, 0, 2, 0);
|
|
@@ -204,9 +204,7 @@
|
|
return -1;
|
|
}
|
|
|
|
- temperature = (buf[1] & 0xFF) + (buf[0] << 8);
|
|
- temperature += 1152; // calibration value
|
|
- *tempC = temperature * (125.0 / 32000.0);
|
|
+ *tempC=buf[0]+((float)buf[1])/256;
|
|
return 0;
|
|
}
|
|
|
|
@@ -253,29 +251,15 @@
|
|
TemperSendCommand(t, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
*/
|
|
|
|
- bzero(buf, 256);
|
|
- ret = TemperGetOtherStuff(t, buf, 256);
|
|
- printf("Other Stuff (%d bytes):\n", ret);
|
|
- for(i = 0; i < ret; i++) {
|
|
- printf(" %02x", buf[i] & 0xFF);
|
|
- if(i % 16 == 15) {
|
|
- printf("\n");
|
|
- }
|
|
- }
|
|
- printf("\n");
|
|
-
|
|
- for(;;) {
|
|
- float tempc;
|
|
-
|
|
- if(TemperGetTemperatureInC(t, &tempc) < 0) {
|
|
- perror("TemperGetTemperatureInC");
|
|
- exit(1);
|
|
- }
|
|
- printf("temperature %.2fF %.2fC\n", (9.0 / 5.0 * tempc + 32.0),
|
|
- tempc);
|
|
- sleep(10);
|
|
- }
|
|
- return 0;
|
|
+ float tempc;
|
|
+
|
|
+ if(TemperGetTemperatureInC(t, &tempc) < 0) {
|
|
+ perror("TemperGetTemperatureInC");
|
|
+ exit(1);
|
|
+ }
|
|
+ printf("temperature %.2fF %.2fC\n", (9.0 / 5.0 * tempc + 32.0),
|
|
+ tempc);
|
|
+ fflush(stdout); /* flush the stdout buffer */
|
|
}
|
|
|
|
#endif
|