Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
e9c521c0e4 | |||
ed51155640 | |||
9d010120d5 | |||
5d15838757 |
142
Cargo.lock
generated
142
Cargo.lock
generated
@ -3,37 +3,47 @@
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.59.2"
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"peeking_take_while",
|
||||
"itertools",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.73"
|
||||
version = "1.1.30"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
|
||||
checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -47,52 +57,55 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.3.3"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b"
|
||||
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.0"
|
||||
name = "either"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.24"
|
||||
version = "0.1.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
|
||||
checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.126"
|
||||
version = "0.2.159"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
|
||||
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
@ -102,58 +115,66 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.1"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "peeking_take_while"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.25"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
|
||||
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.40"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7"
|
||||
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.20"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.6.0"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
||||
checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.27"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
||||
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
@ -173,12 +194,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.1.0"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.2"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7"
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
|
@ -8,6 +8,6 @@ build = "build.rs"
|
||||
libc = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
cc = { version = "1.0", features = ["parallel"] }
|
||||
bindgen = { version = "0.59", default-features = false}
|
||||
cc = { version = "1.1", features = ["parallel"] }
|
||||
bindgen = { version = "0.70", default-features = false }
|
||||
pkg-config = "0.3"
|
||||
|
12
build.rs
12
build.rs
@ -1,8 +1,8 @@
|
||||
extern crate bindgen;
|
||||
use cc;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=src/pcsensor.c");
|
||||
@ -14,7 +14,7 @@ fn main() {
|
||||
fn bind() {
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("/usr/include/libusb-1.0/libusb.h")
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
@ -26,10 +26,10 @@ fn bind() {
|
||||
|
||||
fn compile_pcsensor() {
|
||||
cc::Build::new()
|
||||
.file("src/pcsensor.c")
|
||||
.shared_flag(true)
|
||||
.static_flag(true)
|
||||
.compile("pcsensor");
|
||||
.file("src/pcsensor.c")
|
||||
.shared_flag(true)
|
||||
.static_flag(true)
|
||||
.compile("pcsensor");
|
||||
}
|
||||
|
||||
fn link() {
|
||||
|
106
src/pcsensor.c
106
src/pcsensor.c
@ -22,6 +22,7 @@ typedef struct {
|
||||
const int has_sensor; // number of temperature sensor
|
||||
const int has_humid; // flag for humidity sensor
|
||||
void (*decode_func)();
|
||||
float divisor;
|
||||
} temper_type_t;
|
||||
|
||||
typedef struct {
|
||||
@ -29,15 +30,24 @@ typedef struct {
|
||||
temper_type_t *type;
|
||||
} temper_device_t;
|
||||
|
||||
void decode_answer_fm75();
|
||||
void decode_answer_sht1x();
|
||||
void decode_answer();
|
||||
|
||||
#define TEMPER_TYPES 4
|
||||
|
||||
const char GetFirmware[8] = { 0x01, 0x86, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00 };
|
||||
const char GetTemperature[8] = { 0x01, 0x80, 0x33, 0x01, 0x00, 0x00, 0x00, 0x00 };
|
||||
//#define Temperature { 0x01, 0x82, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00 }
|
||||
|
||||
//const char uTemperature1[8] = { 0x01, 0x80, 0x33, 0x01, 0x00, 0x00, 0x00, 0x00 };
|
||||
//const char uTemperature2[8] = { 0x01, 0x82, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00 };
|
||||
//const char uTemperature3[8] = { 0x01, 0x86, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
#define TEMPER_TYPES 3
|
||||
|
||||
temper_type_t tempers[TEMPER_TYPES] = {
|
||||
{0x0c45, 0x7401, "TEMPer2", 1, 2, 0, decode_answer_fm75}, // TEMPer2* eg. TEMPer2V1.3
|
||||
{0x0c45, 0x7401, "TEMPer1", 0, 1, 0, decode_answer_fm75}, // other 0c45:7401 eg. TEMPerV1.4
|
||||
{0x0c45, 0x7402, "TEMPerHUM", 0, 1, 1, decode_answer_sht1x},
|
||||
{0x1a86, 0xe025, "TEMPerGold", 1, 1, 0, decode_answer, 100.0},
|
||||
{0x0c45, 0x7401, "TEMPer2", 1, 2, 0, decode_answer, 256.0},
|
||||
{0x0c45, 0x7401, "TEMPer1", 0, 1, 0, decode_answer, 256.0},
|
||||
//{0x0c45, 0x7402, "TEMPerHUM", 0, 1, 1, decode_answer_sht1x, 100.0},
|
||||
};
|
||||
|
||||
/* memo: TEMPer2 cannot be distinguished with VID:PID,
|
||||
@ -51,12 +61,9 @@ temper_type_t tempers[TEMPER_TYPES] = {
|
||||
#define INTERFACE2 0x01
|
||||
|
||||
const int reqIntLen = 8;
|
||||
const int endpoint_Int_in = 0x82; /* endpoint 0x81 address for IN */
|
||||
const int timeout = 5000; /* timeout in ms */
|
||||
|
||||
const char uTemperature[] = {0x01, 0x80, 0x33, 0x01, 0x00, 0x00, 0x00, 0x00};
|
||||
//const static char uIni1[] = { 0x01, 0x82, 0x77, 0x01, 0x00, 0x00, 0x00, 0x00 };
|
||||
//const static char uIni2[] = { 0x01, 0x86, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00 };
|
||||
const int endpoint_Int_out = 0x02;
|
||||
const int endpoint_Int_in = 0x82;
|
||||
const int timeout = 300; /* timeout in ms */
|
||||
|
||||
static int bsalir = 1;
|
||||
static int debug = 0;
|
||||
@ -156,7 +163,6 @@ int find_lvr_winusb(temper_device_t *devices) {
|
||||
}
|
||||
|
||||
int setup_libusb_access(temper_device_t *devices) {
|
||||
int i;
|
||||
int log_level = 0;
|
||||
int numdev;
|
||||
|
||||
@ -176,10 +182,10 @@ int setup_libusb_access(temper_device_t *devices) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < numdev; i++) {
|
||||
for (int i = 0; i < numdev; i++) {
|
||||
usb_detach(devices[i].handle, INTERFACE1);
|
||||
usb_detach(devices[i].handle, INTERFACE2);
|
||||
libusb_reset_device(devices[i].handle);
|
||||
//libusb_reset_device(devices[i].handle);
|
||||
|
||||
if (libusb_set_configuration(devices[i].handle, 0x01) < 0) {
|
||||
fprintf(stderr, "Could not set configuration 1\n");
|
||||
@ -201,25 +207,6 @@ int setup_libusb_access(temper_device_t *devices) {
|
||||
return numdev;
|
||||
}
|
||||
|
||||
void ini_control_transfer(libusb_device_handle *dev) {
|
||||
int r, i;
|
||||
|
||||
char question[reqIntLen];
|
||||
question[0] = 0x01;
|
||||
question[1] = 0x01;
|
||||
|
||||
r = libusb_control_transfer(dev, 0x21, 0x09, 0x0201, 0x00, (unsigned char *)question, 2, timeout);
|
||||
if (r < 0) {
|
||||
perror("USB control write");
|
||||
bad("USB write failed");
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
for (i = 0; i < reqIntLen; i++) fprintf(stderr, "%02x ", question[i] & 0xFF);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void control_transfer(libusb_device_handle *dev, const char *pquestion) {
|
||||
int r, i;
|
||||
|
||||
@ -230,7 +217,7 @@ void control_transfer(libusb_device_handle *dev, const char *pquestion) {
|
||||
r = libusb_control_transfer(dev, 0x21, 0x09, 0x0200, 0x01, (unsigned char *)question, reqIntLen, timeout);
|
||||
if (r < 0) {
|
||||
perror("USB control write");
|
||||
bad("USB write failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
@ -240,15 +227,25 @@ void control_transfer(libusb_device_handle *dev, const char *pquestion) {
|
||||
}
|
||||
}
|
||||
|
||||
void interrupt_read(libusb_device_handle *dev, unsigned char *answer) {
|
||||
void interrupt_read(libusb_device_handle *dev, unsigned char *answer, const char *pquestion, const char *product_name) {
|
||||
int r, s, i;
|
||||
char question[reqIntLen];
|
||||
|
||||
memset(answer, 0, reqIntLen);
|
||||
memcpy(question, pquestion, sizeof question);
|
||||
|
||||
s = libusb_interrupt_transfer(dev, endpoint_Int_in, answer, reqIntLen, &r, timeout);
|
||||
if (r != reqIntLen) {
|
||||
fprintf(stderr, "USB read failed: %d\n", s);
|
||||
|
||||
if (strcmp(product_name, "TEMPerGold") == 0) {
|
||||
libusb_interrupt_transfer(dev, endpoint_Int_out, (unsigned char *)question, reqIntLen, &r, timeout);
|
||||
s = libusb_interrupt_transfer(dev, endpoint_Int_in, answer, reqIntLen, &r, timeout);
|
||||
}
|
||||
|
||||
if (s != 0) {
|
||||
fprintf(stderr, "USB read failed: %s\n", libusb_error_name(s));
|
||||
perror("USB interrupt read");
|
||||
bad("USB read failed");
|
||||
exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
@ -260,13 +257,13 @@ void interrupt_read(libusb_device_handle *dev, unsigned char *answer) {
|
||||
}
|
||||
|
||||
void cleanup_usb_devices(temper_device_t *devices, int numdev) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numdev; i++)
|
||||
{
|
||||
for (int i = 0; i < numdev; i++) {
|
||||
libusb_release_interface(devices[i].handle, INTERFACE1);
|
||||
libusb_release_interface(devices[i].handle, INTERFACE2);
|
||||
|
||||
libusb_attach_kernel_driver(devices[i].handle, INTERFACE1);
|
||||
libusb_attach_kernel_driver(devices[i].handle, INTERFACE2);
|
||||
|
||||
libusb_close(devices[i].handle);
|
||||
}
|
||||
|
||||
@ -279,24 +276,22 @@ void ex_program() {
|
||||
(void)signal(SIGINT, SIG_DFL);
|
||||
}
|
||||
|
||||
/* decode funcs */
|
||||
/* Thanks to https://github.com/edorfaus/TEMPered */
|
||||
|
||||
void decode_answer_fm75(unsigned char *answer, float *tempd, float *calibration) {
|
||||
void decode_answer(unsigned char *answer, float *divisor, float *tempd, float *calibration) {
|
||||
int buf;
|
||||
|
||||
// temp C internal
|
||||
buf = ((signed char)answer[2] << 8) + (answer[3] & 0xFF);
|
||||
tempd[0] = buf * (125.0 / 32000.0);
|
||||
tempd[0] = buf / *divisor;
|
||||
tempd[0] = tempd[0] * calibration[0] + calibration[1];
|
||||
|
||||
// temp C external
|
||||
buf = ((signed char)answer[4] << 8) + (answer[5] & 0xFF);
|
||||
tempd[1] = buf * (125.0 / 32000.0);
|
||||
tempd[1] = buf / *divisor;
|
||||
tempd[1] = tempd[1] * calibration[0] + calibration[1];
|
||||
}
|
||||
|
||||
void decode_answer_sht1x(unsigned char *answer, float *tempd, float *calibration) {
|
||||
/*
|
||||
void decode_answer_sht1x(unsigned char *answer, float *divisor, float *tempd, float *calibration) {
|
||||
int buf;
|
||||
|
||||
// temp C
|
||||
@ -313,10 +308,12 @@ void decode_answer_sht1x(unsigned char *answer, float *tempd, float *calibration
|
||||
if (tempd[1] > 99)
|
||||
tempd[1] = 100;
|
||||
}
|
||||
*/
|
||||
|
||||
float get_temp_c() {
|
||||
temper_device_t *devices;
|
||||
int numdev, i;
|
||||
int numdev;
|
||||
int i = 0;
|
||||
unsigned char *answer;
|
||||
float tempd[2];
|
||||
float calibration[2] = {1, 0};
|
||||
@ -330,10 +327,9 @@ float get_temp_c() {
|
||||
|
||||
answer = calloc(reqIntLen, sizeof(unsigned char));
|
||||
|
||||
i = 0;
|
||||
control_transfer(devices[i].handle, uTemperature);
|
||||
interrupt_read(devices[i].handle, answer);
|
||||
devices[i].type->decode_func(answer, tempd, calibration);
|
||||
control_transfer(devices[i].handle, GetTemperature);
|
||||
interrupt_read(devices[i].handle, answer, GetTemperature, devices[i].type->product_name);
|
||||
devices[i].type->decode_func(answer, &devices[i].type->divisor, tempd, calibration);
|
||||
|
||||
cleanup_usb_devices(devices, numdev);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user