コード例 #1
0
ファイル: slck.c プロジェクト: Flyagin/BS-MRZV
//------------------------------------------------------------------------------
/// Configure the RC oscillator for the slow clock
//------------------------------------------------------------------------------
void SLCK_32ktoRC(void)
{
    // Check that the master clock has a different source than slow clock.
    if( (AT91C_BASE_PMC->PMC_MCKR & AT91C_PMC_CSS) == 0)
    {
        TRACE_WARNING("The master clock use the slow clock. " \
            "Not possible to change Slow clock\n\r");
        return;
    }

    // Check that the slow clock source is RC
    if( !SLCK_Is32k() )
    {
        TRACE_WARNING("The slow clock is already the internal RC oscillator\n\r");
        return;
    }

    // Enable the internal RC oscillator by setting the bit RCEN to 1
    *AT91C_SYS_SLCKSEL |= AT91C_SLCKSEL_RCEN;

    // Wait internal RC Startup Time for clock stabilization (software loop).
    WaitTimeInUs(BOARD_MCK*2, T_ST_SLCK_RC_IN_US);

    // Switch from 32768 Hz oscillator to internal RC by setting the bit OSCSEL to 0.
    *AT91C_SYS_SLCKSEL &= (0xFFFFFFFF ^ AT91C_SLCKSEL_OSCSEL);

    // Wait 5 slow clock cycles for internal resynchronization.
    WaitTimeInUs(BOARD_MCK*2, TIME_5_CYCLES_RC_IN_US);

    // Disable the 32768 Hz oscillator by setting the bit OSC32EN to 0.
    *AT91C_SYS_SLCKSEL &= (0xFFFFFFFF ^ AT91C_SLCKSEL_OSC32EN);

    TRACE_INFO("The slow clock is now the internal RC oscillator\n\r");
}
コード例 #2
0
ファイル: slck.c プロジェクト: Flyagin/BS-MRZV
//------------------------------------------------------------------------------
/// Configure the 32kHz oscillator for the slow clock
//------------------------------------------------------------------------------
void SLCK_RCto32k(void)
{
    unsigned int timeout = 0;

    // Check that the master clock has a different source than slow clock. If no,
    if( (AT91C_BASE_PMC->PMC_MCKR & AT91C_PMC_CSS) == 0)
    {
        TRACE_WARNING("The master clock use the slow clock. " \
            "Not possible to change Slow clock\n\r");
        return;
    }

    // Check that the slow clock source is RC
    if( SLCK_Is32k() )
    {
        TRACE_WARNING("The slow clock is already the external 32.768kHz crystal\n\r");
        return;
    }

    // Select the internal RC oscillator by set  XTALSEL to 1.
    AT91C_BASE_SUPC->SUPC_CR = AT91C_SUPC_CR_XTALSEL_CRYSTAL_SEL | (0xA5 << 24);
    timeout = 0;
    while (!(AT91C_BASE_SUPC->SUPC_SR & AT91C_SUPC_SR_OSCSEL_CRYST) && (timeout++ < CLOCK_TIMEOUT));

    TRACE_INFO("The slow clock is now the external 32.768kHz crystal\n\r");
}
コード例 #3
0
ファイル: main.c プロジェクト: gstroe/Arm
/*----------------------------------------------------------------------------
 * Callback invoked when data has been received on the USB.
 *----------------------------------------------------------------------------*/
static void _UsbDataReceived(uint32_t unused,
							 uint8_t status,
							 uint32_t received,
							 uint32_t remaining)
{
	unused = unused;
	Usart *pUs = BASE_USART;

	/* Check that data has been received successfully */
	if (status == USBD_STATUS_SUCCESS) {

		SCB_InvalidateDCache_by_Addr((uint32_t *)usbBuffer, received);

		/* Send back CDC data */
		if (isCdcEchoON) {
			while (CDCDSerialDriver_Write(usbBuffer, received, 0, 0)
				   != USBD_STATUS_SUCCESS);
		}

		/* Send data through USART */
		if (isCdcSerialON)
			_UsartDmaTx((uint32_t)&pUs->US_THR, usbBuffer, received);

		/* Check if bytes have been discarded */
		if ((received == DATAPACKETSIZE) && (remaining > 0)) {
			TRACE_WARNING(
				"_UsbDataReceived: %u bytes discarded\n\r",
				(unsigned int)remaining);
		}
	} else {
		TRACE_WARNING("_UsbDataReceived: Transfer error\n\r");
	}
}
コード例 #4
0
ファイル: MULTIDriver.c プロジェクト: 12019/at91work
//-----------------------------------------------------------------------------
/// Handles composite-specific USB requests sent by the host, and forwards
/// standard ones to the USB device driver.
/// \param request Pointer to a USBGenericRequest instance.
//-----------------------------------------------------------------------------
void MULTIDriver_RequestHandler(const USBGenericRequest *request)
{
    // Check if this is a class request
    if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) {

        unsigned char rc = 0;

        //rc = CCID_RequestHandler(request);
        if (!rc) {
            TRACE_WARNING(
              "MULTIDriver_RequestHandler: Unsupported request (%d)\n\r",
              USBGenericRequest_GetRequest(request));
            USBD_Stall(0);
        }

    }
    // Check if this is a standard request
    else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) {

        unsigned char rc = 0;

        // Forward request to the standard handler
        if (rc == 0)
            USBDDriver_RequestHandler(&(usbdDriver), request);
    }
    // Unsupported request type
    else {
        TRACE_WARNING(
          "MULTIDriver_RequestHandler: Unsupported request type (%d)\n\r",
          USBGenericRequest_GetType(request));
        USBD_Stall(0);
    }
}
コード例 #5
0
ファイル: main.c プロジェクト: kaiman1234/a-culfw
//------------------------------------------------------------------------------
/// Callback invoked when data has been received on the USB.
//------------------------------------------------------------------------------
static void UsbDataReceived(unsigned int unused,
                            unsigned char status,
                            unsigned int received,
                            unsigned int remaining)
{
  // Check that data has been received successfully
  if (status == USBD_STATUS_SUCCESS) {

    for(unsigned int i=0;i<received;i++) {
      rb_put(&TTY_Rx_Buffer, usbBuffer[i]);
    }

      // Check if bytes have been discarded
      if ((received == DATABUFFERSIZE) && (remaining > 0)) {

        TRACE_WARNING("UsbDataReceived: %u bytes discarded\n\r",remaining);
      }
  }
  else {

    TRACE_WARNING( "UsbDataReceived: Transfer error\n\r");
  }

  // Restart USB read
  CDCDSerialDriver_Read(usbBuffer,
           DATABUFFERSIZE,
           (TransferCallback) UsbDataReceived,
           0);

}
コード例 #6
0
ファイル: network_client.c プロジェクト: waycom/h6
static int32_t
network_client_init(client_t *c, void *data)
{
	network_client *nc = (network_client*)c;
	init_parm *parm = (init_parm*)data;
	int32_t err;

	err = init_this(nc, parm->factory, parm->io);
	if (err)
	{
		TRACE_WARNING("network_client_init()->init_this() failed.");
		return err;
	}

	nc->ops = parm->opts;
	if (nc->ops && nc->ops->init)
	{
		err = (*nc->ops->init)(nc);
		if (err)
		{
			TRACE_WARNING("network_client_init()->(*nc->ops->init)() failed.");
			nc->ops = NULL;
			finalize_this(nc); //@{obj_unref() can't reach this layer}
			return err;
		}
	}

	return 0;
}
コード例 #7
0
ファイル: slck.c プロジェクト: Flyagin/BS-MRZV
//------------------------------------------------------------------------------
/// Configure the 32kHz oscillator for the slow clock
//------------------------------------------------------------------------------
void SLCK_RCto32k(void)
{
    // Check that the master clock has a different source than slow clock. If no,
    if( (AT91C_BASE_PMC->PMC_MCKR & AT91C_PMC_CSS) == 0)
    {
        TRACE_WARNING("The master clock use the slow clock. " \
            "Not possible to change Slow clock\n\r");
        return;
    }

    // Check that the slow clock source is RC
    if( SLCK_Is32k() )
    {
        TRACE_WARNING("The slow clock is already the external 32.768kHz crystal\n\r");
        return;
    }

    // Enable the 32,768 Hz oscillator by setting the bit OSC32K_XT_EN to 1.
    *AT91C_SYS_SYS_OSCMR |= AT91C_OSC32K_XT_EN;

    // Wait 32,768 Hz Startup Time for clock stabilization (software loop).
    WaitTimeInMs(BOARD_MCK, /*T_ST_SLCK_32K_IN_MS*/10);

    // Switch from internal RC to 32,768 Hz oscillator by setting the bit OSC32K_SEL to 1.
    *AT91C_SYS_SYS_OSCMR |= AT91C_OSC32K_SEL;

    TRACE_INFO("The slow clock is now the external 32.768kHz crystal\n\r");
}
コード例 #8
0
ファイル: main.c プロジェクト: NissankaW/Mariokart3
//------------------------------------------------------------------------------
/// Callback invoked when data has been received on the USB.
//------------------------------------------------------------------------------
static void UsbDataReceived(unsigned int unused,
                            unsigned char status,
                            unsigned int received,
                            unsigned int remaining)
{
    // Check that data has been received successfully
    if (status == USBD_STATUS_SUCCESS) {

        // Send data through USART
        while (!USART_WriteBuffer(AT91C_BASE_US0, usbBuffer, received));
        AT91C_BASE_US0->US_IER = AT91C_US_TXBUFE;

        // Check if bytes have been discarded
        if ((received == DATABUFFERSIZE) && (remaining > 0)) {

            TRACE_WARNING(
                      "UsbDataReceived: %u bytes discarded\n\r",
                      remaining);
        }
    }
    else {

        TRACE_WARNING( "UsbDataReceived: Transfer error\n\r");
    }
}
コード例 #9
0
ファイル: fast_source.c プロジェクト: JiaoXianjun/osmo-sdr
void fastsource_req_hdlr(const USBGenericRequest *request)
{
	unsigned char entity;
	unsigned char interface;

	switch (USBGenericRequest_GetType(request)) {
	case USBGenericRequest_STANDARD:
		USBDDriver_RequestHandler(&fast_source_driver, request);
		return;
	case USBGenericRequest_CLASS:
		/* continue below */
		break;
	default:
		TRACE_WARNING("Unsupported request type %u\n\r",
				USBGenericRequest_GetType(request));
		USBD_Stall(0);
		return;
	}

	switch (USBGenericRequest_GetRequest(request)) {
	case AUDGenericRequest_SETCUR:
		entity = AUDGenericRequest_GetEntity(request);
		interface = AUDGenericRequest_GetInterface(request);
		if (((entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT) ||
		     (entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC)) &&
		    (interface == AUDDLoopRecDriverDescriptors_CONTROL)) {
			fastsource_set_feat_cur_val(entity,
				AUDFeatureUnitRequest_GetChannel(request),
				AUDFeatureUnitRequest_GetControl(request),
				USBGenericRequest_GetLength(request));
		} else {
			TRACE_WARNING("Unsupported entity/interface combination 0x%04x\n\r",
					USBGenericRequest_GetIndex(request));
			USBD_Stall(0);
		}
		break;
	case AUDGenericRequest_GETCUR:
		entity = AUDGenericRequest_GetEntity(request);
		interface = AUDGenericRequest_GetInterface(request);
		if (((entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT) ||
		     (entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC)) &&
		    (interface == AUDDLoopRecDriverDescriptors_CONTROL)) {
			fastsource_get_feat_cur_val(entity,
				AUDFeatureUnitRequest_GetChannel(request),
				AUDFeatureUnitRequest_GetControl(request),
				USBGenericRequest_GetLength(request));
		} else {
			TRACE_WARNING("Unsupported entity/interface combination 0x%04x\n\r",
					USBGenericRequest_GetIndex(request));
			USBD_Stall(0);
		}
		break;
	default:
		TRACE_WARNING("Unsupported request %u\n\r",
				USBGenericRequest_GetIndex(request));
		USBD_Stall(0);
		break;
	}
}
コード例 #10
0
ファイル: SpyServer.c プロジェクト: 340211173/hf-2011
BOOL SpySrv_KillProcess (PROCADDR nProcessAddress, BOOL bKernelModeKill) 
{
  BOOL		bSuccess ;

  if( ! bKernelModeKill )
    {
      PROCSTRUCT	*pProc ;
      HANDLE		hProcess ;
      UINT		nProcessId ;

      ProcList_Lock () ;
      pProc = ProcList_Get (nProcessAddress) ;
      if( pProc ) nProcessId = pProc->nProcessId ;
      ProcList_Unlock () ;
      
      if( pProc==NULL )
	{
	  TRACE_WARNING (TEXT("Tryed to kill an unknown process\n")) ;
	}
      else if( nProcessId==GetCurrentProcessId() )
	{
	  TRACE_WARNING (TEXT("Refused to kill my process\n")) ;
	  bSuccess = FALSE ;
	}
      else
	{
	  hProcess = OpenProcess (PROCESS_TERMINATE, FALSE, nProcessId) ;
	  
	  if( ! hProcess ) 
	    {
	      TRACE_WARNING (TEXT("OpenProcess failed (error=%u)\n"), GetLastError()) ;
	      return FALSE ;
	    }
	  
	  bSuccess = TerminateProcess (hProcess, 0) ;  
	  CloseHandle (hProcess) ;
	  
	  if( ! bSuccess )
	    TRACE_ERROR (TEXT("TerminateProcess failed (error=%u)\n"), GetLastError()) ;
	}
    }
  else
    { 
      DWORD	nBytesReturned ;
    
      bSuccess = DeviceIoControl (g_hDriver, IOCTL_KILL_PROCESS, 
				  &nProcessAddress, sizeof(nProcessAddress), 
				  NULL, 0, &nBytesReturned, NULL) ;
      
      if( ! bSuccess )
	TRACE_ERROR (TEXT("DeviceIoControl failed (error=%u)\n"), GetLastError()) ;     
    }
  
  return bSuccess ;
}
コード例 #11
0
int SerialPortMacOS::convertBaudRateFlag(int baudrate)
{
    int baudRateFlag = 0;

    // Set termios baudrate flag
    if (baudrate > 0)
    {
        // Try an exact match
        baudRateFlag = rate_to_constant(baudrate);

        if (baudRateFlag != 0)
        {
            TRACE_1(SERIAL, "convertBaudRateFlag(%i) has been set to %i (exact match)\n", baudrate, baudrate);
        }
        else
        {
            int speeds[20] = {2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400,
                              460800, 500000, 576000, 921600, 1000000, 1152000,
                              1500000, 2000000, 2500000, 3000000, 3500000, 4000000};

            // Try a "close enough" match (we allow ±1.5% mismatch)
            for (int i = 0; i < 20; i++)
            {
                if ((baudrate > (static_cast<double>(speeds[i]) * 98.5 / 100.0)) && (baudrate < (static_cast<double>(speeds[i]) * 101.5 / 100.0)))
                {
                    baudRateFlag = rate_to_constant(speeds[i]);
                    TRACE_WARNING(SERIAL, "convertBaudRateFlag(%i) has been set to B%i (close enough match, ±1.5%)\n", baudrate, speeds[i]);
                    break;
                }
            }

            // Try a custom speed
            if (baudRateFlag == 0)
            {
                ttyCustomSpeed = true;
                baudRateFlag = B38400;
                TRACE_WARNING(SERIAL, "convertBaudRateFlag(%i) has been set to B38400 (custom speed will be used)\n", baudrate);
            }
        }
    }
    else
    {
        TRACE_ERROR(SERIAL, "Invalid baudrate, using default value of: B1000000\n");
    }

    // Fallback
    if (baudRateFlag == 0)
    {
        baudRateFlag = B1000000;
        TRACE_ERROR(SERIAL, "Unable to set baud speed at %i: too slow!\n", baudrate);
        TRACE_ERROR(SERIAL, "Invalid baudrate, using default value of: B1000000\n");
    }

    return baudRateFlag;
}
コード例 #12
0
ファイル: icmp.c プロジェクト: nandojve/embedded
void icmpProcessMessage(NetInterface *interface,
                        Ipv4Addr srcIpAddr, const ChunkedBuffer *buffer, size_t offset)
{
    size_t length;
    IcmpHeader *header;

    //Retrieve the length of the ICMP message
    length = chunkedBufferGetLength(buffer) - offset;

    //Ensure the message length is correct
    if(length < sizeof(IcmpHeader))
    {
        //Debug message
        TRACE_WARNING("ICMP message length is invalid!\r\n");
        //Silently discard incoming message
        return;
    }

    //Point to the ICMP message header
    header = chunkedBufferAt(buffer, offset);
    //Sanity check
    if(!header) return;

    //Debug message
    TRACE_INFO("ICMP message received (%" PRIuSIZE " bytes)...\r\n", length);
    //Dump message contents for debugging purpose
    icmpDumpMessage(header);

    //Verify checksum value
    if(ipCalcChecksumEx(buffer, offset, length) != 0x0000)
    {
        //Debug message
        TRACE_WARNING("Wrong ICMP header checksum!\r\n");
        //Drop incoming message
        return;
    }

    //Check the type of ICMP message
    switch(header->type)
    {
    //Echo request?
    case ICMP_TYPE_ECHO_REQUEST:
        //Process Echo Request message
        icmpProcessEchoRequest(interface, srcIpAddr, buffer, offset);
        break;
    //Unknown type?
    default:
        //Debug message
        TRACE_WARNING("Unknown ICMP message type!\r\n");
        //Discard incoming ICMP message
        break;
    }
}
コード例 #13
0
ファイル: main.c プロジェクト: gstroe/Arm
/**
 * USART interrupt handler
 */
void USART2_Handler(void)
{
	Usart *pUs = BASE_USART;
	uint32_t status;
	uint16_t serialState;
	uint32_t count;

	status  = USART_GetStatus(pUs);
	status &= USART_GetItMask(pUs);

	/* If USB device is not configured, do nothing */
	if (!isCdcSerialON) {
		USART_DisableIt(pUs, 0xFFFFFFFF);
		return;
	}

	if (status & US_CSR_TIMEOUT) {
		/*Clear TIMEOUT Flag and Start Time-out After Next Character Received*/
		USART_AcknowledgeRxTimeOut(BASE_USART, 0);
		/* Flush the DMA FIFO */
		XDMAC_SoftwareFlushReq(dmad.pXdmacs, usartDmaRxChannel);
		/* Transfer the last pack through USB */
		count = dmad.pXdmacs->XDMAC_CHID[usartDmaRxChannel].XDMAC_CUBC;
		SCB_InvalidateDCache_by_Addr((uint32_t *)usartBuffers, DATAPACKETSIZE - count);

		while (CDCDSerialDriver_Write(usartBuffers, DATAPACKETSIZE - count, 0, 0)
			   != USBD_STATUS_SUCCESS);

		/*Reset DMA transfer*/
		XDMAD_StopTransfer(&dmad, usartDmaRxChannel);
		_UsartDmaRx();
	} else {
		/* Errors */
		serialState = CDCDSerialDriver_GetSerialState();

		/* Overrun */
		if ((status & US_CSR_OVRE) != 0) {
			TRACE_WARNING("USART_IrqHandler: Overrun\n\r");
			serialState |= CDCSerialState_OVERRUN;
		}

		/* Framing error */
		if ((status & US_CSR_FRAME) != 0) {
			TRACE_WARNING("USART_IrqHandler: Framing error\n\r");
			serialState |= CDCSerialState_FRAMING;
		}

		CDCDSerialDriver_SetSerialState(serialState);
	}
}
コード例 #14
0
ファイル: MSDLun.c プロジェクト: YTakami/makecontroller
//------------------------------------------------------------------------------
//! \brief  Reads data from a LUN, starting at the specified block address.
//! \param  pLUN          Pointer to a MSDLun instance
//! \param  blockAddress First block address to read
//! \param  data         Pointer to a data buffer in which to store the data
//! \param  length       Number of blocks to read
//! \param  callback     Optional callback to invoke when the read finishes
//! \return Operation result code
//------------------------------------------------------------------------------
unsigned char LUN_Read(MSDLun        *lun,
                       unsigned int blockAddress,
                       void         *data,
                       unsigned int length,
                       TransferCallback   callback,
                       void         *argument)
{
    unsigned int address;
    unsigned char status;

    // Check that the data is not too big
    if ((length * lun->blockSize)
        > (lun->size - lun->blockSize * blockAddress)) {

        TRACE_WARNING("LUN_Read: Data too big\n\r");
        status = USBD_STATUS_ABORTED;
    }
    else {

        TRACE_INFO_WP("LUNRead(%u) ", blockAddress);

        // Compute read start address
        address = lun->media->baseAddress
                   + lun->baseAddress
                   + blockAddress * lun->blockSize;

        // Start write operation
        status = MED_Read(lun->media,
                          address,
                          data,
                          length * lun->blockSize,
                          (MediaCallback) callback,
                          argument);

        // Check result code
        if (status == MED_STATUS_SUCCESS) {

            status = USBD_STATUS_SUCCESS;
        }
        else {

            TRACE_WARNING("LUN_Read: Cannot read media\n\r");
            status = USBD_STATUS_ABORTED;
        }
    }

    return status;
}
コード例 #15
0
const char *TScriptCall::GetFile(const char *pzFile)
{
	int nRetryCount = 0;
RESEND:
	try
	{
		m_strResults = m_DataSource->send(	"TScript",
										pzFile,
										(int)strlen(pzFile),/* -1 = Don't send the Null terminator */
										0,
										&m_pUserData,"TScriptFile=");

		if (XMLProcedureCall::m_lpfnRecv)
			XMLProcedureCall::m_lpfnRecv(m_strResults);

	}
	catch(GException &e)
	{
		// "General error parsing XML stream" means the data was corrupted in transit.
		if (e.GetError() == 7)
		{
			// Resend the request.
			if (nRetryCount++ < 3)
			{
				TRACE_WARNING("Attempting resend" );
				goto RESEND;
			}
		}
		
		// "the handle is invalid".  We need to 'reboot' the datasource. (WININET)
		if ((e.GetError()  == 6) && 
			(e.GetSystem() == 0)) 
		{
			// Resend the request.
			if (nRetryCount++ < 3)
			{
				TRACE_WARNING("Attempting resend" );
				m_DataSource->IPAddressChange();
				goto RESEND;
			}
		}

		// This helps distinguish Client errors from Server errors
		// unless the error was a client side connect error.
		throw GException("XMLProcedureCall", 4, m_DataSource->GetServerAddress(), e.GetDescription());
	}
	return m_strResults;
}
コード例 #16
0
//	Called by receiveIntoObject() after an "AttributeStartTag" has been found
//	this will get the next and only possible token (the value of the attribute)
//	and set it to the current member or object through the CMemberMappingEntry
void XMLObjectFactory::SetRootObjectAttributeValue(xml::token **attNameTok,
												   MemberDescriptor *pMap,
													  XMLObject *pObjCurrent,
													unsigned int nObjBehaviorFlags)
{
	__int64 nLen = (*attNameTok)->length();
	
	// strAttributeName will be [nLen] bytes long, we can use less memory by getting the exact amount from the heap
	// or take GStrings 256 byte stack default and briefly use a little more memory much faster than the heap allocation
	GString strAttributeName((*attNameTok)->get(), nLen);

	if (m_tokenLookAhead.m_type != xml::_unknown)
	{
		// attNameTok was a pointer to m_tokenLookAhead, so we 
		// are freeing it here before we ask for the next token.
		m_pLex->releaseLastToken(&m_tokenLookAhead);
		*attNameTok = &m_token;
	}
	m_pLex->nextToken(&m_token);


	if (m_token.m_type == xml::_pcdata)
	{
		// add attributes to this member if it is mapped to the object
		int nMapped = 0;
		if (pMap)
		{
			// Loads the MemberDescriptors for the object if this is the first attribute
			// then copies the token value into mapped member variable in the Object.
			nMapped = pObjCurrent->SetMappedAttribute(strAttributeName, m_token.get(), m_token.length() );
		}
		if ( !nMapped )
		{
			if ( nObjBehaviorFlags & PREVENT_ATTRIB_AUTOMAP )
			{
				// log the fact that data in the XML was lost because it was not mapped
				char szTemp[128];
				sprintf(szTemp, "*** Attribute Tag <%s> does not map to Object <%s> *************",
					strAttributeName.Buf(), pObjCurrent->GetObjectType());
				TRACE_WARNING(szTemp);

				// allow for custom override
				pObjCurrent->ObjectMessage(MSG_UNMAPPED_ATTRIBUTE, strAttributeName, m_token.get(), m_token.length(), 0);
			}
			else
			{
				pObjCurrent->AddAttribute(strAttributeName, m_token.get());
			}
		}
	}
	else
	{
		// debug tracing:
		// expected token (eType,strXml) following attributeStartTag (strAttTagName)
		GString strErr;
		strErr.Format("Unexpected XML <%s> following Token <%s> in object <%s>", m_token.get(), strAttributeName.Buf(), pObjCurrent->GetObjectType());
		TRACE_ERROR((const char *)strErr)
		throw;
	}
}
コード例 #17
0
ファイル: WriteFile.cpp プロジェクト: LightBitsLabs/osmosis
void WriteFile::write( size_t offset, const void * data, const unsigned length )
{
	ASSERT( data != nullptr );
	if ( length == 0 )
		return;
	if ( offset != _offset )
		seek( offset );

	auto nrBytesLeftToWrite = length;
	unsigned char *datap = (unsigned char *) data;
	while ( nrBytesLeftToWrite > 0 ) {
		ssize_t written = ::write( _descriptor.fd(), datap, nrBytesLeftToWrite );
		if ( written <= 0 )
			THROW_BOOST_ERRNO_EXCEPTION( errno, "Unable to write to '" << _filename <<
				"' at offset " << _offset );
		if ( written != nrBytesLeftToWrite )
			TRACE_WARNING("While writing to file '" << _filename << "': linux 'write' system call return "
				"value indicates that partial data was written: " <<
				"expected: " << nrBytesLeftToWrite << " but only " << written << " was written. " <<
				nrBytesLeftToWrite << "bytes left to write." );
		_offset += written;
		nrBytesLeftToWrite -= written;
		datap += written;
	}
}
コード例 #18
0
ファイル: h264_macroblock.c プロジェクト: misterk72/MiniVideo
/*!
 * \param slice_type The slice type.
 * \param sub_mb_type docme.
 *
 * Table 7-17: Sub-macroblock types in P macroblocks.
 * Table 7-18: Sub-macroblock types in B macroblocks.
 */
static int SubMbPartHeight(const unsigned int slice_type, const unsigned int sub_mb_type)
{
    TRACE_INFO(MB, "  > " BLD_GREEN "SubMbPartHeight()\n" CLR_RESET);
    int retcode = 0;

    if (slice_type == 0 || slice_type == 5) // P slice
    {
        TRACE_WARNING(MB, ">>> UNIMPLEMENTED SubMbPartHeight(P slice)\n");
    }
    else if (slice_type == 1 || slice_type == 6) // B slice
    {
        TRACE_WARNING(MB, ">>> UNIMPLEMENTED SubMbPartHeight(B slice)\n");
    }

    return retcode;
}
コード例 #19
0
ファイル: HookSys.c プロジェクト: brock7/winpooch
NTSTATUS DDKAPI Hook_PspTerminateProcess (IN PEPROCESS	Eprocess, 
					  IN NTSTATUS	ExitStatus) 
{
  PROC		pfnStub = Hooks_GetStubAddress (HOOKS_PSPTERMINATEPROCESS) ;
  NTSTATUS	nStatus ;

  TRACE_ALWAYS (TEXT("Eprocess = 0x%08X\n"), Eprocess) ;

  nStatus = (NTSTATUS) pfnStub (Eprocess, ExitStatus) ;

  if( SUCCEEDED(nStatus) )
    {
      PROCSTRUCT *pProc ;

      if( nStatus!=STATUS_SUCCESS )
	TRACE_WARNING(TEXT("PspTerminateProcess returned 0x%08X\n"), nStatus) ;

      nStatus = ProcList_Lock () ;
      if( nStatus != STATUS_SUCCESS ) return nStatus ;

      pProc = ProcList_Remove ((PROCADDR)Eprocess) ;	
      ProcList_Unlock () ;
      
      if( pProc==NULL || (pProc->nFlags&PROCESS_NO_NOTIFICATION)==0 )
	HookCommon_SendProcessTerminatedNotification ((PROCADDR)Eprocess) ;     	

      ProcList_Delete (pProc) ;
    }  
 
  return nStatus ;  
}
コード例 #20
0
ファイル: SpyServer.c プロジェクト: 340211173/hf-2011
BOOL SpySrv_SetScannerExePath (LPCWSTR szScannerExe) 
{
  BOOL		bSuccess ;
  DWORD		nWaitResult ;
  OVERLAPPED	ov ;
  UINT		nSize ;

  ov.hEvent = CreateEvent (NULL, TRUE, FALSE, NULL) ;

  nSize = szScannerExe!=NULL ? (_tcslen(szScannerExe)+1)*sizeof(TCHAR) : 0 ;

  bSuccess = DeviceIoControl (g_hDriver, 
			      IOCTL_SET_SCANNER_PATH, 
			      (VOID*)szScannerExe, nSize,
			      NULL, 0, NULL, &ov) ;

  if( !bSuccess && GetLastError()==ERROR_IO_PENDING )
    {
      TRACE_WARNING (TEXT("IOCTL_SET_SCANNER_PATH is running asynchronously\n")) ;

      nWaitResult = WaitForSingleObject (ov.hEvent, 10*1000) ;

      bSuccess = nWaitResult==WAIT_OBJECT_0 ;
    }

  CloseHandle (ov.hEvent) ;
  
  if( ! bSuccess )
    TRACE_ERROR (TEXT("Failed to send scanner path to driver\n")) ;
  
  return bSuccess ;
}
コード例 #21
0
/**
 * Handles audio-specific USB requests sent by the host, and forwards
 * standard ones to the USB device driver.
 * \param request Pointer to a USBGenericRequest instance.
 */
void AUDDSpeakerDriver_RequestHandler(const USBGenericRequest *request)
{
    AUDDSpeakerDriver *pAudd = &auddSpeakerDriver;
    AUDDSpeakerPhone *pAudf  = &pAudd->fun;
    USBDDriver *pUsbd = pAudf->pUsbd;

    TRACE_INFO_WP("NewReq ");

    /* Handle Audio Class requests */
    if (AUDDSpeakerPhone_RequestHandler(pAudf, request) == USBRC_SUCCESS) {
        return;
    }

    /* Handle STD requests */
    if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) {

        USBDDriver_RequestHandler(pUsbd, request);
    }
    /* Unsupported request */
    else {

        TRACE_WARNING(
            "AUDDSpeakerDriver_RequestHandler: Unsupported request (%d,%x)\n\r",
            USBGenericRequest_GetType(request),
            USBGenericRequest_GetRequest(request));
        USBD_Stall(0);
    }
}
コード例 #22
0
ファイル: network_client.c プロジェクト: waycom/h6
static __inline__ int32_t
init_this(network_client *nc, uint32_t factory, void *io)
{
	int32_t fd = (int32_t)io;

	nc->ip[0] = '\0';
	unix_sock_get_peer(fd, nc->ip, MAX_IP4_LEN);

	nc->factory = factory;
	nc->proto_watch = proto_watch_new(io, DEFAULT_TIMEOUT_SEC * DEFAULT_CHECK_TIMES * 1000, 
		&network_client_watch_impl, nc, proto_watch_on_finalize);
	if (!nc->proto_watch)
	{
		TRACE_WARNING("network_client()->proto_watch_new() failed.");
		unix_sock_close((int32_t)io);
		return -EINVAL;
	}

	proto_watch_set_window(nc->proto_watch, DEFAULT_PW_WINSIZE);

    obj_ref(nc); // *****
    
	nc->state = 0;
    
	nc->lock = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
    pthread_mutex_init(nc->lock, NULL);

	return 0;
}
コード例 #23
0
/**
 * Handles composite-specific USB requests sent by the host, and forwards
 * standard ones to the USB device driver.
 * \param request Pointer to a USBGenericRequest instance.
 */
void DUALCDCDDriver_RequestHandler(const USBGenericRequest *request)
{
    CDCDSerialPort *pCdcd = 0;
    USBDDriver *pUsbd = 0;
    uint32_t rc, i;

    TRACE_INFO_WP("NewReq ");

    for (i = 0; i < NUM_PORTS; i ++) {
        pCdcd = &dualcdcdDriver.cdcdSerialPort[i];
        rc = CDCDSerialPort_RequestHandler(pCdcd, request);
        if (rc == USBRC_SUCCESS)
            break;
    }

    /* Not handled by CDC Serial */
    if (rc != USBRC_SUCCESS) {
        if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) {
            pUsbd = pCdcd->pUsbd;
            USBDDriver_RequestHandler(pUsbd, request);
        }
        else {
            TRACE_WARNING(
              "DUALCDCDDriver_RequestHandler: Unsupported request (%d,%d)\n\r",
              USBGenericRequest_GetType(request),
              USBGenericRequest_GetRequest(request));
            USBD_Stall(0);
        }
    }

}
コード例 #24
0
void reconstruct_reverse_track() {
	if (get_step_count() > 0) {
		TRACE_DEBUG("-- reconstruct_reverse_track -- \r\n");
		char txt_buff[16];
		sprintf(txt_buff, "Total steps: %2d", get_step_count());
		HY1602F6_Log("Reversing track", txt_buff);

		init_oa_configuration();
		CD4053_EnableIRSensors();
		waitms(1000);

		int step_count = get_step_count() - 1;
		for (; step_count >= 0; step_count--) {
			char lcd_buff1[16];
			sprintf(lcd_buff1, "angle: %3d", (int) steps_data[step_count]);
			char lcd_buff2[16];
			sprintf(lcd_buff2, "step: %3d", step_count);
			HY1602F6_Log(lcd_buff1, lcd_buff2);

			turn_of_angle(steps_data[step_count]);

			go_prosto();
		}

		Kierunek(RIGHT_ENGINES, STOP_GEAR);
		Kierunek(LEFT_ENGINES, STOP_GEAR);
	} else {
		TRACE_WARNING("-- No steps recorded. --\r\n");
		HY1602F6_Log("Invalid track", "No data found");
	}
}
コード例 #25
0
ファイル: wrap-theora.c プロジェクト: beller0ph0nt/utility
int
w_theora_decode_header(theora_info* ci, theora_comment* cc, ogg_packet* op)
{
    int ret = theora_decode_header(ci, cc, op);
    if (ret == OC_BADHEADER)
    {
        TRACE_ERROR("theora_decode_header failure (OC_BADHEADER:%d)", ret);
        exit(EXIT_FAILURE);
    }
    else if (ret == OC_VERSION)
    {
        TRACE_ERROR("theora_decode_header failure (OC_VERSION:%d)", ret);
        exit(EXIT_FAILURE);
    }
    else if (ret == OC_NEWPACKET)
    {
        TRACE_ERROR("theora_decode_header failure (OC_NEWPACKET:%d)", ret);
        exit(EXIT_FAILURE);
    }
    else if (ret == OC_NOTFORMAT)
    {
        TRACE_WARNING("theora_decode_header (OC_NOTFORMAT:%d)", ret);
    }

    return ret;
}
コード例 #26
0
ファイル: sockets.c プロジェクト: escoand/socksswitch
/* wrapper for socket accpeting */
int socksswitch_accept(const int sock) {
    SOCKET_ADDR_LEN addrlen = sizeof(struct sockaddr_in);
    struct sockaddr_in addr;
    int rc;

    DEBUG_ENTER;

    rc = accept(sock, (struct sockaddr *) &addr, &addrlen);

    /* socket connected */
    if (rc > 0) {
	TRACE_INFO("connect from %s:%i (socket:%i)\n",
		   inet_ntoa(addr.sin_addr), ntohs(addr.sin_port), rc);
    }

    /* error */
    else {
	TRACE_WARNING("failure on connecting (socket:%i err:%i): %s\n",
		      sock, SOCKET_ERROR_CODE, socketError());
	socketError();
    }

    DEBUG_LEAVE;
    return rc;
}
コード例 #27
0
ファイル: WatchedObjects.c プロジェクト: 340211173/hf-2011
NTSTATUS WatchObjs_Uninit () 
{
  NODE	*pNode, *pNext ;
  ULONG	nNodeCount = 0 ;

  TRACE ;

  WatchObjs_Lock () ;

  if( g_data.pFirst ) ASSERT (g_data.pFirst->pPrev==NULL) ;
  if( g_data.pLast ) ASSERT (g_data.pLast->pNext==NULL) ;
  
  for( pNode=g_data.pFirst ; pNode ; pNode=pNext )
    {
      pNext = pNode->pNext ;

      if( pNext ) ASSERT(pNext->pPrev==pNode) ;

      FREE (pNode->pUserData) ;
      FREE (pNode) ;

      nNodeCount++ ;
    }

  WatchObjs_Unlock () ;

  if( nNodeCount!=g_data.nNodeCount )
    TRACE_WARNING (TEXT("Freed %u nodes, whereas node count was %u\n"), 
		   nNodeCount, g_data.nNodeCount) ;

  g_data.bInitialized = FALSE ;

  return STATUS_SUCCESS ;
}
コード例 #28
0
ファイル: sockets.c プロジェクト: escoand/socksswitch
/* wrapper for socket closing */
int socksswitch_close(const int sock) {
    char addrstr[256];

    DEBUG_ENTER;

    if (sock <= 0) {
	DEBUG_LEAVE;
	return 0;
    }

    strcpy(addrstr, socksswitch_addr(sock));

    /* disconnect */
    if (shutdown(sock, SD_BOTH) == 0 && SOCKET_CLOSE(sock) == 0)
	TRACE_INFO("disconnected from %s (socket:%i)\n", addrstr, sock);

    /* error */
    else {
	TRACE_WARNING
	    ("failure on closing from %s (socket:%i err:%i): %s\n",
	     addrstr, sock, SOCKET_ERROR_CODE, socketError());
	DEBUG_LEAVE;
	return SOCKET_ERROR;
    }

    DEBUG_LEAVE;
    return 1;
}
コード例 #29
0
ファイル: tcp_ip_stack_mem.c プロジェクト: rpc-fw/analyzer
void *memPoolAlloc(size_t size)
{
#if (MEM_POOL_SUPPORT == ENABLED)
   uint_t i;
#endif

   //Pointer to the allocated memory block
   void *p = NULL;

   //Debug message
   TRACE_DEBUG("Allocating %" PRIuSIZE " bytes...\r\n", size);

//Use fixed-size blocks allocation?
#if (MEM_POOL_SUPPORT == ENABLED)
   //Acquire exclusive access to the memory pool
   osMutexAcquire(memPoolMutex);

   //Enforce block size
   if(size <= MEM_POOL_BUFFER_SIZE)
   {
      //Loop through allocation table
      for(i = 0; i < MEM_POOL_BUFFER_COUNT; i++)
      {
         //Check whether the current block is free
         if(!memPoolAllocTable[i])
         {
            //Mark the current entry as used
            memPoolAllocTable[i] = TRUE;
            //Point to the corresponding memory block
            p = memPool[i];

            //Update statistics
            memPoolCurrentUsage++;
            //Maximum number of buffers that have been allocated so far
            memPoolMaxUsage = max(memPoolCurrentUsage, memPoolMaxUsage);

            //Exit immediately
            break;
         }
      }
   }

   //Release exclusive access to the memory pool
   osMutexRelease(memPoolMutex);
#else
   //Allocate a memory block
   p = osMemAlloc(size);
#endif

   //Failed to allocate memory?
   if(!p)
   {
      //Debug message
      TRACE_WARNING("Memory allocation failed!\r\n");
   }

   //Return a pointer to the allocated memory block
   return p;
}
コード例 #30
0
ファイル: Disasm.c プロジェクト: brock7/winpooch
int _Dasm_ReadModRmAndSid (int nCur, BYTE * pInst)
{
  int nSize = 0 ;

  TRACE_INFO (TEXT("inst=0x%02X, mod=%d, opcode=%d, rm=%d\n"), 
	      pInst[0], OPCODE(pInst[nCur]), MOD(pInst[nCur]), RM(pInst[nCur])) ;
  
  switch( MOD(pInst[nCur]) )
    {
    case 0: // Mod==00 => No disp

      // /!\ not valid if R/M is 4
      switch( RM(pInst[nCur]) )
	{   
	case 4: // an SIB follows
	  nSize = nCur + 2 ;
	  break ;   
	case 5:  // has disp32
	  nSize = nCur + 5 ;
	  break ;
	default:
	  nSize = nCur + 1 ;
	}

      break ; 
      
    case 1: // Mod==01 => 8 bits disp

      switch( RM(pInst[nCur]) )
	{ 
	case 4: // an SIB follows
	  nSize = nCur + 3 ;
	  break ;

	default:
	  nSize = nCur + 2 ;
	}

      break ;
      
    case 2: // Mod==10 => 32 bits disp

      // /!\ not valid if R/M is 4
      nSize = nCur + 5 ;

      if( RM(pInst[nCur])==4 )
	TRACE_WARNING (TEXT("Not tested instruction decoding\n")) ;
      
      break ;
      
    case 3:

      nSize = nCur + 1 ;

      break ; 
    }

  return nSize ;
}