当前位置: 首页>>代码示例>>C++>>正文


C++ DebugPrint函数代码示例

本文整理汇总了C++中DebugPrint函数的典型用法代码示例。如果您正苦于以下问题:C++ DebugPrint函数的具体用法?C++ DebugPrint怎么用?C++ DebugPrint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DebugPrint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DriverEntry

NTSTATUS
DriverEntry(
	IN PDRIVER_OBJECT DriverObject,
	IN PUNICODE_STRING RegistryPath
	)
{
	NTSTATUS status;

	DebugPrint(("Yt driver loaded.\n"));

	YtDriverObject = DriverObject;

	//Inicialize spin-lock and head of list.
	time1 = (PLARGE_INTEGER) YtAlloc(NonPagedPool, sizeof(LARGE_INTEGER));
	time2 = (PLARGE_INTEGER) YtAlloc(NonPagedPool, sizeof(LARGE_INTEGER));
	time.QuadPart = 0;
	count.QuadPart = 0;

	//Save registry path
	YtRegistryPath.MaximumLength = RegistryPath->Length
									+ sizeof(UNICODE_NULL);
	YtRegistryPath.Buffer = (PWSTR) YtAlloc(NonPagedPool, YtRegistryPath.MaximumLength);
	if (YtRegistryPath.Buffer != NULL)
	{
		RtlCopyUnicodeString(&YtRegistryPath, RegistryPath);
	} else {
		YtRegistryPath.Length = 0;
		YtRegistryPath.MaximumLength = 0;
	}

	//Create dispatch points
	PDRIVER_DISPATCH *dispatch;
	ULONG i;
	for (i = 0, dispatch = DriverObject->MajorFunction;
		i <= IRP_MJ_MAXIMUM_FUNCTION;
		i++, dispatch++) {

		*dispatch = YtDispatchEmpty;
	}

	//Set up the device driver entry points.
	DriverObject->MajorFunction[IRP_MJ_CREATE]          = YtDispatchCreateClose;
	DriverObject->MajorFunction[IRP_MJ_CLOSE]           = YtDispatchCreateClose;
	DriverObject->MajorFunction[IRP_MJ_CLEANUP]         = YtDispatchCreateClose;
	DriverObject->MajorFunction[IRP_MJ_READ]            = YtDispatchRead;
	DriverObject->MajorFunction[IRP_MJ_WRITE]           = YtDispatchWrite;
	DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL]  = YtDeviceControl;
	
	DriverObject->MajorFunction[IRP_MJ_SHUTDOWN]        = YtShutdownFlush;
	DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS]   = YtShutdownFlush;
	DriverObject->MajorFunction[IRP_MJ_PNP]             = YtDispatchPnP;
	DriverObject->MajorFunction[IRP_MJ_POWER]           = YtDispatchPower;

	DriverObject->DriverExtension->AddDevice            = YtAddDevice;//YtAddDeviceStub;
	DriverObject->DriverUnload                          = YtUnload;

/*	PWSTR devlist;
	NTSTATUS dlstatus = IoGetDeviceInterfaces(
		&GUID_DEVINTERFACE_DISK,
		NULL,
		0,
		&devlist
		);

	if(NT_SUCCESS(dlstatus))
	{
		DebugPrint(("Yt: device list received successfully: %X\n", devlist));

		PWSTR buf = devlist;
		while( *buf != L'\0')
		{
			DebugPrint(("Yt: Disk device detected: %ws\n", buf));

			UNICODE_STRING DeviceName;
			RtlInitUnicodeString(&DeviceName, buf);

			PFILE_OBJECT FileObject;
			PDEVICE_OBJECT DeviceObject;

			NTSTATUS obstatus = IoGetDeviceObjectPointer(
				&DeviceName,
				FILE_READ_DATA | FILE_WRITE_DATA,
				&FileObject,
				&DeviceObject
				);

			if(NT_SUCCESS(obstatus))
			{
				DebugPrint(("Yt: Successfully got object pointer for device %ws\n", buf));

				//YtAddDevice(DriverObject, DeviceObject);
				ObDereferenceObject(FileObject);
			}
			else
			{
				DebugPrint(("Yt: Unable to get object pointer for device %ws\n", buf));
			}

			buf += wcslen(buf)+1;
		}
//.........这里部分代码省略.........
开发者ID:virl,项目名称:yttrium,代码行数:101,代码来源:ytdrv.cpp

示例2: closesocket

int Broadcast::Bind(unsigned short port)
{
    SOCKADDR_IN addr;
    int result;
    unsigned short i;
    BOOL istrue=TRUE;

    //If called a second time reintialize
    if (m_sock != INVALID_SOCKET)
        closesocket(m_sock);

    m_sock=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);

    if (m_sock==INVALID_SOCKET)
    {
        result=WSAGetLastError();
        DebugPrint("Failed to create socket error<%d>\n",result);
        return result;
    }


    //Create a socket for broadcasting 
    //and that doesn't linge on close
    //should set buffer max to 512
/*
    if (setsockopt(m_sock,SOL_SOCKET,
            SO_BROADCAST,(const char *)&istrue,sizeof(istrue))) {
        result = WSAGetLastError();
        DebugPrint("Failed to setsockopt SO_BROADCAST error<%d>\n",result);
        closesocket(m_sock);
        m_sock=INVALID_SOCKET;
        return result;
    }
*/
    //remember that TCP/IP and UDP ports are seperate
    //and so even with TCP/IP ports all used we shouldn't
    //have a problem binding to a port. So no retry on port
    ZeroMemory(&addr,sizeof(SOCKADDR_IN));
    ZeroMemory(&m_addr,sizeof(SOCKADDR_IN));
    addr.sin_family=AF_INET;
    addr.sin_addr.s_addr = INADDR_ANY;
    addr.sin_port = htons(port);

    //For broadcast address we don't want to bind to the port we want to send to
    for (i=10000;i<0xFFFF;i++) {
        if (i==port)
            continue;

        addr.sin_port = htons(i);
        DebugPrint("Tring to bind on port<%d>\n",i);
        if (result=bind(m_sock,(SOCKADDR *)&addr,sizeof(SOCKADDR_IN)))
        {
            result=WSAGetLastError();
            if (result!= WSAEADDRINUSE) {
                DebugPrint("Failed to bind error<%d>\n",result);
                closesocket(m_sock);
                m_sock=INVALID_SOCKET;
                return result;
            }
        }
        else
            break;
    }

    if (result) {
        DebugPrint("Failed to bind to any address\n");
        closesocket(m_sock);
        m_sock=INVALID_SOCKET;
    };    
    addr.sin_port = htons(port);
    addr.sin_addr.s_addr = INADDR_BROADCAST;
    CopyMemory(&m_addr,&addr,sizeof(SOCKADDR_IN));

    //We are good to send
    return NULL;
};
开发者ID:AllegianceZone,项目名称:Allegiance,代码行数:76,代码来源:broadcast.cpp

示例3: DebugPrint

void CPlayer::Init(/* PlayerTypes */ int type)
{
	this->Units.resize(0);
	this->FreeWorkers.resize(0);

	//  Take first slot for person on this computer,
	//  fill other with computer players.
	if (type == PlayerPerson && !NetPlayers) {
		if (!ThisPlayer) {
			ThisPlayer = this;
		} else {
			type = PlayerComputer;
		}
	}
	if (NetPlayers && NumPlayers == NetLocalPlayerNumber) {
		ThisPlayer = &Players[NetLocalPlayerNumber];
	}

	if (NumPlayers == PlayerMax) {
		static int already_warned;

		if (!already_warned) {
			DebugPrint("Too many players\n");
			already_warned = 1;
		}
		return;
	}

	//  Make simple teams:
	//  All person players are enemies.
	int team;
	switch (type) {
		case PlayerNeutral:
		case PlayerNobody:
		default:
			team = 0;
			this->SetName("Neutral");
			break;
		case PlayerComputer:
			team = 1;
			this->SetName("Computer");
			break;
		case PlayerPerson:
			team = 2 + NumPlayers;
			this->SetName("Person");
			break;
		case PlayerRescuePassive:
		case PlayerRescueActive:
			// FIXME: correct for multiplayer games?
			this->SetName("Computer");
			team = 2 + NumPlayers;
			break;
	}
	DebugPrint("CreatePlayer name %s\n" _C_ this->Name.c_str());

	this->Type = type;
	this->Race = 0;
	this->Team = team;
	this->Enemy = 0;
	this->Allied = 0;
	this->AiName = "ai-passive";

	//  Calculate enemy/allied mask.
	for (int i = 0; i < NumPlayers; ++i) {
		switch (type) {
			case PlayerNeutral:
			case PlayerNobody:
			default:
				break;
			case PlayerComputer:
				// Computer allied with computer and enemy of all persons.
				if (Players[i].Type == PlayerComputer) {
					this->Allied |= (1 << i);
					Players[i].Allied |= (1 << NumPlayers);
				} else if (Players[i].Type == PlayerPerson || Players[i].Type == PlayerRescueActive) {
					this->Enemy |= (1 << i);
					Players[i].Enemy |= (1 << NumPlayers);
				}
				break;
			case PlayerPerson:
				// Humans are enemy of all?
				if (Players[i].Type == PlayerComputer || Players[i].Type == PlayerPerson) {
					this->Enemy |= (1 << i);
					Players[i].Enemy |= (1 << NumPlayers);
				} else if (Players[i].Type == PlayerRescueActive || Players[i].Type == PlayerRescuePassive) {
					this->Allied |= (1 << i);
					Players[i].Allied |= (1 << NumPlayers);
				}
				break;
			case PlayerRescuePassive:
				// Rescue passive are allied with persons
				if (Players[i].Type == PlayerPerson) {
					this->Allied |= (1 << i);
					Players[i].Allied |= (1 << NumPlayers);
				}
				break;
			case PlayerRescueActive:
				// Rescue active are allied with persons and enemies of computer
				if (Players[i].Type == PlayerComputer) {
					this->Enemy |= (1 << i);
//.........这里部分代码省略.........
开发者ID:stefanhendriks,项目名称:stratagus,代码行数:101,代码来源:player.cpp

示例4: Assert

/**
**  Draw unit on map.
*/
void CUnit::Draw(const CViewport &vp) const
{
	int frame;
	int state;
	int constructed;
	const CConstructionFrame *cframe;
	const CUnitType *type;

	if (this->Destroyed || this->Container || this->Type->Revealer) { // Revealers are not drawn
		return;
	}

	bool IsVisible = this->IsVisible(*ThisPlayer);

	// Those should have been filtered. Check doesn't make sense with ReplayRevealMap
	Assert(ReplayRevealMap || this->Type->VisibleUnderFog || IsVisible);

	int player = this->RescuedFrom ? this->RescuedFrom->Index : this->Player->Index;
	int action = this->CurrentAction();
	PixelPos screenPos;
	if (ReplayRevealMap || IsVisible) {
		screenPos = vp.MapToScreenPixelPos(this->GetMapPixelPosTopLeft());
		type = this->Type;
		frame = this->Frame;
		state = (action == UnitActionBuilt) | ((action == UnitActionUpgradeTo) << 1);
		constructed = this->Constructed;
		// Reset Type to the type being upgraded to
		if (action == UnitActionUpgradeTo) {
			const COrder_UpgradeTo &order = *static_cast<COrder_UpgradeTo *>(this->CurrentOrder());

			type = &order.GetUnitType();
		}

		if (this->CurrentAction() == UnitActionBuilt) {
			COrder_Built &order = *static_cast<COrder_Built *>(this->CurrentOrder());

			cframe = &order.GetFrame();
		} else {
			cframe = NULL;
		}
	} else {
		screenPos = vp.TilePosToScreen_TopLeft(this->Seen.tilePos);

		screenPos.x += this->Seen.IX;
		screenPos.y += this->Seen.IY;
		frame = this->Seen.Frame;
		type = this->Seen.Type;
		constructed = this->Seen.Constructed;
		state = this->Seen.State;
		cframe = this->Seen.CFrame;
	}

#ifdef DYNAMIC_LOAD
	if (!type->Sprite) {
		LoadUnitTypeSprite(type);
	}
#endif

	if (!IsVisible && frame == UnitNotSeen) {
		DebugPrint("FIXME: Something is wrong, unit %d not seen but drawn time %lu?.\n" _C_
				   UnitNumber(*this) _C_ GameCycle);
		return;
	}


	if (state == 1 && constructed && cframe) {
		DrawConstructionShadow(*type, cframe, frame, screenPos);
	} else {
		if (action != UnitActionDie) {
			DrawShadow(*type, frame, screenPos);
		}
	}

	//
	// Show that the unit is selected
	//
	DrawUnitSelection(vp, *this);

	//
	// Adjust sprite for Harvesters.
	//
	CPlayerColorGraphic *sprite = type->Sprite;
	if (type->Harvester && this->CurrentResource) {
		ResourceInfo *resinfo = type->ResInfo[this->CurrentResource];
		if (this->ResourcesHeld) {
			if (resinfo->SpriteWhenLoaded) {
				sprite = resinfo->SpriteWhenLoaded;
			}
		} else {
			if (resinfo->SpriteWhenEmpty) {
				sprite = resinfo->SpriteWhenEmpty;
			}
		}
	}

	//
	// Now draw!
//.........这里部分代码省略.........
开发者ID:Clemenshemmerling,项目名称:Stratagus,代码行数:101,代码来源:unit_draw.cpp

示例5: GetComponent

/**
**  Return the value corresponding.
**
**  @param unit   Unit.
**  @param index  Index of the variable.
**  @param e      Component of the variable.
**  @param t      Which var use (0:unit, 1:Type, 2:Stats)
**
**  @return       Value corresponding
*/
UStrInt GetComponent(const CUnit &unit, int index, EnumVariable e, int t)
{
	UStrInt val;
	CVariable *var;

	Assert((unsigned int) index < UnitTypeVar.GetNumberVariable());

	switch (t) {
		case 0: // Unit:
			var = &unit.Variable[index];
			break;
		case 1: // Type:
			var = &unit.Type->MapDefaultStat.Variables[index];
			break;
		case 2: // Stats:
			var = &unit.Stats->Variables[index];
			break;
		default:
			DebugPrint("Bad value for GetComponent: t = %d" _C_ t);
			var = &unit.Variable[index];
			break;
	}

	switch (e) {
		case VariableValue:
			val.type = USTRINT_INT;
			val.i = var->Value;
			break;
		case VariableMax:
			val.type = USTRINT_INT;
			val.i = var->Max;
			break;
		case VariableIncrease:
			val.type = USTRINT_INT;
			val.i = var->Increase;
			break;
		case VariableDiff:
			val.type = USTRINT_INT;
			val.i = var->Max - var->Value;
			break;
		case VariablePercent:
			Assert(unit.Variable[index].Max != 0);
			val.type = USTRINT_INT;
			val.i = 100 * var->Value / var->Max;
			break;
		case VariableName:
			if (index == GIVERESOURCE_INDEX) {
				val.type = USTRINT_STR;
				val.i = unit.Type->GivesResource;
				val.s = DefaultResourceNames[unit.Type->GivesResource].c_str();
			} else if (index == CARRYRESOURCE_INDEX) {
				val.type = USTRINT_STR;
				val.i = unit.CurrentResource;
				val.s = DefaultResourceNames[unit.CurrentResource].c_str();
			} else {
				val.type = USTRINT_STR;
				val.i = index;
				val.s = UnitTypeVar.VariableNameLookup[index];
			}
			break;
	}
	return val;
}
开发者ID:onkrot,项目名称:stratagus,代码行数:73,代码来源:mainscr.cpp

示例6: DispatchCreateClose

// IRP_MJ_CREATE/IRP_MJ_CLOSE处理函数
NTSTATUS DispatchCreateClose(
    __in PDEVICE_OBJECT DeviceObject,
    __in PIRP Irp
    )
{
    PIO_STACK_LOCATION irpStack;
    NTSTATUS            status;
    PFILE_CONTEXT       fileContext;

    UNREFERENCED_PARAMETER(DeviceObject);

    PAGED_CODE();

    irpStack = IoGetCurrentIrpStackLocation(Irp);

    ASSERT(irpStack->FileObject != NULL);    

    switch (irpStack->MajorFunction)
    {
	case IRP_MJ_CREATE:
		{
			DebugPrint(("IRP_MJ_CREATE\n"));

			fileContext = (PFILE_CONTEXT)ExAllocatePoolWithQuotaTag(
				NonPagedPool, 
				sizeof(FILE_CONTEXT),
				TAG);

			if (NULL == fileContext) 
			{
				status =  STATUS_INSUFFICIENT_RESOURCES;
				break;
			}

			IoInitializeRemoveLock(&fileContext->FileRundownLock, TAG, 0, 0);

			ASSERT(irpStack->FileObject->FsContext == NULL);
			irpStack->FileObject->FsContext = (PVOID) fileContext;

			status = STATUS_SUCCESS;
			break;
		}

	case IRP_MJ_CLOSE:
		{
			DebugPrint(("IRP_MJ_CLOSE\n"));

			fileContext = irpStack->FileObject->FsContext;
			IoAcquireRemoveLock(&fileContext->FileRundownLock, 0);
			IoReleaseRemoveLockAndWait(&fileContext->FileRundownLock, 0);

			ExFreePoolWithTag(fileContext, TAG);

			status = STATUS_SUCCESS;
			break;
		}

	default:
		ASSERT(FALSE);  // should never hit this
		status = STATUS_NOT_IMPLEMENTED;
		break;
    }

    Irp->IoStatus.Status = status;
    Irp->IoStatus.Information = 0;
    IoCompleteRequest(Irp, IO_NO_INCREMENT);
    return status;
}
开发者ID:HiXiaoMing,项目名称:Win_Dev_Driver_Code,代码行数:69,代码来源:Main.c

示例7: AiNewDepotRequest

void AiNewDepotRequest(CUnit &worker)
{
#if 0
    DebugPrint("%d: Worker %d report: Resource [%d] too far from depot, returning time [%d].\n"
               _C_ worker->Player->Index _C_ worker->Slot
               _C_ worker->CurrentResource
               _C_ worker->Data.Move.Cycles);
#endif
    Assert(worker.CurrentAction() == UnitActionResource);
    COrder_Resource &order = *static_cast<COrder_Resource *>(worker.CurrentOrder());

    const Vec2i pos = order.GetHarvestLocation();

    if (pos.x != -1 && NULL != FindDepositNearLoc(*worker.Player, pos, 10, worker.CurrentResource)) {
        /*
         * New Depot has just be finished and worker just return to old depot
         * (far away) from new Deopt.
         */
        return;
    }
    CUnitType *best_type = NULL;
    int best_cost = 0;
    //int best_mask = 0;
    // Count the already made build requests.
    int counter[UnitTypeMax];

    AiGetBuildRequestsCount(*worker.Player->Ai, counter);

    const int n = AiHelpers.Depots[worker.CurrentResource - 1].size();

    for (int i = 0; i < n; ++i) {
        CUnitType &type = *AiHelpers.Depots[worker.CurrentResource - 1][i];

        if (counter[type.Slot]) { // Already ordered.
            return;
        }
        if (!AiRequestedTypeAllowed(*worker.Player, type)) {
            continue;
        }

        // Check if resources available.
        //int needmask = AiCheckUnitTypeCosts(type);
        int cost = 0;
        for (int c = 1; c < MaxCosts; ++c) {
            cost += type.Stats[worker.Player->Index].Costs[c];
        }

        if (best_type == NULL || (cost < best_cost)) {
            best_type = &type;
            best_cost = cost;
            //best_mask = needmask;
        }
    }

    if (best_type) {
        //if(!best_mask) {
        AiBuildQueue queue;

        queue.Type = best_type;
        queue.Want = 1;
        queue.Made = 0;
        queue.Pos = pos;

        worker.Player->Ai->UnitTypeBuilt.push_back(queue);

        DebugPrint("%d: Worker %d report: Requesting new depot near [%d,%d].\n"
                   _C_ worker.Player->Index _C_ UnitNumber(worker)
                   _C_ queue.Pos.x _C_ queue.Pos.y);
        /*
        } else {
        	AiPlayer->NeededMask |= best_mask;
        }
        */
    }
}
开发者ID:saeyoonlee,项目名称:Stratagus,代码行数:75,代码来源:ai_resource.cpp

示例8: read_write_mode

ssize_t read_write_mode(int fd, OriginF fn, const char* hook_fn_name, uint32_t event, int timeout_so, Args && ... args)
{
    DebugPrint(dbg_hook, "hook %s. %s coroutine.", hook_fn_name, g_Scheduler.IsCoroutine() ? "In" : "Not in");

    if (!g_Scheduler.IsCoroutine()) {
        return fn(fd, std::forward<Args>(args)...);
    } else {
        int flags = fcntl(fd, F_GETFL, 0);
        if (flags & O_NONBLOCK)
            return fn(fd, std::forward<Args>(args)...);

        if (-1 == fcntl(fd, F_SETFL, flags | O_NONBLOCK))
            return fn(fd, std::forward<Args>(args)...);

        ssize_t n = fn(fd, std::forward<Args>(args)...);
        if (n == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
            // get timeout option.
            Task* tk = g_Scheduler.GetCurrentTask();
            uint64_t timer_id = 0;
            struct timeval timeout;
            socklen_t timeout_blen = sizeof(timeout);
            if (0 == getsockopt(fd, SOL_SOCKET, timeout_so, &timeout, &timeout_blen)) {
                if (timeout.tv_sec > 0 || timeout.tv_usec > 0) {
                    std::chrono::milliseconds duration{timeout.tv_sec * 1000 +
                        timeout.tv_usec / 1000};
                    DebugPrint(dbg_hook, "hook task(%s) %s timeout=%dms. fd=%d",
                            g_Scheduler.GetCurrentTaskDebugInfo(), hook_fn_name, (int)duration.count(), fd);
                    tk->IncrementRef(); // timer use ref.
                    timer_id = g_Scheduler.ExpireAt(duration, [=]{
                            g_Scheduler.IOBlockCancel(tk);
                            tk->DecrementRef(); // timer use ref.
                            });
                }
            }

            // add into epoll, and switch other context.
            g_Scheduler.IOBlockSwitch(fd, event);
            bool is_timeout = false;
            if (timer_id) {
                is_timeout = true;
                if (g_Scheduler.CancelTimer(timer_id)) {
                    is_timeout = false;
                    tk->DecrementRef(); // timer use ref.
                }
            }

            if (tk->wait_successful_ == 0) {
                if (is_timeout) {
                    fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
                    errno = EAGAIN;
                    return -1;
                } else {
                    fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
                    return fn(fd, std::forward<Args>(args)...);
                }
            }

            DebugPrint(dbg_hook, "continue task(%s) %s. fd=%d", g_Scheduler.GetCurrentTaskDebugInfo(), hook_fn_name, fd);
            n = fn(fd, std::forward<Args>(args)...);
        } else {
            DebugPrint(dbg_hook, "task(%s) syscall(%s) completed immediately. fd=%d",
                    g_Scheduler.GetCurrentTaskDebugInfo(), hook_fn_name, fd);
        }

        int e = errno;
        fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
        errno = e;
        return n;
    }
}
开发者ID:jiuaiwo1314,项目名称:cpp_features,代码行数:70,代码来源:linux_glibc_hook.cpp

示例9: DebugPrint

string ExactMatchingRule::ToString() const
{
  ostringstream os;
  os << "ExactMatchingRule [ " << DebugPrint(m_mwmId) << ", " << DebugPrint(m_feature) << " ]";
  return os.str();
}
开发者ID:milchakov,项目名称:omim,代码行数:6,代码来源:test_results_matching.cpp

示例10: SetCommLineStatus

int GSM::begin(long baud_rate){
	int response=-1;
	int cont=0;
	boolean norep=false;
	boolean turnedON=false;
	SetCommLineStatus(CLS_ATCMD);
	_cell.begin(baud_rate);
	setStatus(IDLE); 

	
	for (cont=0; cont<3; cont++){
		if (AT_RESP_ERR_NO_RESP == SendATCmdWaitResp("AT", 500, 100, "OK", 5)&&!turnedON) {		//check power
	    // there is no response => turn on the module
			#ifdef DEBUG_ON
				Serial.println("DB:NO RESP");
			#endif
			// generate turn on pulse
			digitalWrite(GSM_ON, HIGH);
			delay(1200);
			digitalWrite(GSM_ON, LOW);
			delay(10000);
			norep=true;
		}
		else{
			#ifdef DEBUG_ON
				Serial.println("DB:ELSE");
			#endif
			norep=false;
		}
	}
	
	if (AT_RESP_OK == SendATCmdWaitResp("AT", 500, 100, "OK", 5)){
		#ifdef DEBUG_ON
			Serial.println("DB:CORRECT BR");
		#endif
		turnedON=true;
	}
	if(cont==3&&norep){
		Serial.println("ERROR: SIM900 doesn't answer. Check power and serial pins in GSM.cpp");
		return 0;
	}


	if (AT_RESP_ERR_DIF_RESP == SendATCmdWaitResp("AT", 500, 100, "OK", 5)&&!turnedON){		//check OK
		#ifdef DEBUG_ON
			Serial.println("DB:DIFF RESP");
		#endif
		for (int i=1;i<8;i++){
			switch (i) {
			case 1:
			  _cell.begin(2400);
			  break;
			  
			case 2:
			  _cell.begin(4800);
			  break;
			  
			case 3:
			  _cell.begin(9600);
			  break;
			   
			case 4:
			  _cell.begin(19200);
			  break;
			  
			case 5:
			  _cell.begin(38400);
			  break;
			  
			case 6:
			  _cell.begin(57600);
			  break;
			  
			case 7:
			  _cell.begin(115200);
			  _cell.print("AT+IPR=9600\r");
			  _cell.begin(9600);
			  delay(500);
			  break;
  
			// if nothing else matches, do the default
			// default is optional
			}
					
			delay(100);

			#ifdef DEBUG_PRINT
				// parameter 0 - because module is off so it is not necessary 
				// to send finish AT<CR> here
				DebugPrint("DEBUG: Stringa ", 0);
				DebugPrint(buff, 0);
			#endif
				

			if (AT_RESP_OK == SendATCmdWaitResp("AT", 500, 100, "OK", 5)){
				#ifdef DEBUG_ON
					Serial.println("DB:FOUND PREV BR");
				#endif
				_cell.print("AT+IPR=");
				_cell.print(baud_rate);    
//.........这里部分代码省略.........
开发者ID:fffaraz,项目名称:gpst,代码行数:101,代码来源:GSM.cpp

示例11: Inverse


//.........这里部分代码省略.........
			u = inc;
			v = inc;
			ct = 0;
			for (int y = 0; y < sampleRate; y++)
				{
				u = inc;
				for (int x = 0; x < sampleRate; x++)
					{
					Point3 pt = p->interp(patch, u, v);
					patchPoints[ct] = pt;
					ct++;
					u += inc;
					}
				v += inc;
				}

			
			for (int j = 0; j < pointCount; j++)
				{

				if ((ip) && ((j%10) == 0))
					{
					TSTR name;
					name.printf(GetString(IDS_COMPLETED_PCT_W_COUNT),(float) i / numPatches *100.0f,j,pointCount);
					SetWindowText(GetDlgItem(hWnd,IDC_STATUS),name);
					}
				if (closestPoint[j] == i)
					{
					int closest = -1;
					float d= 0.0f;

					for (int k = 0; k <  sampleRate*sampleRate; k++)
						{
						float len = LengthSquared(patchPoints[k]-pointData[j]);
						if ((closest == -1) || (len<d))
							{
							d = len;
							closest = k;							
							}
						}	
					
					localData->paramData[j].uv.y = float (closest/sampleRate);
					localData->paramData[j].uv.x = float (closest - (localData->paramData[j].uv.y*sampleRate));

					localData->paramData[j].uv.y = (localData->paramData[j].uv.y +1) * inc;
					localData->paramData[j].uv.x = (localData->paramData[j].uv.x +1) * inc;		
					localData->paramData[j].patchIndex = i;

//get the u vec
					float u = localData->paramData[j].uv.x;
					float v = localData->paramData[j].uv.y;
					float delta = 1.0f/(sampleRate+1.0f)*0.5f;
					float du = u-delta;
					float dv = v-delta;

if (du <= 0.0f) DebugPrint(_T("error du 0.0f \n"));
if (dv <= 0.0f) DebugPrint(_T("error dv 0.0f \n"));
if (du >= 1.0f) DebugPrint(_T("error du 1.0f \n"));
if (dv >= 1.0f) DebugPrint(_T("error dv 1.0f \n"));

					localData->incDelta = delta;

					Patch *p = &patch->patches[i];

					Point3 uVec = Normalize(p->interp(patch, du, v)-patchPoints[closest]);
//get the v vec
					Point3 vVec = Normalize(p->interp(patch, u, dv)-patchPoints[closest]);

					Point3 xAxis,yAxis,zAxis;
					xAxis = uVec;
					zAxis = CrossProd(uVec,vVec);
					yAxis = CrossProd(xAxis,zAxis);

					Point3 center = patchPoints[closest];

					Matrix3 tm(xAxis,yAxis,zAxis,center);
/*DebugPrint(_T("init %d\n"),j);*/
/*DebugPrint(_T("%f %f %f\n"),xAxis.x,xAxis.y,xAxis.z);
DebugPrint(_T("%f %f %f\n"),yAxis.x,yAxis.y,yAxis.z);
DebugPrint(_T("%f %f %f\n"),zAxis.x,zAxis.y,zAxis.z);
DebugPrint(_T("%f %f %f\n"),center.x,center.y,center.z);*/

					localData->paramData[j].initialPoint = pointData[j]*Inverse(tm);
//DebugPrint(_T("init %d\n"),j);

					}
				}
			
			}
		}

	if (ip)
		{
		TSTR name;
		name.printf(_T("%s"),GetString(IDS_PICK));
		SetWindowText(GetDlgItem(hWnd,IDC_STATUS),name);
		}

//split the patch into sub samples chunk
	}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:101,代码来源:SkinWrapPatch.cpp

示例12: MPSetPowerLowPrivate

BOOLEAN
MPSetPowerLowPrivate(
    PVOID Context
    )
/*++
Routine Description:

    The section follows the steps mentioned in
    Section C.2.6.2 of the Reference Manual.


Arguments:

    Adapter     Pointer to our adapter

Return Value:

--*/
{
    CSR_FILTER_STRUC    Filter;
    USHORT              IntStatus;
    MP_PMCSR            PMCSR = {0};
    ULONG               ulResult;
    PFDO_DATA FdoData = Context;

    DebugPrint(TRACE, DBG_POWER, "-->MPSetPowerLowPrivate\n");
    RtlZeroMemory (&Filter, sizeof (Filter));

    do
    {

        //
        // Before issue the command to low power state, we should disable the
        // interrup and ack all the pending interrupts, then set the adapter's power to
        // low state.
        //
        NICDisableInterrupt(FdoData);
        NIC_ACK_INTERRUPT(FdoData, IntStatus);

        //
        // If the driver should wake up the machine
        //
        if (FdoData->AllowWakeArming)
        {
            //
            // Send the WakeUp Patter to the nic
            MPIssueScbPoMgmtCommand(FdoData, &Filter, TRUE);


            //
            // Section C.2.6.2 - The driver needs to wait for the CU to idle
            // The above function already waits for the CU to idle
            //
            ASSERT ((FdoData->CSRAddress->ScbStatus & SCB_CUS_MASK) == SCB_CUS_IDLE);
        }
        else
        {

            ulResult = FdoData->BusInterface.GetBusData(
                                    FdoData->BusInterface.Context,
                                    PCI_WHICHSPACE_CONFIG,
                                    (PVOID)&PMCSR,
                                    FIELD_OFFSET(MP_PM_PCI_SPACE, PMCSR),
                                    sizeof(PMCSR));

            if(ulResult != sizeof(PMCSR)){
                ASSERT(ulResult == sizeof(PMCSR));
                DebugPrint(ERROR, DBG_POWER, "GetBusData for PMCSR failed\n");
                return FALSE;
            }
            if (PMCSR.PME_En == 1)
            {
                //
                // PME is enabled. Clear the PME_En bit.
                // So that it is not asserted
                //
                MpClearPME_En (FdoData,PMCSR);

            }

            //
            // Set the driver to lower power state by OS
            //
        }



    } while (FALSE);

    DebugPrint(TRACE, DBG_POWER, "<--MPSetPowerLowPrivate\n");

    return TRUE;
}
开发者ID:kcrazy,项目名称:winekit,代码行数:93,代码来源:nic_pm.c

示例13: NetSocketAddr

// ARI: I knew how to write this for a unix environment,
// but am quite certain that porting this can cause you
// trouble..
int NetSocketAddr(const Socket sock, unsigned long *ips, int maxAddr)
{
	if (sock == static_cast<Socket>(-1)) {
		return 0;
	}
	char buf[4096];
	struct ifconf ifc;
	ifc.ifc_len = sizeof(buf);
	ifc.ifc_buf = buf;
	if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
		DebugPrint("SIOCGIFCONF - errno %d\n" _C_ errno);
		return 0;
	}
	// with some inspiration from routed..
	int nif = 0;
	struct ifreq *ifr = ifc.ifc_req;
	char *cplim = buf + ifc.ifc_len; // skip over if's with big ifr_addr's

	for (char *cp = buf; cp < cplim;
		 cp += sizeof(ifr->ifr_name) + sizeof(ifr->ifr_ifru)) {
		ifr = (struct ifreq *)cp;
		struct ifreq ifreq = *ifr;
		if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
			DebugPrint("%s: SIOCGIFFLAGS - errno %d\n" _C_
					   ifr->ifr_name _C_ errno);
			continue;
		}
		if ((ifreq.ifr_flags & IFF_UP) == 0 || ifr->ifr_addr.sa_family == AF_UNSPEC) {
			continue;
		}
		// argh, this'll have to change sometime
		if (ifr->ifr_addr.sa_family != AF_INET) {
			continue;
		}
		if (ifreq.ifr_flags & IFF_LOOPBACK) {
			continue;
		}
		struct sockaddr_in *sap = (struct sockaddr_in *)&ifr->ifr_addr;
		struct sockaddr_in sa = *sap;
		ips[nif] = sap->sin_addr.s_addr;
		if (ifreq.ifr_flags & IFF_POINTOPOINT) {
			if (ioctl(sock, SIOCGIFDSTADDR, (char *)&ifreq) < 0) {
				DebugPrint("%s: SIOCGIFDSTADDR - errno %d\n" _C_
						   ifr->ifr_name _C_ errno);
				// failed to obtain dst addr - ignore
				continue;
			}
			if (ifr->ifr_addr.sa_family == AF_UNSPEC) {
				continue;
			}
		}
		// avoid p-t-p links with common src
		if (nif) {
			int i;
			for (i = 0; i < nif; ++i) {
				if (sa.sin_addr.s_addr == ips[i]) {
					i = -1;
					break;
				}
			}
			if (i == -1) {
				continue;
			}
		}
		++nif;
		if (nif == maxAddr) {
			break;
		}
	}
	return nif;
}
开发者ID:realhidden,项目名称:stratagus,代码行数:74,代码来源:net_lowlevel.cpp

示例14: MPSetUpFilterCB

NTSTATUS
MPSetUpFilterCB(
    __in PFDO_DATA FdoData
    )
{
    NTSTATUS         status = STATUS_SUCCESS;
    PCB_HEADER_STRUC    NonTxCmdBlockHdr = (PCB_HEADER_STRUC)FdoData->NonTxCmdBlock;
    PFILTER_CB_STRUC    pFilterCb = (PFILTER_CB_STRUC)NonTxCmdBlockHdr;
    ULONG               Curr = 0;
    ULONG               Next = 0;
    PLIST_ENTRY         pPatternEntry = ListNext(&FdoData->PoMgmt.PatternList) ;

    DebugPrint(TRACE, DBG_POWER, "--> MPSetUpFilterCB\n");

    RtlZeroMemory (pFilterCb, sizeof(*pFilterCb));

    // Individual Address Setup
    NonTxCmdBlockHdr->CbStatus = 0;
    NonTxCmdBlockHdr->CbCommand = CB_EL_BIT | CB_LOAD_PROG_FILTER;
    NonTxCmdBlockHdr->CbLinkPointer = DRIVER_NULL;




    // go through each filter in the list.

    while (pPatternEntry != (&FdoData->PoMgmt.PatternList))
    {
        PMP_WAKE_PATTERN            pWakeUpPattern = NULL;

        // initialize local variables
        pWakeUpPattern = CONTAINING_RECORD(pPatternEntry, MP_WAKE_PATTERN, linkListEntry);

        // increment the iterator
        pPatternEntry = ListNext (pPatternEntry);

        // Update the Curr Array Pointer
        Curr = Next;

        // Create the Programmable filter for this device.
        MPCreateProgrammableFilter (pWakeUpPattern , &pFilterCb->Pattern[Curr], &Next);

        if (Next >=16)
        {
            break;
        }

    }

    {
        // Set the EL bit on the last pattern
        PUCHAR pLastPattern = (PUCHAR) &pFilterCb->Pattern[Curr];

        // Get to bit 31
        pLastPattern[3] |= CB_FILTER_EL ;


    }

    ASSERT(FdoData->CSRAddress->ScbCommandLow == 0);

    //  Wait for the CU to Idle before giving it this command
    if(!WaitScb(FdoData))
    {
        status = STATUS_DEVICE_DATA_ERROR;
    }

    DebugPrint(TRACE, DBG_POWER, "<-- MPSetUpFilterCB\n");

    return status;


}
开发者ID:kcrazy,项目名称:winekit,代码行数:73,代码来源:nic_pm.c

示例15: while


//.........这里部分代码省略.........
				/* pixel position */
				index=atoi(ss.GetWord(1)->GetString())-1;
				m_coords[index].x=atoi(ss.GetWord(2)->GetString());
				m_coords[index].y=atoi(ss.GetWord(3)->GetString());
			}
			else if(!strcmp(ss.GetWord(0)->GetString(),"MMPLL"))
			{
				/* latitude/longitude position */
				index=atoi(ss.GetWord(1)->GetString())-1;
				m_coords[index].lon=atof(ss.GetWord(2)->GetString());
				m_coords[index].lat=atof(ss.GetWord(3)->GetString());
			}
		}
		++linenum;
	}while(dh.Eof()==false);
	dh.Close();

	/* calculate bounding rectanle for lat/lon */
	m_minlat=m_coords[0].lat;
	maxlat=m_coords[0].lat;
	m_minlon=m_coords[0].lon;
	maxlon=m_coords[0].lon;
	m_minx=m_coords[0].x;
	maxx=m_coords[0].x;
	m_miny=m_coords[0].y;
	maxy=m_coords[0].y;
	for(index=1;index<4;++index)
	{
		if(m_coords[index].lat<m_minlat)
		{
			m_minlat=m_coords[index].lat;
			m_miny=m_coords[index].y;
		}
		if(m_coords[index].lat>maxlat)
		{
			maxlat=m_coords[index].lat;
			maxy=m_coords[index].y;
		}

		if(m_coords[index].lon<m_minlon)
		{
			m_minlon=m_coords[index].lon;
			m_minx=m_coords[index].x;
		}
		if(m_coords[index].lon>maxlon)
		{
			maxlon=m_coords[index].lon;
			maxx=m_coords[index].x;
		}
	}

	/* assume linear for now until I figure out the projection */
	m_slx=(maxlon-m_minlon)/(maxx-m_minx);
	m_sly=(maxlat-m_minlat)/(maxy-m_miny);
	m_lsx=(maxx-m_minx)/(maxlon-m_minlon);
	m_lsy=(maxy-m_miny)/(maxlat-m_minlat);

	for(index=0;index<4;++index)
	{
		GPXCoord c;
		int sx,sy;

		c.Set(m_coords[index].lat,m_coords[index].lon);
		ToMap(&c,&sx,&sy);
		DebugPrint("Coord testing %f,%f %d,%d - %d,%d",m_coords[index].lat,m_coords[index].lon,m_coords[index].x,m_coords[index].y,sx,sy);
	}

	/* load the map file with the tiles */
	fp=kGUI::LoadFile(ozfn.GetString(),&filesize);
	if(!fp)
		return;	/* couldn't load file */

	m_filedata=fp;	/* save pointer to data so destructor will free it up upon exiting */
	oh=(OZ2FHEADER_DEF *)fp;
	
	if(oh->wSignature!=0x7778)
		return;	/* not valid format */

	assert ((oh->wPlanes==1) && (oh->wBitsPerPixel==8),"Unsupported bitmap format" );

	SetTileSize(64,64);

	/* parse the tile data */

	const int dwMasterTblOffset = * reinterpret_cast<const int *> (fp + filesize - 4);
	const int * const pdwMasterTbl = reinterpret_cast<const int *> (fp + dwMasterTblOffset);

	const int zoomlevels = (filesize - 4 - dwMasterTblOffset)/4;
	SetZoomLevels(1,zoomlevels);
	m_bitmaps.Alloc(zoomlevels);
	z=zoomlevels-1;
	for (int zoomlevel = 0; zoomlevel < zoomlevels; ++ zoomlevel)
	{
		OZ2FBITMAP_DEF *ih = (OZ2FBITMAP_DEF *) (fp + pdwMasterTbl [zoomlevel]);

		m_bitmaps.SetEntry(z,ih);
		SetSize(z,ih->dwImageWidth,ih->dwImageHeight);
		--z;
	}
}
开发者ID:neolu,项目名称:gpsturbo,代码行数:101,代码来源:ozmap.cpp


注:本文中的DebugPrint函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。