aboutsummaryrefslogtreecommitdiffstats
path: root/cphidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'cphidget.c')
-rw-r--r--cphidget.c59
1 files changed, 50 insertions, 9 deletions
diff --git a/cphidget.c b/cphidget.c
index a408210..88d5b95 100644
--- a/cphidget.c
+++ b/cphidget.c
@@ -692,6 +692,18 @@ CPhidget_getDeviceClass(CPhidgetHandle phid, CPhidget_DeviceClass *deviceClass)
}
int CCONV
+CPhidget_getUSBProductString(CPhidgetHandle phid, const char **buffer)
+{
+ TESTPTRS(phid, buffer)
+ if (!CPhidget_statusFlagIsSet(phid->status, PHIDGET_ATTACHED_FLAG)
+ && !CPhidget_statusFlagIsSet(phid->status, PHIDGET_DETACHING_FLAG))
+ return EPHIDGET_NOTATTACHED;
+
+ *buffer = (char *)phid->usbProduct;
+ return EPHIDGET_OK;
+}
+
+int CCONV
CPhidget_getDeviceLabel(CPhidgetHandle phid, const char **buffer)
{
TESTPTRS(phid, buffer)
@@ -731,11 +743,6 @@ CPhidget_setDeviceLabel(CPhidgetHandle phid, const char *buffer)
}
else
{
-
-#if 0// defined(_WINDOWS) && !defined(WINCE)
- //setLabel not supported on Windows only (Windows CE does support it)
- return EPHIDGET_UNSUPPORTED;
-#else
int len;
char buffer2[(MAX_LABEL_SIZE * 2) + 2];
ZEROMEM(buffer2, (MAX_LABEL_SIZE * 2) + 2);
@@ -829,9 +836,6 @@ CPhidget_setDeviceLabel(CPhidgetHandle phid, const char *buffer)
}
else
{
-#if defined(_WINDOWS) && !defined(WINCE)
- if(ret != EPHIDGET_UNSUPPORTED)
-#endif
LOG(PHIDGET_LOG_ERROR, "Something unexpected happened trying to set the label. Try again.");
return ret;
}
@@ -853,7 +857,6 @@ CPhidget_setDeviceLabel(CPhidgetHandle phid, const char *buffer)
buffer2[1] = 3;
CUSBSetLabel(phid, buffer2);
return ret;
-#endif
}
}
@@ -1694,6 +1697,8 @@ int deviceSupportsGeneralUSBProtocol(CPhidgetHandle phid)
case PHIDUID_SPATIAL_ACCEL_3AXIS_1043:
case PHIDUID_SPATIAL_ACCEL_GYRO_COMPASS_1042:
case PHIDUID_SPATIAL_ACCEL_GYRO_COMPASS_1044:
+ case PHIDUID_LED_64_ADV_M3:
+ case PHIDUID_RFID_2OUTPUT_ADVANCED:
return PTRUE;
case PHIDUID_FIRMWARE_UPGRADE:
@@ -1827,6 +1832,34 @@ int CCONV CPhidgetGPP_eraseFirmware(CPhidgetHandle phid)
return result;
}
+int CCONV CPhidgetGPP_eraseConfig(CPhidgetHandle phid)
+{
+ int result;
+ unsigned char *buffer;
+ TESTPTR(phid)
+ if (!CPhidget_statusFlagIsSet(phid->status, PHIDGET_ATTACHED_FLAG))
+ return EPHIDGET_NOTATTACHED;
+
+ if(!deviceSupportsGeneralUSBProtocol(phid))
+ return EPHIDGET_UNSUPPORTED;
+
+ buffer = (unsigned char *) malloc(phid->outputReportByteLength);
+ ZEROMEM(buffer, phid->outputReportByteLength);
+
+ buffer[0] = PHID_USB_GENERAL_PACKET_FLAG | PHID_USB_GENERAL_PACKET_ERASE_CONFIG;
+
+ CThread_mutex_lock(&phid->writelock);
+
+ phid->GPPResponse = 0;
+ if((result = CUSBSendPacket((CPhidgetHandle)phid, buffer)) == EPHIDGET_OK)
+ result = GPP_getResponse(phid, PHID_USB_GENERAL_PACKET_ERASE_CONFIG, 200);
+
+ CThread_mutex_unlock(&phid->writelock);
+ free(buffer);
+
+ return result;
+}
+
int CCONV CPhidgetGPP_reboot_firmwareUpgrade(CPhidgetHandle phid)
{
int result;
@@ -1843,6 +1876,14 @@ int CCONV CPhidgetGPP_reboot_firmwareUpgrade(CPhidgetHandle phid)
buffer[0] = PHID_USB_GENERAL_PACKET_FLAG | PHID_USB_GENERAL_PACKET_REBOOT_FIRMWARE_UPGRADE;
+ //Stop the read/write threads first
+ phid->writeStopFlag = PTRUE;
+ CThread_join(&phid->writeThread);
+ CPhidget_clearStatusFlag(&phid->status, PHIDGET_ATTACHED_FLAG, &phid->lock);
+ CThread_join(&phid->readThread);
+ CPhidget_setStatusFlag(&phid->status, PHIDGET_ATTACHED_FLAG, &phid->lock);
+
+ //Then send the command
result = CUSBSendPacket((CPhidgetHandle)phid, buffer);
free(buffer);