summaryrefslogtreecommitdiffstats
path: root/src/nolo.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-09-23 00:20:10 +0200
committerPali Rohár <pali.rohar@gmail.com>2012-09-23 00:20:10 +0200
commitc0e490cc3075f4719af27d9c50cc6c1a9e3275ab (patch)
tree1e33c09c59a00bfc44b1cfec4ee4d3cc4285d2f7 /src/nolo.c
parent15b05dce75b8a2195e5ba613e157fd308bc9f03f (diff)
download0xFFFF-c0e490cc3075f4719af27d9c50cc6c1a9e3275ab.tar.bz2
nolo: Implemented nolo_set_sw_ver
Diffstat (limited to 'src/nolo.c')
-rw-r--r--src/nolo.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/nolo.c b/src/nolo.c
index 6ac0233..f6d4ac0 100644
--- a/src/nolo.c
+++ b/src/nolo.c
@@ -729,8 +729,42 @@ int nolo_get_sw_ver(struct usb_device_info * dev, char * ver, size_t size) {
int nolo_set_sw_ver(struct usb_device_info * dev, const char * ver) {
- printf("nolo_set_sw_ver is not implemented yet\n");
- return -1;
+ char buf[512];
+ char * ptr;
+ uint8_t len;
+ const char * str = "OSSO UART+USB";
+
+ printf("Setting Software release string to: %s\n", ver);
+
+ if ( strlen(ver) > UINT8_MAX )
+ ERROR_RETURN("Software release string is too long", -1);
+
+ ptr = buf;
+
+ memcpy(ptr, "\xe8", 1);
+ ptr += 1;
+
+ len = strlen(str)+1;
+ memcpy(ptr, &len, 1);
+ ptr += 1;
+
+ memcpy(ptr, str, len);
+ ptr += len;
+
+ memcpy(ptr, "\x31", 1);
+ ptr += 1;
+
+ len = strlen(ver)+1;
+ memcpy(ptr, &len, 1);
+ ptr += 1;
+
+ memcpy(ptr, ver, len);
+ ptr += len;
+
+ if ( usb_control_msg(dev->udev, NOLO_WRITE, NOLO_SET_SW_RELEASE, 0, 0, buf, ptr-buf, 2000) < 0 )
+ ERROR_RETURN("NOLO_SET_SW_RELEASE failed", -1);
+
+ return 0;
}