summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-09-23 12:24:09 +0200
committerPali Rohár <pali.rohar@gmail.com>2012-09-23 12:24:09 +0200
commit863cf8134a4eee1826fda5143b27e394f1dacbe1 (patch)
tree64981dc2f11ff52b2ce0d50ee2ff44bbb1b004c3 /src
parent6c220a45fdca707b4de05c941cca717c39d8ad5d (diff)
download0xFFFF-863cf8134a4eee1826fda5143b27e394f1dacbe1.tar.bz2
nolo_get_hwrev and nolo_set_hwrev - use int16_t
Diffstat (limited to 'src')
-rw-r--r--src/main.c11
-rw-r--r--src/nolo.c16
-rw-r--r--src/nolo.h4
3 files changed, 20 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index 7322857..87ce93f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -415,6 +415,7 @@ int main(int argc, char **argv) {
struct usb_device_info * usb_dev = NULL;
+ int tmp;
char buf[512];
simulate = 0;
@@ -958,9 +959,11 @@ int main(int argc, char **argv) {
else
printf("Device: %s\n", device_to_string(usb_dev->detected_device));
- buf[0] = 0;
- nolo_get_hwrev(usb_dev, buf, sizeof(buf));
- printf("HW revision: %s\n", buf[0] ? buf : "(not detected)");
+ tmp = nolo_get_hwrev(usb_dev);
+ if ( tmp <= 0 )
+ printf("HW revision: (not detected)\n");
+ else
+ printf("HW revision: %d\n", tmp);
if ( buf[0] )
usb_dev->detected_hwrev = atoi(buf);
@@ -1121,7 +1124,7 @@ int main(int argc, char **argv) {
if ( set_rd_flags )
nolo_set_rd_flags(usb_dev, set_rd_flags_arg);
if ( set_hw )
- nolo_set_hwrev(usb_dev, set_hw_arg);
+ nolo_set_hwrev(usb_dev, atoi(set_hw_arg));
if ( set_nolo )
nolo_set_nolo_ver(usb_dev, set_nolo_arg);
if ( set_kernel )
diff --git a/src/nolo.c b/src/nolo.c
index e398c24..a8e5ba9 100644
--- a/src/nolo.c
+++ b/src/nolo.c
@@ -680,16 +680,22 @@ int nolo_set_rd_flags(struct usb_device_info * dev, const char * flags) {
}
-int nolo_get_hwrev(struct usb_device_info * dev, char * hwrev, size_t size) {
+int16_t nolo_get_hwrev(struct usb_device_info * dev) {
- return nolo_identify_string(dev, "hw_rev", hwrev, size);
+ char buf[10];
+ if ( nolo_identify_string(dev, "hw_rev", buf, sizeof(buf)) <= 0 )
+ return -1;
+ return atoi(buf);
}
-int nolo_set_hwrev(struct usb_device_info * dev, const char * hwrev) {
+int nolo_set_hwrev(struct usb_device_info * dev, int16_t hwrev) {
- printf("Setting HW revision to: %s\n", hwrev);
- return nolo_set_string(dev, "hw_rev", (char *)hwrev);
+ char buf[9];
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, 8, "%d", hwrev);
+ printf("Setting HW revision to: %s\n", buf);
+ return nolo_set_string(dev, "hw_rev", buf);
}
diff --git a/src/nolo.h b/src/nolo.h
index 2f93153..f603895 100644
--- a/src/nolo.h
+++ b/src/nolo.h
@@ -44,8 +44,8 @@ int nolo_set_rd_mode(struct usb_device_info * dev, int enable);
int nolo_get_rd_flags(struct usb_device_info * dev, char * flags, size_t size);
int nolo_set_rd_flags(struct usb_device_info * dev, const char * flags);
-int nolo_get_hwrev(struct usb_device_info * dev, char * hwrev, size_t size);
-int nolo_set_hwrev(struct usb_device_info * dev, const char * hwrev);
+int16_t nolo_get_hwrev(struct usb_device_info * dev);
+int nolo_set_hwrev(struct usb_device_info * dev, int16_t hwrev);
int nolo_get_kernel_ver(struct usb_device_info * dev, char * ver, size_t size);
int nolo_set_kernel_ver(struct usb_device_info * dev, const char * ver);