Пример #1
0
UMTSStickErr UMTSStick::getSerial(UsbSerial** ppUsbSerial)
{
  m_host.init();
  
  UMTSStickErr rc;
  
  rc = waitForDevice();
  if(rc)
    return rc;
   
  //Device is now enumerated, read table
  
  uint16_t vid = m_pDev->getVid();
  uint16_t pid = m_pDev->getPid();
  
  DBG("Configuration set: vid:%04x pid:%04x\n", vid, pid);
    
  bool handled = false;
  bool cdfs = false;
  const UMTSSwitchingInfo* pInfo;
  for(int i = 0; i < UMTS_SWITCHING_COUNT; i++)
  {
    pInfo = &UMTSwitchingTable[i];
    if( !checkDeviceState(pInfo, &cdfs) )
    {
      handled = true;
      break;
    }
    
  } //for(int i = 0; i < UMTS_SWITCHING_COUNT; i++)
  
  if(!handled)
  {
    DBG("Don't know this device!\n");
    return UMTSERR_NOTIMPLEMENTED;
  }
  
  //Check if the device is in CDFS mode, in this case switch
  if(cdfs)
  {
    DBG("Switching the device by sending a magic packet\n");
  
    rc = switchMode(pInfo);
    if(rc)
      return rc;
      
    DBG("Now wait for device to reconnect\n");
    
    m_host.releaseDevice(m_pDev);
      
    //Wait for device to reconnect
    wait(3);
    rc = waitForDevice();
    if(rc)
      return rc;
  }
  
  rc = findSerial(ppUsbSerial);
  if(rc)
    return rc;
  
  return UMTSERR_OK;
}
Пример #2
0
void PreLL1() {
	digType cflag = 0;

	// Detect and eliminate left recursion
	DLR();

#ifdef _DEBUG
	printf("After deleting the left recursion: \n");

	for (pRule p = gRules; p; p = p->next) {
		for (pRuleNode pr = p->addr; pr; pr = pr->next) {
			printf("%s ", pr->symbol);
		}
		printf("\n");
	}
	printf("\n\n\n");
#endif // _DEBUG

	// Terminals First set
	for (pSymbolNode p = ll[1]; p; p = p->next) {
		getSymbolFirst(p);
	}

	// Nonterminals First set
	while (1)
	{
		for (pSymbolNode p = ll[0]; p; p = p->next) {
			getSymbolFirst(p);
		}

		if (cflag == setCount(getSymbolFirst)) break;
		else cflag = setCount(getSymbolFirst);
	}

#ifdef _DEBUG
	printf("The First sets: \n");

	for (pSymbolNode p = ll[0]; p; p = p->next) {
		printf("%s: ", p->symbol);
		if (p->first)
			for (unsigned int i = 1; i <= *(p->first); i++) {
				char *s = findSerial(*(p->first + i));
				printf("%s ", s);
				free(s);
			}
		printf("\n");
	}
	printf("\n\n\n");
#endif // _DEBUG

	cflag = 0;

	//  Follow set
	while (1)
	{
		for (pSymbolNode p = ll[0]; p; p = p->next) {
			getFollow(p);
		}

		if (cflag == setCount(getFollow)) break;
		else cflag = setCount(getFollow);
	}
#ifdef _DEBUG
	printf("The Follow sets: \n");

	for (pSymbolNode p = ll[0]; p; p = p->next) {
		printf("%s: ", p->symbol);
		if (p->follow)
			for (unsigned int i = 1; i <= *(p->follow); i++) {
				char *s = findSerial(*(p->follow + i));
				printf("%s ", s);
				printf("(%d) ", *(p->follow + i));
				free(s);
			}
		printf("\n");
	}
	printf("\n\n\n");
#endif // _DEBUG

	// Construct LL(1) analysis table
	CLAT();

#ifdef _DEBUG
	printf("The Analysis table: \n\t");

	for (digType i = 0; i < gTerSerial / 2; i++) {
		if (!i)
			printf("# ");
		else {
			char* s = findSerial(i * 2);
			printf("%s ", s);
			free(s);
		}
	}
	printf("\n");

	for (digType row = 0; row < gNonTerSerial / 2; row++) {
		char* s = findSerial(row * 2 + 1);
		printf("%s\t", s);
		free(s);
		for (digType col = 0; col < gTerSerial / 2; col++) {
			if (!AT[row][col]) {
				printf(". ");
				continue;
			}

			s = findSerial(AT[row][col]->serial);
			if (s)
				printf("%s ", s);
			else
				printf("0 ");
			free(s);
		}
		printf("\n");
	}
	printf("\n\n\n");
#endif // _DEBUG
}