Unify a bunch of debug fail messages to a single point. More needed.

This commit is contained in:
Andrew J. Kroll 2013-03-30 10:29:16 -04:00
parent 904f2ff25a
commit 5ec8889fa3
15 changed files with 148 additions and 153 deletions

36
BTD.cpp
View file

@ -143,7 +143,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* We only need the Control endpoint, so we don't have to initialize the other endpoints of device */
rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, 1);
if (rcode)
goto FailSetConf;
goto FailSetConfDescr;
if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
#ifdef DEBUG
@ -193,7 +193,7 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
// Set Configuration Value
rcode = pUsb->setConf(bAddress, epInfo[ BTD_CONTROL_PIPE ].epAddr, bConfNum);
if (rcode)
goto FailSetConf;
goto FailSetConfDescr;
hci_num_reset_loops = 100; // only loop 100 times before trying to send the hci reset command
hci_counter = 0;
@ -209,40 +209,30 @@ uint8_t BTD::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */
FailGetDevDescr:
#ifdef DEBUG
Notify(PSTR("\r\ngetDevDescr"), 0x80);
#endif
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
#ifdef DEBUG
Notify(PSTR("\r\nsetDevTblEn"), 0x80);
#endif
NotifyFailSetDevTblEntry();
goto Fail;
FailGetConfDescr:
#ifdef DEBUG
Notify(PSTR("\r\ngetConf"), 0x80);
#endif
NotifyFailGetConfDescr();
goto Fail;
FailSetConf:
#ifdef DEBUG
Notify(PSTR("\r\nsetConf"), 0x80);
#endif
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail;
FailUnknownDevice:
#ifdef DEBUG
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
#endif
NotifyFailUnknownDevice(VID,PID);
pUsb->setAddr(bAddress, 0, 0); // Reset address
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
goto Fail;
Fail:
#ifdef DEBUG
Notify(PSTR("\r\nBTD Init Failed, error code: "), 0x80);
Serial.print(rcode);
#endif
NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -187,7 +187,7 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, epInfo[ PS3_CONTROL_PIPE ].epAddr, 1);
if (rcode)
goto FailSetConf;
goto FailSetConfDescr;
if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
if (PID == PS3_PID) {
@ -232,34 +232,25 @@ uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */
FailGetDevDescr:
#ifdef DEBUG
Notify(PSTR("\r\ngetDevDescr:"), 0x80);
#endif
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
#ifdef DEBUG
Notify(PSTR("\r\nsetDevTblEn:"), 0x80);
#endif
NotifyFailSetDevTblEntry();
goto Fail;
FailSetConf:
#ifdef DEBUG
Notify(PSTR("\r\nsetConf:"), 0x80);
#endif
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail;
FailUnknownDevice:
#ifdef DEBUG
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
#endif
NotifyFailUnknownDevice(VID,PID);
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
goto Fail;
Fail:
#ifdef DEBUG
Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
Serial.print(rcode, HEX);
#endif
NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -207,7 +207,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1);
if (rcode)
goto FailSetConf;
goto FailSetConfDescr;
#ifdef DEBUG
Notify(PSTR("\r\nXbox Wireless Receiver Connected\r\n"), 0x80);
@ -218,34 +218,26 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */
FailGetDevDescr:
#ifdef DEBUG
Notify(PSTR("\r\ngetDevDescr:"), 0x80);
#endif
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
#ifdef DEBUG
Notify(PSTR("\r\nsetDevTblEn:"), 0x80);
#endif
NotifyFailSetDevTblEntry();
goto Fail;
FailSetConf:
#ifdef DEBUG
Notify(PSTR("\r\nsetConf:"), 0x80);
#endif
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail;
FailUnknownDevice:
#ifdef DEBUG
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
#endif
NotifyFailUnknownDevice(VID,PID);
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
goto Fail;
Fail:
#ifdef DEBUG
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
Serial.print(rcode, HEX);
#endif
NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -171,7 +171,7 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1);
if (rcode)
goto FailSetConf;
goto FailSetConfDescr;
#ifdef DEBUG
Notify(PSTR("\r\nXbox 360 Controller Connected\r\n"), 0x80);
@ -183,34 +183,25 @@ uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */
FailGetDevDescr:
#ifdef DEBUG
Notify(PSTR("\r\ngetDevDescr:"), 0x80);
#endif
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
#ifdef DEBUG
Notify(PSTR("\r\nsetDevTblEn:"), 0x80);
#endif
NotifyFailSetDevTblEntry();
goto Fail;
FailSetConf:
#ifdef DEBUG
Notify(PSTR("\r\nsetConf:"), 0x80);
#endif
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail;
FailUnknownDevice:
#ifdef DEBUG
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
#endif
NotifyFailUnknownDevice(VID,PID);
rcode = USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED;
goto Fail;
Fail:
#ifdef DEBUG
Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
Serial.print(rcode, HEX);
#endif
NotifyFail(rcode);
Release();
return rcode;
}

25
adk.cpp
View file

@ -176,7 +176,7 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
// Set Configuration Value
rcode = pUsb->setConf(bAddress, 0, bConfNum);
if (rcode) {
goto FailSetConf;
goto FailSetConfDescr;
}
/* print endpoint structure */
// USBTRACE("\r\nEndpoint Structure:");
@ -227,11 +227,19 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
/* diagnostic messages */
FailGetDevDescr:
USBTRACE("\r\ngetDevDescr:");
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
USBTRACE("\r\nsetDevTblEn:");
NotifyFailSetDevTblEntry();
goto Fail;
FailGetConfDescr:
NotifyFailGetConfDescr();
goto Fail;
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail;
FailGetProto:
@ -244,22 +252,15 @@ FailSwAcc:
SwAttempt:
USBTRACE("\r\nAccessory mode switch attempt");
goto Fail;
// goto Fail;
FailGetConfDescr:
// USBTRACE("getConf:");
goto Fail;
//
FailSetConf:
// USBTRACE("setConf:");
goto Fail;
//
//FailOnInit:
// USBTRACE("OnInit:");
// goto Fail;
//
Fail:
//USBTRACE2("\r\nADK Init Failed, error code: ", rcode);
//NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -165,7 +165,7 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, 0, bConfNum);
if (rcode)
goto FailSetConf;
goto FailSetConfDescr;
rcode = pAsync->OnInit(this);
@ -180,29 +180,26 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0;
FailGetDevDescr:
USBTRACE("getDevDescr:");
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
USBTRACE("setDevTblEn:");
NotifyFailSetDevTblEntry();
goto Fail;
FailGetConfDescr:
USBTRACE("getConf:");
NotifyFailGetConfDescr();
goto Fail;
FailSetConf:
USBTRACE("setConf:");
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail;
FailOnInit:
USBTRACE("OnInit:");
goto Fail;
Fail:
PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\r\n"), 0x80);
// Serial.println(rcode, HEX);
NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -178,29 +178,26 @@ uint8_t FTDI::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0;
FailGetDevDescr:
USBTRACE("getDevDescr:");
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
USBTRACE("setDevTblEn:");
NotifyFailSetDevTblEntry();
goto Fail;
FailGetConfDescr:
USBTRACE("getConf:");
NotifyFailGetConfDescr();
goto Fail;
FailSetConfDescr:
USBTRACE("setConf:");
NotifyFailSetConfDescr();
goto Fail;
FailOnInit:
USBTRACE("OnInit:");
goto Fail;
Fail:
PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\r\n"), 0x80);
//Serial.println(rcode, HEX);
NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -155,29 +155,26 @@ uint8_t PL2303::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0;
FailGetDevDescr:
USBTRACE("getDevDescr:");
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
USBTRACE("setDevTblEn:");
NotifyFailSetDevTblEntry();
goto Fail;
FailGetConfDescr:
USBTRACE("getConf:");
NotifyFailGetConfDescr();
goto Fail;
FailSetConfDescr:
USBTRACE("setConf:");
NotifyFailSetConfDescr();
goto Fail;
FailOnInit:
USBTRACE("OnInit:");
goto Fail;
Fail:
PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\r\n"), 0x80);
//Serial.println(rcode, HEX);
NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -390,17 +390,22 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed
return 0;
FailGetDevDescr:
USBTRACE("getDevDescr:");
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
USBTRACE("setDevTblEn:");
NotifyFailSetDevTblEntry();
goto Fail;
FailGetConfDescr:
USBTRACE("getConf:");
NotifyFailGetConfDescr();
goto Fail;
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail;
FailSetProtocol:
USBTRACE("SetProto:");
goto Fail;
@ -409,14 +414,8 @@ FailSetIdle:
USBTRACE("SetIdle:");
goto Fail;
FailSetConfDescr:
USBTRACE("setConf:");
goto Fail;
Fail:
PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\n"), 0x80);
// Serial.println(rcode, HEX);
NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -221,29 +221,27 @@ uint8_t HIDUniversal::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0;
FailGetDevDescr:
USBTRACE("getDevDescr:");
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
USBTRACE("setDevTblEn:");
NotifyFailSetDevTblEntry();
goto Fail;
FailGetConfDescr:
USBTRACE("getConf:");
NotifyFailGetConfDescr();
goto Fail;
FailSetConfDescr:
USBTRACE("setConf:");
NotifyFailSetConfDescr();
goto Fail;
FailSetIdle:
USBTRACE("SetIdle:");
goto Fail;
Fail:
PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\r\n"), 0x80);
//Serial.println(rcode, HEX);
NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -1,3 +1,4 @@
#include "message.h"
#include "masstorage.h"
const uint8_t BulkOnly::epDataInIndex = 1;
const uint8_t BulkOnly::epDataOutIndex = 2;
@ -160,7 +161,7 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) {
rcode = pUsb->setConf(bAddress, 0, bConfNum);
if (rcode)
goto FailSetConf;
goto FailSetConfDescr;
delay(10000);
@ -280,19 +281,19 @@ uint8_t BulkOnly::Init(uint8_t parent, uint8_t port, bool lowspeed) {
return 0;
FailGetDevDescr:
USBTRACE("getDevDescr:");
NotifyFailGetDevDescr();
goto Fail;
FailSetDevTblEntry:
USBTRACE("setDevTblEn:");
NotifyFailSetDevTblEntry();
goto Fail;
FailGetConfDescr:
USBTRACE("getConf:");
NotifyFailGetConfDescr();
goto Fail;
FailSetConf:
USBTRACE("setConf:");
FailSetConfDescr:
NotifyFailSetConfDescr();
goto Fail;
FailOnInit:
@ -325,12 +326,9 @@ FailModeSense0:
FailModeSense1:
USBTRACE("ModeSense1:");
goto Fail;
Fail:
PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\r\n"), 0x80);
//Serial.println(rcode, HEX);
NotifyFail(rcode);
Release();
return rcode;
}

View file

@ -45,3 +45,32 @@ void NotifyStr(char const * msg, int lvl) {
while (c = *msg++) Notifyc(c, lvl);
}
#ifdef DEBUG
void NotifyFailGetDevDescr(void) {
Notify(PSTR("\r\ngetDevDescr"), 0x80);
}
void NotifyFailSetDevTblEntry(void) {
Notify(PSTR("\r\nsetDevTblEn"), 0x80);
}
void NotifyFailGetConfDescr(void) {
Notify(PSTR("\r\ngetConf"), 0x80);
}
void NotifyFailSetConf(void) {
Notify(PSTR("\r\nsetConf"), 0x80);
}
void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID) {
Notify(PSTR("\r\nUnknown Device Connected - VID: "), 0x80);
PrintHex<uint16_t > (VID, 0x80);
Notify(PSTR(" PID: "), 0x80);
PrintHex<uint16_t > (PID, 0x80);
}
void NotifyFail(uint8_t rcode) {
PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\r\n"), 0x80);
}
#endif

View file

@ -22,11 +22,25 @@ e-mail : support@circuitsathome.com
void Notify(char const * msg, int lvl);
void NotifyStr(char const * msg, int lvl);
#ifdef DEBUG
void NotifyFailGetDevDescr(void);
void NotifyFailSetDevTblEntry(void);
void NotifyFailGetConfDescr(void);
void NotifyFailSetConfDescr(void);
void NotifyFailUnknownDevice(uint16_t VID, uint16_t PID);
void NotifyFail(uint8_t rcode);
#else
#define NotifyFailGetDevDescr()
#define NotifyFailSetDevTblEntry()
#define NotifyFailGetConfDescr()
#define NotifyFailSetConfDescr()
#define NotifyFailUnknownDevice(VID, PID)
#define NotifyFail(rcode)
#endif
extern int UsbDEBUGlvl;
#include "printhex.h"
//void Notify(const char* msg);
template <class ERROR_TYPE>
void ErrorMessage(char const * msg, ERROR_TYPE rcode = 0) {
Notify(msg, 0x80);

View file

@ -185,6 +185,7 @@ uint8_t USBHub::Init(uint8_t parent, uint8_t port, bool lowspeed) {
bInitState = 0;
return 0;
// Oleg, No debugging?? -- xxxajk
FailGetDevDescr:
goto Fail;