From c0e490cc3075f4719af27d9c50cc6c1a9e3275ab Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sun, 23 Sep 2012 00:20:10 +0200 Subject: nolo: Implemented nolo_set_sw_ver --- src/nolo.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/nolo.c') 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; } -- cgit v1.2.3