Exemplo n.º 1
0
StatePtrProxy StateAVReflashAckNack( char ch )
{
    switch ( ch )
    {
        case '!':
        {
            Log( "ok\n" );

            gDownloadOffset += gDeviceInfo.pageSize;
            if ( gDownloadOffset >= gDownloadSegment->lenThisSegment )
            {
                gDownloadSegment = gDownloadSegment->next;
                gDownloadOffset = 0;
            }

            if ( gDownloadSegment == NULL )
            {
                // We're done.

                SendExecCode();

                return NULL;
            }
            break;
        }

        case '$':
        {
            LogError( "*** Error *** Verify failed - Retrying\n" );
            gRetryCount++;
            break;
        }

        case '@':
        {
            LogError( "*** Error *** CheckSum failed - Retrying\n" );
            gRetryCount++;
            break;
        }

        default:
        {
            LogError( "Unexpected character received: 0x%02x while waiting for Ack/Nak\n", (unsigned)ch );
            return NULL;
        }
    }

    if ( gRetryCount > 3 )
    {
        return NULL;
    }

    SendPage( gDownloadSegment->address + gDownloadOffset, 
              &gDownloadSegment->data[ gDownloadOffset ], 
              gDeviceInfo.pageSize );

    return StateAVReflashAckNack;

} // StateAVReflashAckNack
Exemplo n.º 2
0
StatePtrProxy StateAVReflashPageSize( char ch )
{
    if (( ch >= '0' ) && ( ch <= '9' ))
    {
        gDeviceInfo.pageSize *= 10;
        gDeviceInfo.pageSize += ( ch - '0' );

        if ( gDeviceInfo.pageSize > MAX_PAGE_SIZE )
        {
            LogError( "Invalid Page Size: %d\n", gDeviceInfo.pageSize );
            return NULL;
        }

        return StateAVReflashPageSize;
    }

    if ( ch == '!' )
    {
        Log( "Page Size:  %3d\n", gDeviceInfo.pageSize );

        // Currently, we don't know the device size or the bootloader size
        // so we can't call CheckFile.

        if (( gDownloadFileName == NULL ) 
//        ||  !CheckFile( gDownloadInfo, &gDeviceInfo )
        ||  gDownloadInfo->head == NULL )
        {
            // No download - just send the ExecCode

            SendExecCode();

            return NULL;
        }

        gDownloadSegment = gDownloadInfo->head;
        gDownloadOffset = 0;
        gRetryCount = 0;

        SendPage( gDownloadSegment->address + gDownloadOffset, 
                  &gDownloadSegment->data[ gDownloadOffset ], 
                  gDeviceInfo.pageSize );

        return StateAVReflashAckNack;
    }

    LogError( "Unexpected character received: 0x%02x while waiting for Ack/Nak\n", (unsigned)ch );
    return NULL;

} // StateAVReflashPageSize
Exemplo n.º 3
0
void EQWHTTPHandler::Exec() {
	m_sentHeaders = false;
	m_responseCode = "200";
//	printf("Request: %s, %s, %s, %s.\n", GetMethod().c_str(), GetUrl().c_str(), GetUri().c_str(), GetQueryString().c_str());

	SetHttpVersion("HTTP/1.0");
	AddResponseHeader("Connection", "close");

	if(GetUri().find("..") != std::string::npos) {
		SendResponse("403", "Forbidden");
		printf("%s is forbidden.\n", GetUri().c_str());
		return;
	}

	if(!CheckAuth()) {
		AddResponseHeader("Content-type", "text/plain");
		AddResponseHeader("WWW-Authenticate", "Basic realm=\"EQEmulator\"");
		SendResponse("401", "Authorization Required");
		SendString("Gotta Authenticate.");
	} else {
		std::string::size_type start = GetUri().find_first_not_of('/');
		std::string page;
		if(start != std::string::npos)
			page = GetUri().substr(start);
		else
			page = "index.html";
		SendPage(page);
	}
/*	if (!Detach()) {
		printf("Unable to detach...\n");
	}
	if(GetOutputLength() > 0) {
		//we cannot close yet
		m_closeOnFinish = true;
	} else {
		Close();
	}*/
	Free();	//the "app" side (us) is done with this connection too...
	Disconnect();
}
Exemplo n.º 4
0
void LogDump(){
  uint32_u fullAddress;
  uint8_t  firstByte;
  uint8_t pageBuffer[256];
  uint32_t waitTimer;

  for(uint16_t i = 0; i <= 0x3FFF; i++){
    fullAddress.val = (uint32_t)i << 8;
    FlashSSLow();
    SPI.transfer(READ_ARRAY);
    SPI.transfer(fullAddress.buffer[2]);
    SPI.transfer(fullAddress.buffer[1]);
    SPI.transfer(fullAddress.buffer[0]);
    firstByte = SPI.transfer(0);
    FlashSSHigh();
    if (firstByte == WRITE_COMPLETE_REC_START || firstByte == WRITE_COMPLETE_REC_START_END || firstByte == WRITE_COMPLETE_REC_END || firstByte == WRITE_COMPLETE){
      FlashGetPage(i,pageBuffer);
      SendPage(pageBuffer);
      //delay(5);
    }
  }

}