本文整理汇总了C++中Notify函数的典型用法代码示例。如果您正苦于以下问题:C++ Notify函数的具体用法?C++ Notify怎么用?C++ Notify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Notify函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Notify
void CalibTree::Init(TChain *tree, const char *dupFileName) {
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
// It is normally not necessary to make changes to the generated
// code, but the routine can be extended by the user if needed.
// Init() will be called many times when running on PROOF
// (once per file to be processed).
// Set object pointer
t_DetIds = 0;
t_HitEnergies = 0;
t_trgbits = 0;
t_DetIds1 = 0;
t_DetIds3 = 0;
t_HitEnergies1 = 0;
t_HitEnergies3 = 0;
// Set branch addresses and branch pointers
fChain = tree;
if (!tree) return;
fCurrent = -1;
fChain->SetMakeClass(1);
fChain->SetBranchAddress("t_Run", &t_Run, &b_t_Run);
fChain->SetBranchAddress("t_Event", &t_Event, &b_t_Event);
fChain->SetBranchAddress("t_DataType", &t_DataType, &b_t_DataType);
fChain->SetBranchAddress("t_ieta", &t_ieta, &b_t_ieta);
fChain->SetBranchAddress("t_iphi", &t_iphi, &b_t_iphi);
fChain->SetBranchAddress("t_EventWeight", &t_EventWeight, &b_t_EventWeight);
fChain->SetBranchAddress("t_nVtx", &t_nVtx, &b_t_nVtx);
fChain->SetBranchAddress("t_nTrk", &t_nTrk, &b_t_nTrk);
fChain->SetBranchAddress("t_goodPV", &t_goodPV, &b_t_goodPV);
fChain->SetBranchAddress("t_l1pt", &t_l1pt, &b_t_l1pt);
fChain->SetBranchAddress("t_l1eta", &t_l1eta, &b_t_l1eta);
fChain->SetBranchAddress("t_l1phi", &t_l1phi, &b_t_l1phi);
fChain->SetBranchAddress("t_l3pt", &t_l3pt, &b_t_l3pt);
fChain->SetBranchAddress("t_l3eta", &t_l3eta, &b_t_l3eta);
fChain->SetBranchAddress("t_l3phi", &t_l3phi, &b_t_l3phi);
fChain->SetBranchAddress("t_p", &t_p, &b_t_p);
fChain->SetBranchAddress("t_pt", &t_pt, &b_t_pt);
fChain->SetBranchAddress("t_phi", &t_phi, &b_t_phi);
fChain->SetBranchAddress("t_mindR1", &t_mindR1, &b_t_mindR1);
fChain->SetBranchAddress("t_mindR2", &t_mindR2, &b_t_mindR2);
fChain->SetBranchAddress("t_eMipDR", &t_eMipDR, &b_t_eMipDR);
fChain->SetBranchAddress("t_eHcal", &t_eHcal, &b_t_eHcal);
fChain->SetBranchAddress("t_eHcal10", &t_eHcal10, &b_t_eHcal10);
fChain->SetBranchAddress("t_eHcal30", &t_eHcal30, &b_t_eHcal30);
fChain->SetBranchAddress("t_hmaxNearP", &t_hmaxNearP, &b_t_hmaxNearP);
fChain->SetBranchAddress("t_rhoh", &t_rhoh, &b_t_rhoh);
fChain->SetBranchAddress("t_selectTk", &t_selectTk, &b_t_selectTk);
fChain->SetBranchAddress("t_qltyFlag", &t_qltyFlag, &b_t_qltyFlag);
fChain->SetBranchAddress("t_qltyMissFlag", &t_qltyMissFlag, &b_t_qltyMissFlag);
fChain->SetBranchAddress("t_qltyPVFlag", &t_qltyPVFlag, &b_t_qltyPVFlag);
fChain->SetBranchAddress("t_gentrackP", &t_gentrackP, &b_t_gentrackP);
fChain->SetBranchAddress("t_DetIds", &t_DetIds, &b_t_DetIds);
fChain->SetBranchAddress("t_HitEnergies", &t_HitEnergies, &b_t_HitEnergies);
fChain->SetBranchAddress("t_trgbits", &t_trgbits, &b_t_trgbits);
fChain->SetBranchAddress("t_DetIds1", &t_DetIds1, &b_t_DetIds1);
fChain->SetBranchAddress("t_DetIds3", &t_DetIds3, &b_t_DetIds3);
fChain->SetBranchAddress("t_HitEnergies1", &t_HitEnergies1, &b_t_HitEnergies1);
fChain->SetBranchAddress("t_HitEnergies3", &t_HitEnergies3, &b_t_HitEnergies3);
Notify();
ifstream infil1(dupFileName);
if (!infil1.is_open()) {
std::cout << "Cannot open " << dupFileName << std::endl;
} else {
while (1) {
Long64_t jentry;
infil1 >> jentry;
if (!infil1.good()) break;
entries.push_back(jentry);
}
infil1.close();
std::cout << "Reads a list of " << entries.size() << " events from "
<< dupFileName << std::endl;
}
}
开发者ID:mkiani,项目名称:cmssw,代码行数:78,代码来源:CalibTree.C
示例2: ATLVERIFY
DWORD CImplRepairVul::_ThreadFuncDownloadImpl()
{
do
{
m_thinfo.Reset();
INT nTotalFixItem = m_arrDownloadItem.GetSize();
if(nTotalFixItem==0)
break;
m_thinfo.totalNum = nTotalFixItem;
//
BOOL bImportLocal = m_dwRepairFlags&VULFLAG_REPAIR_IMPORT_LOCAL;
BOOL bDownloadIfFailImport = m_dwRepairFlags&VULFLAG_REPAIR_DOWNLOAD_IF_FAIL_IMPORT;
bImportLocal = bImportLocal && !m_strImportPath.IsEmpty();
// 1. Download
CFileDownloader fdSingle;
m_thinfo.m_pFileDownloaderSingle = &fdSingle;
fdSingle.SetObserver( this );
IDownload *fd = NULL;
ATLVERIFY( SUCCEEDED(CreateDownloadObject(__uuidof(IDownload), (VOID**)&fd)) );
m_thinfo.m_pFileDownloader = fd;
fd->SetObserver( this );
m_thinfo.m_fileDownloadLocal.SetObserver(this);
for(int i=0; i<m_arrDownloadItem.GetSize() && !m_bCanceled; ++i)
{
T_RepairItem &item = m_arrDownloadItem[i];
BOOL bNeedCheckCert = item.bCheckCert;
DWORD dwDownfileStat = 0;
Notify(EVulfix_DownloadBegin, item.nID, i, m_thinfo.totalNum);
BOOL downSuccess = FALSE;
if(item.type==VTYPE_SOFTLEAK && item.bDisableCOM)
{
downSuccess = TRUE;
}
else
{
downSuccess = FALSE;
item.strFilename = m_strDownloadPath;
CString strFilename;
if(GetFileNameFromUrl(item.strURL, strFilename))
{
// 兼容正常文件名
item.strFilename.Format(_T("%s\\%s"), m_strDownloadPath, strFilename);
if(!IsFileExist(item.strFilename))
{
item.strFilename.Format(_T("%s\\%s%s"), m_strDownloadPath, BK_FILE_PREFIX, strFilename);
if(!IsFileExist(item.strFilename))
{
item.strFilename.Format(_T("%s\\%s"), m_strDownloadPath, strFilename);
// download if file not exists
dwDownfileStat |= ERDOWN_LOCAL_NOT_EXISTS;
BOOL toDownloadFromWeb = TRUE;
if(bImportLocal)
{
m_thinfo.m_fileDownloadLocal.SetUserData((LPVOID)item.nID);
CString strImportFilename;
LPCTSTR lpszHttp = _T("http://");
if( _tcsnicmp(lpszHttp, m_strImportPath, _tcslen(lpszHttp))==0 )
{
// 支持本地http 导入
strImportFilename.Format(_T("%s/%s"), m_strImportPath, strFilename);
fd->SetUserData((LPVOID)item.nID);
fd->SetDownloadInfo(strImportFilename, item.strFilename);
fd->Fetch();
}
else
{
// 本地路径导入
strImportFilename.Format(_T("%s\\%s"), m_strImportPath, strFilename);
m_thinfo.m_fileDownloadLocal.SetDownloadInfo(strImportFilename, item.strFilename);
if( !m_thinfo.m_fileDownloadLocal.Fetch() )
{
if(!m_bCanceled)
{
strImportFilename.Format(_T("%s\\%s%s"), m_strImportPath, BK_FILE_PREFIX, strFilename);
m_thinfo.m_fileDownloadLocal.SetDownloadInfo(strImportFilename, item.strFilename);
m_thinfo.m_fileDownloadLocal.Fetch();
}
}
}
if(PathFileExists(item.strFilename))
{
toDownloadFromWeb = FALSE;
dwDownfileStat |= ERDOWN_IMPORT_LOCAL;
}
else
{
toDownloadFromWeb = bDownloadIfFailImport;
//.........这里部分代码省略.........
开发者ID:6520874,项目名称:pcmanager,代码行数:101,代码来源:ImplRepairVul.cpp
示例3: Notify
NS_IMETHODIMP
PlacesEvent::Run()
{
Notify();
return NS_OK;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:6,代码来源:Helpers.cpp
示例4: Notify
ECode NotificationManager::Notify(
/* [in] */ Int32 id,
/* [in] */ INotification* notification)
{
return Notify(String(NULL), id, notification);
}
开发者ID:elastos,项目名称:Elastos5,代码行数:6,代码来源:NotificationManager.cpp
示例5: again
/*
* How server management (for one particular article) works:
- there is a list of failed servers which is initially empty;
- level is initially 0;
<loop>
- request a connection from server pool for current level;
Exception: this step is skipped for the very first download attempt, because a
level-0 connection is initially passed from queue manager;
- try to download from server;
- if connection to server cannot be established or download fails due to interrupted connection,
try again (as many times as needed without limit) the same server until connection is OK;
- if download fails with error "Not-Found" (article or group not found) or with CRC error,
add the server to failed server list;
- if download fails with general failure error (article incomplete, other unknown error
codes), try the same server again as many times as defined by option <Retries>; if all attempts
fail, add the server to failed server list;
- if all servers from current level were tried, increase level;
- if all servers from all levels were tried, break the loop with failure status.
<end-loop>
*/
void ArticleDownloader::Run()
{
debug("Entering ArticleDownloader-loop");
SetStatus(adRunning);
BuildOutputFilename();
m_szResultFilename = m_pArticleInfo->GetResultFilename();
if (g_pOptions->GetContinuePartial())
{
if (Util::FileExists(m_szResultFilename))
{
// file exists from previous program's start
detail("Article %s already downloaded, skipping", m_szInfoName);
FreeConnection(true);
SetStatus(adFinished);
Notify(NULL);
return;
}
}
EStatus Status = adFailed;
int iRetries = g_pOptions->GetRetries() > 0 ? g_pOptions->GetRetries() : 1;
int iRemainedRetries = iRetries;
ServerPool::Servers failedServers;
failedServers.reserve(g_pServerPool->GetServers()->size());
NewsServer* pWantServer = NULL;
NewsServer* pLastServer = NULL;
int iLevel = 0;
int iServerConfigGeneration = g_pServerPool->GetGeneration();
while (!IsStopped())
{
Status = adFailed;
SetStatus(adWaiting);
while (!m_pConnection && !(IsStopped() || iServerConfigGeneration != g_pServerPool->GetGeneration()))
{
m_pConnection = g_pServerPool->GetConnection(iLevel, pWantServer, &failedServers);
usleep(5 * 1000);
}
SetLastUpdateTimeNow();
SetStatus(adRunning);
if (IsStopped() || g_pOptions->GetPauseDownload() || g_pOptions->GetPauseDownload2() ||
iServerConfigGeneration != g_pServerPool->GetGeneration())
{
Status = adRetry;
break;
}
pLastServer = m_pConnection->GetNewsServer();
m_pConnection->SetSuppressErrors(false);
// test connection
bool bConnected = m_pConnection && m_pConnection->Connect();
if (bConnected && !IsStopped())
{
// Okay, we got a Connection. Now start downloading.
detail("Downloading %s @ %s (%s)", m_szInfoName,
m_pConnection->GetNewsServer()->GetName(), m_pConnection->GetHost());
Status = Download();
}
if (bConnected)
{
if (Status == adConnectError)
{
m_pConnection->Disconnect();
bConnected = false;
Status = adFailed;
}
else
{
// freeing connection allows other threads to start.
//.........这里部分代码省略.........
开发者ID:Bootz,项目名称:nzbget,代码行数:101,代码来源:ArticleDownloader.cpp
示例6: NotifyFailSetDevTblEntry
void NotifyFailSetDevTblEntry(void) {
Notify(PSTR("\r\nsetDevTblEn"), 0x80);
}
开发者ID:Aerobota,项目名称:radiationUAV,代码行数:3,代码来源:message.cpp
示例7: printf
/**
* For driver use only.
*
* @param pcbw
* @param buf_size
* @param buf
* @param flags
* @return
*/
uint8_t BulkOnly::Transaction(CommandBlockWrapper *pcbw, uint16_t buf_size, void *buf
#if MS_WANT_PARSER
, uint8_t flags
#endif
) {
#if MS_WANT_PARSER
uint16_t bytes = (pcbw->dCBWDataTransferLength > buf_size) ? buf_size : pcbw->dCBWDataTransferLength;
printf("Transfersize %i\r\n", bytes);
delay(1000);
bool callback = (flags & MASS_TRANS_FLG_CALLBACK) == MASS_TRANS_FLG_CALLBACK;
#else
uint16_t bytes = buf_size;
#endif
bool write = (pcbw->bmCBWFlags & MASS_CMD_DIR_IN) != MASS_CMD_DIR_IN;
uint8_t ret = 0;
uint8_t usberr;
CommandStatusWrapper csw; // up here, we allocate ahead to save cpu cycles.
SetCurLUN(pcbw->bmCBWLUN);
ErrorMessage<uint32_t > (PSTR("CBW.dCBWTag"), pcbw->dCBWTag);
while((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw)) == hrBUSY) delay(1);
ret = HandleUsbError(usberr, epDataOutIndex);
//ret = HandleUsbError(pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, sizeof (CommandBlockWrapper), (uint8_t*)pcbw), epDataOutIndex);
if(ret) {
ErrorMessage<uint8_t > (PSTR("============================ CBW"), ret);
} else {
if(bytes) {
if(!write) {
#if MS_WANT_PARSER
if(callback) {
uint8_t rbuf[bytes];
while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, rbuf)) == hrBUSY) delay(1);
if(usberr == hrSUCCESS) ((USBReadParser*)buf)->Parse(bytes, rbuf, 0);
} else {
#endif
while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*)buf)) == hrBUSY) delay(1);
#if MS_WANT_PARSER
}
#endif
ret = HandleUsbError(usberr, epDataInIndex);
} else {
while((usberr = pUsb->outTransfer(bAddress, epInfo[epDataOutIndex].epAddr, bytes, (uint8_t*)buf)) == hrBUSY) delay(1);
ret = HandleUsbError(usberr, epDataOutIndex);
}
if(ret) {
ErrorMessage<uint8_t > (PSTR("============================ DAT"), ret);
}
}
}
{
bytes = sizeof (CommandStatusWrapper);
int tries = 2;
while(tries--) {
while((usberr = pUsb->inTransfer(bAddress, epInfo[epDataInIndex].epAddr, &bytes, (uint8_t*) & csw)) == hrBUSY) delay(1);
if(!usberr) break;
ClearEpHalt(epDataInIndex);
if(tries) ResetRecovery();
}
if(!ret) {
Notify(PSTR("CBW:\t\tOK\r\n"), 0x80);
Notify(PSTR("Data Stage:\tOK\r\n"), 0x80);
} else {
// Throw away csw, IT IS NOT OF ANY USE.
ResetRecovery();
return ret;
}
ret = HandleUsbError(usberr, epDataInIndex);
if(ret) {
ErrorMessage<uint8_t > (PSTR("============================ CSW"), ret);
}
if(usberr == hrSUCCESS) {
if(IsValidCSW(&csw, pcbw)) {
//ErrorMessage<uint32_t > (PSTR("CSW.dCBWTag"), csw.dCSWTag);
//ErrorMessage<uint8_t > (PSTR("bCSWStatus"), csw.bCSWStatus);
//ErrorMessage<uint32_t > (PSTR("dCSWDataResidue"), csw.dCSWDataResidue);
Notify(PSTR("CSW:\t\tOK\r\n\r\n"), 0x80);
return csw.bCSWStatus;
} else {
// NOTE! Sometimes this is caused by the reported residue being wrong.
// Get a different device. It isn't compliant, and should have never passed Q&A.
// I own one... 05e3:0701 Genesys Logic, Inc. USB 2.0 IDE Adapter.
// Other devices that exhibit this behavior exist in the wild too.
// Be sure to check quirks in the Linux source code before reporting a bug. --xxxajk
Notify(PSTR("Invalid CSW\r\n"), 0x80);
ResetRecovery();
//return MASS_ERR_SUCCESS;
//.........这里部分代码省略.........
开发者ID:radiumray,项目名称:mdxly,代码行数:101,代码来源:masstorage.cpp
示例8: PrintExpCompensation
void PrintExpCompensation()
{
Notify(PSTR("ExpComp:"));
PrintValueTitle<uint8_t, VT_EXPCOMP, VT_EXPCOMP_COUNT, VT_EXPCOMP_TEXT_LEN>((PTP*)&Ps, PS_DPC_ExpCompensation, ExpCompTitles);
Notify(PSTR("\r\n"));
}
开发者ID:54dashayu,项目名称:arducam-osd,代码行数:6,代码来源:psconsole.cpp
示例9: PrintCamOutput
void PrintCamOutput()
{
Notify(PSTR("CamOutput:"));
PrintValueTitle<uint8_t, VT_CAMOUTPUT, VT_CAMOUTPUT_COUNT, VT_CAMOUTPUT_TEXT_LEN>((PTP*)&Ps, PS_DPC_CameraOutput, CamOutputTitles);
Notify(PSTR("\r\n"));
}
开发者ID:54dashayu,项目名称:arducam-osd,代码行数:6,代码来源:psconsole.cpp
示例10: PrintWB
void PrintWB()
{
Notify(PSTR("WB:"));
PrintValueTitle<uint8_t, VT_WB, VT_WB_COUNT, VT_WB_TEXT_LEN>((PTP*)&Ps, PS_DPC_WhiteBalance, WbTitles);
Notify(PSTR("\r\n"));
}
开发者ID:54dashayu,项目名称:arducam-osd,代码行数:6,代码来源:psconsole.cpp
示例11: PrintIso
void PrintIso()
{
Notify(PSTR("ISO:"));
PrintValueTitle<uint16_t, VT_ISO, VT_ISO_COUNT, VT_ISO_TEXT_LEN>((PTP*)&Ps, PS_DPC_ISOSpeed, IsoTitles);
Notify(PSTR("\r\n"));
}
开发者ID:54dashayu,项目名称:arducam-osd,代码行数:6,代码来源:psconsole.cpp
示例12: PrintShutterSpeed
void PrintShutterSpeed()
{
Notify(PSTR("T:"));
PrintValueTitle<uint16_t, VT_SHSPEED, VT_SHSPEED_COUNT, VT_SHSPEED_TEXT_LEN>((PTP*)&Ps, PS_DPC_ShutterSpeed, ShutterSpeedTitles);
Notify(PSTR("\r\n"));
}
开发者ID:54dashayu,项目名称:arducam-osd,代码行数:6,代码来源:psconsole.cpp
示例13: PrintAperture
void PrintAperture()
{
Notify(PSTR("F:"));
PrintValueTitle<uint16_t, VT_APERTURE, VT_APT_COUNT, VT_APT_TEXT_LEN>((PTP*)&Ps, PS_DPC_Aperture, ApertureTitles);
Notify(PSTR("\r\n"));
}
开发者ID:54dashayu,项目名称:arducam-osd,代码行数:6,代码来源:psconsole.cpp
示例14: PrintMode
void PrintMode()
{
Notify(PSTR("Mode:"));
PrintValueTitle<uint8_t, VT_MODE, VT_MODE_COUNT, VT_MODE_TEXT_LEN>((PTP*)&Ps, PS_DPC_ShootingMode, ModeTitles);
Notify(PSTR("\r\n"));
}
开发者ID:54dashayu,项目名称:arducam-osd,代码行数:6,代码来源:psconsole.cpp
示例15: NotifyFail
void NotifyFail(uint8_t rcode) {
D_PrintHex<uint8_t > (rcode, 0x80);
Notify(PSTR("\r\n"), 0x80);
}
开发者ID:Aerobota,项目名称:radiationUAV,代码行数:4,代码来源:message.cpp
示例16: osip_message_to_str
void FTComputingState::onFindSuccRedirect(
Node* node,
osip_transaction_t * tr ,
osip_message *response)
{
char *message;
size_t length = 0;
int i = osip_message_to_str(response, &message, &length);
node->LogStream("RECEIVE<<======================================\n") ;
node->LogStream(message) ;
// printf("RECEIVE<<======================================\n") ;
// printf(message) ;
/* to , from , contact are same as orig_request ;
req_uri is the contact of the response */
ChordId to(
atoi(tr->orig_request->to->url->username),
node->getConstants(),
tr->orig_request->to->url->host,
tr->orig_request->to->url->port
) ;
ChordId from(
atoi(tr->orig_request->from->url->username),
node->getConstants(),
tr->orig_request->from->url->host,
tr->orig_request->from->url->port
) ;
osip_contact_t *osip_contact ;
osip_message_get_contact(response,0,&osip_contact) ;
if(!osip_contact)
{return ;}//error
ChordId contact(
atoi(osip_contact->url->username),
node->getConstants(),
osip_contact->url->host,
osip_contact->url->port
) ;
ChordId chordId = node->getChordId() ;
//******************************
//如果重定向到自己,那么自身就是对应to的finger
if(contact.equals(chordId))
{
//scan fingertable
for(int i = 1 ; i <= node->getFingerTable()->getTableLength() ; i++)
{
if(node->getFingerTable()->getFinger(i)->start.equals(to))
break ;
}
int k ;
if(i <= node->getFingerTable()->getTableLength())
k = node->Set_Fingers(i, contact) + 1 ;
//A.finger表更新完毕
if (k == node->getFingerTable()->getTableLength() + 1)
{
//- Notify ...
Notify(node) ;
//- change state ...
ChangeState(node,new NormalState(node)) ;
}
//B.finger表未更新完
if (k<= node->getFingerTable()->getTableLength()) //update of fingertalbe if not completed
{
int i = node->SndRegister(FINDSUCC,contact,node->getFingerTable()->getFinger(k)->start,chordId) ;
//- not change state...
return ;
}
}
//继续重定向
else
{
node->SndRegister(FINDSUCC,contact,to,chordId) ;
}
}
开发者ID:inuyasha1027,项目名称:SI2P,代码行数:84,代码来源:FTComputingState.cpp
示例17: NotifyFailGetDevDescr
void NotifyFailGetDevDescr(void) {
Notify(PSTR("\r\ngetDevDescr"), 0x80);
}
开发者ID:Aerobota,项目名称:radiationUAV,代码行数:3,代码来源:message.cpp
示例18: NotifyFailSetConfDescr
void NotifyFailSetConfDescr(void) {
Notify(PSTR("\r\nsetConf"), 0x80);
}
开发者ID:Aerobota,项目名称:radiationUAV,代码行数:3,代码来源:message.cpp
示例19: Notify
uint8_t XBOXUSB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
uint8_t buf[sizeof(USB_DEVICE_DESCRIPTOR)];
uint8_t rcode;
UsbDevice *p = NULL;
EpInfo *oldep_ptr = NULL;
uint16_t PID;
uint16_t VID;
// get memory address of USB device address pool
AddressPool &addrPool = pUsb->GetAddressPool();
#ifdef EXTRADEBUG
Notify(PSTR("\r\nXBOXUSB Init"));
#endif
// check if address has already been assigned to an instance
if (bAddress) {
#ifdef DEBUG
Notify(PSTR("\r\nAddress in use"));
#endif
return USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE;
}
// Get pointer to pseudo device with address 0 assigned
p = addrPool.GetUsbDevicePtr(0);
if (!p) {
#ifdef DEBUG
Notify(PSTR("\r\nAddress not found"));
#endif
return USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL;
}
if (!p->epinfo) {
#ifdef DEBUG
Notify(PSTR("\r\nepinfo is null"));
#endif
return USB_ERROR_EPINFO_IS_NULL;
}
// Save old pointer to EP_RECORD of address 0
oldep_ptr = p->epinfo;
// Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence
p->epinfo = epInfo;
p->lowspeed = lowspeed;
// Get device descriptor
rcode = pUsb->getDevDescr(0, 0, sizeof(USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);// Get device descriptor - addr, ep, nbytes, data
// Restore p->epinfo
p->epinfo = oldep_ptr;
if(rcode)
goto FailGetDevDescr;
VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
if(VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) // We just check if it's a xbox controller using the Vendor ID
goto FailUnknownDevice;
if(PID == XBOX_WIRELESS_PID) {
#ifdef DEBUG
Notify(PSTR("\r\nYou have plugged in a wireless Xbox 360 controller - it doesn't support USB communication"));
#endif
goto FailUnknownDevice;
}
else if(PID == XBOX_WIRELESS_RECEIVER_PID || PID == XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID) {
#ifdef DEBUG
Notify(PSTR("\r\nThis library only supports Xbox 360 controllers via USB"));
#endif
goto FailUnknownDevice;
}
// Allocate new address according to device class
bAddress = addrPool.AllocAddress(parent, false, port);
if (!bAddress)
return USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL;
// Extract Max Packet Size from device descriptor
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
// Assign new address to the device
rcode = pUsb->setAddr( 0, 0, bAddress );
if (rcode) {
p->lowspeed = false;
addrPool.FreeAddress(bAddress);
bAddress = 0;
#ifdef DEBUG
Notify(PSTR("\r\nsetAddr: "));
#endif
PrintHex<uint8_t>(rcode);
return rcode;
}
#ifdef EXTRADEBUG
Notify(PSTR("\r\nAddr: "));
PrintHex<uint8_t>(bAddress);
#endif
p->lowspeed = false;
//get pointer to assigned address record
//.........这里部分代码省略.........
开发者ID:Cribstone,项目名称:USB_Host_Shield_2.0,代码行数:101,代码来源:XBOXUSB.cpp
示例20: switch
/**
* For driver use only.
*
* @param status
* @return
*/
uint8_t BulkOnly::HandleSCSIError(uint8_t status) {
uint8_t ret = 0;
switch(status) {
case 0: return MASS_ERR_SUCCESS;
case 2:
ErrorMessage<uint8_t > (PSTR("Phase Error"), status);
ErrorMessage<uint8_t > (PSTR("LUN"), bTheLUN);
ResetRecovery();
return MASS_ERR_GENERAL_SCSI_ERROR;
case 1:
ErrorMessage<uint8_t > (PSTR("SCSI Error"), status);
ErrorMessage<uint8_t > (PSTR("LUN"), bTheLUN);
RequestSenseResponce rsp;
ret = RequestSense(bTheLUN, sizeof (RequestSenseResponce), (uint8_t*) & rsp);
if(ret) {
return MASS_ERR_GENERAL_SCSI_ERROR;
}
ErrorMessage<uint8_t > (PSTR("Response Code"), rsp.bResponseCode);
if(rsp.bResponseCode & 0x80) {
Notify(PSTR("Information field: "), 0x80);
for(int i = 0; i < 4; i++) {
D_PrintHex<uint8_t > (rsp.CmdSpecificInformation[i], 0x80);
Notify(PSTR(" "), 0x80);
}
Notify(PSTR("\r\n"), 0x80);
}
ErrorMessage<uint8_t > (PSTR("Sense Key"), rsp.bmSenseKey);
ErrorMessage<uint8_t > (PSTR("Add Sense Code"), rsp.bAdditionalSenseCode);
ErrorMessage<uint8_t > (PSTR("Add Sense Qual"), rsp.bAdditionalSenseQualifier);
// warning, this is not testing ASQ, only SK and ASC.
switch(rsp.bmSenseKey) {
case SCSI_S_UNIT_ATTENTION:
switch(rsp.bAdditionalSenseCode) {
case SCSI_ASC_MEDIA_CHANGED:
return MASS_ERR_MEDIA_CHANGED;
default:
return MASS_ERR_UNIT_NOT_READY;
}
case SCSI_S_NOT_READY:
switch(rsp.bAdditionalSenseCode) {
case SCSI_ASC_MEDIUM_NOT_PRESENT:
return MASS_ERR_NO_MEDIA;
default:
return MASS_ERR_UNIT_NOT_READY;
}
case SCSI_S_ILLEGAL_REQUEST:
switch(rsp.bAdditionalSenseCode) {
case SCSI_ASC_LBA_OUT_OF_RANGE:
return MASS_ERR_BAD_LBA;
default:
return MASS_ERR_CMD_NOT_SUPPORTED;
}
default:
return MASS_ERR_GENERAL_SCSI_ERROR;
}
// case 4: return MASS_ERR_UNIT_BUSY; // Busy means retry later.
// case 0x05/0x14: we stalled out
// case 0x15/0x16: we naked out.
default:
ErrorMessage<uint8_t > (PSTR("Gen SCSI Err"), status);
ErrorMessage<uint8_t > (PSTR("LUN"), bTheLUN);
return status;
} // switch
}
开发者ID:radiumray,项目名称:mdxly,代码行数:76,代码来源:masstorage.cpp
注:本文中的Notify函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论