Library to allo USB PTP device to be hosted by the mbed platform
Dependents: class_project_main
Diff: USBHostPTP.cpp
- Revision:
- 11:3b072cf16df8
- Parent:
- 10:fc1cb68fc91e
--- a/USBHostPTP.cpp Wed Sep 18 01:48:07 2013 +0000 +++ b/USBHostPTP.cpp Mon Oct 07 04:45:55 2013 +0000 @@ -43,6 +43,7 @@ commandContainer.type = PIMA_CONTAINER_COMMAND; sessionID = 1; dataLeftToTransfer = 0; + CodeDecoderFunction = NULL; memset(buffer,0,1024); } @@ -757,10 +758,10 @@ } void USBHostPTP::ParseDevicePropDescrBlock(void *ptp,uint8_t *buffer,uint16_t length){ - PIMAPropDescr *temp; + //PIMAPropDescr *temp; - temp= new PIMAPropDescr; - temp.fill(buffer); + //temp= new PIMAPropDescr; + //temp.fill(buffer); } @@ -792,6 +793,19 @@ printf("\r\n"); } +void USBHostPTP::PrintCodeInformation(uint16_t value){ + char stringValue[80]; + bool found=false; + + if( CodeDecoderFunction != NULL) { + found = (*CodeDecoderFunction)(value,stringValue); + } + if (found) { + printf("0x%04x: %s\r\n",value,stringValue); + } else { + printf("0x%04x: (Unknown)\r\n",value); + } +} void USBHostPTP::DumpDeviceInfo(){ int i; @@ -802,26 +816,26 @@ printf("Vendor Extension Description: \r\n"); printf("%s\r\n",(deviceInfo.vendorExtensionDesc.getString())); printf("Functional Mode: %x\r\n",deviceInfo.functionMode); - printf("Supported Operations: \r\n"); + printf("<<< Supported Operations: >>>\r\n"); for(i=0;i<deviceInfo.operationsSupported.numberOfElements;i++) { - printf("0x%04x\r\n",deviceInfo.operationsSupported.GetElement(i)); + PrintCodeInformation(deviceInfo.operationsSupported.GetElement(i)); + } + printf("<<< Supported Events: >>>\r\n"); + for(i=0;i<deviceInfo.eventsSupported.numberOfElements;i++) { + PrintCodeInformation(deviceInfo.eventsSupported.GetElement(i)); } - printf("Supported Events: \r\n"); - for(i=0;i<deviceInfo.eventsSupported.numberOfElements;i++) { - printf("0x%04x\r\n",deviceInfo.eventsSupported.GetElement(i)); - } - printf("Supported Device Properties: \r\n"); + printf("<<< Supported Device Properties: >>>\r\n"); for(i=0;i<deviceInfo.devicePropertiesSupported.numberOfElements;i++) { - printf("0x%04x\r\n",deviceInfo.devicePropertiesSupported.GetElement(i)); + PrintCodeInformation(deviceInfo.devicePropertiesSupported.GetElement(i)); } - printf("Supported Capture Formats: \r\n"); + printf("<<< Supported Capture Formats: >>>\r\n"); for(i=0;i<deviceInfo.captureFormats.numberOfElements;i++) { - printf("0x%04x\r\n",deviceInfo.captureFormats.GetElement(i)); + PrintCodeInformation(deviceInfo.captureFormats.GetElement(i)); } - printf("Supported Image Formats: \r\n"); + printf("<<< Supported Image Formats: >>>\r\n"); for(i=0;i<deviceInfo.imageFormats.numberOfElements;i++) { - printf("0x%04x\r\n",deviceInfo.imageFormats.GetElement(i)); - } + PrintCodeInformation(deviceInfo.imageFormats.GetElement(i)); + } printf("Manufacturer: \r\n"); printf("%s\r\n",deviceInfo.manufacturer.getString()); @@ -882,3 +896,4 @@ +