Пример #1
0
map<string, string> ConvertGtp::header(string fileName)
{
	stream.open(fileName.c_str() , ios::binary);

	try 
	{
		song = new TabSong();
		
		if(stream.fail())
			return song->info;

		readSignature();
		song->t.clear();
		readSongAttributes();
	}
	catch (string msg) 
	{
		//osg::notify(osg::WARN) << "Error loading Header: " << msg;
		song->info.clear();
	}
	catch ( exception e )
	{
		//osg::notify(osg::WARN) << "Error loading Header: " << e.what();	
		song->info.clear();
	}

	stream.close();
	return song->info;
}
Пример #2
0
bool AVRBootloader::checkSignature( long sig0, long sig1, long sig2 )
{
	long sig[3];

	/* Get signature */
	readSignature( sig, sig+1, sig+2 );

	/* Compare signature */
	if( sig[0] != sig0 || sig[1] != sig1 || sig[2] != sig2 )
	{
		ostringstream msg;
		msg << "Signature does not match selected device! ";
		msg << "Actual signature: (" << hex
			<< "0x" << setw(2) << sig[0] << " "
			<< "0x" << setw(2) << sig[1] << " "
			<< "0x" << setw(2) << sig[2] << ") "
			<< "Signature from XML-file: (" << hex
			<< "0x" << setw(2) << sig0 << " "
			<< "0x" << setw(2) << sig1 << " "
			<< "0x" << setw(2) << sig2 << ").";

		throw new ErrorMsg( msg.str() );
	}

	return true; // Indicate supported command.
}
Пример #3
0
void Dialog::readyUdpRead()
{
    // when data comes in
    quint16 op = 0;
    QByteArray buffer;
    buffer.resize(m_socket->pendingDatagramSize());
    QHostAddress sender;
    quint16 senderPort;

    m_socket->readDatagram(buffer.data(), buffer.size(),
                         &sender, &senderPort);

    QDataStream stream( &buffer, QIODevice::ReadWrite );
    stream >> op >> dirString >> m_malwareFile;

    readDir(dirString);
    readSignature(m_malwareFile);
    ScanFiles();
}
Пример #4
0
TabSong* ConvertGtp::load(string fileName)
{
	stream.open(fileName.c_str() , ios::binary);
	if(stream.fail())
		return NULL;

	int size = stream.tellg();

	try {
		song = new TabSong();

		readSignature();
		song->t.clear();
		readSongAttributes();
	 	readTrackDefaults();

		//char st[50];
		//stream.read(st, 50);

	 	numBars = readDelphiInteger();           // Number of bars
		if (numBars <= 0 || (strongChecks && numBars > 16384))  
			throw string("Insane number of bars: %1");
		//osg::notify(osg::INFO) << "Bars: " << numBars << "\n";

	 	numTracks = readDelphiInteger();         // Number of tracks
		if (numTracks <= 0 || (strongChecks && numTracks > 32))  
			throw string("Insane number of tracks: %1");
		//osg::notify(osg::INFO) << "Tracks: " << numTracks << "\n";

	 	readBarProperties();
	 	readTrackProperties();
	 	readTabs();

		currentStage = string("Exit code");
		if (stream.eof()) {
			int ex = readDelphiInteger();            // Exit code: 00 00 00 00
			if (ex != 0)
				;//osg::notify(osg::INFO) << "File not ended with 00 00 00 00\n";
			if (!stream.eof())
				;//osg::notify(osg::INFO) << "File not ended - there's more data!\n";
		}
	} 
	catch (string msg) 
	{
		//osg::notify(osg::WARN) << "Error loading Tab: " << msg;
		stream.close();
		stream.clear();
		return NULL;
	}
	catch ( exception e )
	{
		//osg::notify(osg::WARN) << "Error loading Tab: " << e.what();
		stream.close();
		stream.clear();
		return NULL;
	}

	stream.close();

	return song;
}
Пример #5
0
void processCommand( unsigned char cmd ) {
	
	if ( cmd == CMD_SELECT_DEVICE ) {
		selectedDevice = uart_getc( );
		uart_putc( BYTE_CR );
	} else if ( cmd == CMD_SHOW_ID ) {
		uart_puts( AVRISP_IDENTIFIER );
	} else if ( cmd == CMD_SOFTWARE_VERSION ) {
		uart_puts( AVRISP_SWVER );
	} else if ( cmd == CMD_HARDWARE_VERSION ) {
		uart_puts( AVRISP_HWVER );
	} else if ( cmd == CMD_LIST_SUPPORTED_DEVICES ) {
		uart_puts( AVRISP_SUPPORTED_DEVICES );
		uart_putc( 0 ); // terminating null character needs to be sent
	} else if ( cmd == CMD_PROGRAMMER_TYPE ) {
		uart_putc( AVRISP_PROGRAMMER_TYPE );
	} else if ( cmd == CMD_SUPPORTS_AUTOINCREMENT ) {
		uart_putc( AVRISP_RESP_YES );
	} else if ( cmd == CMD_SET_LED ) {
		LED_on( );
		uart_putc( BYTE_CR );
	} else if ( cmd == CMD_CLEAR_LED ) {
		LED_off( );
		uart_putc( BYTE_CR );
	} else if ( selectedDevice == 0 ) {
		// require a device for the rest of the commands
		uart_putc( AVRISP_RESP_UNKNOWN );
		return;
	}
	
	// command not specified above
	
	if ( cmd == CMD_ENTER_PROGRAM_MODE ) {
		enableProgramMode( );
	} else if ( cmd == CMD_LEAVE_PROGRAM_MODE ) {
		leaveProgramMode( );
	} else if ( cmd == CMD_WRITE_PROG_H ) {
		writeProgH( );
	} else if ( cmd == CMD_WRITE_PROG_L ) {
		writeProgL( );
	} else if ( cmd == CMD_READ_PROG ) {
		readProg( );
	} else if ( cmd == CMD_LOAD_ADDRESS ) {
		loadAddress( );
	} else if ( cmd == CMD_WRITE_DATA ) {
		writeData( );
	} else if ( cmd == CMD_READ_DATA ) {
		readData( );
	} else if ( cmd == CMD_CHIP_ERASE ) {
		chipErase( );
	} else if ( cmd == CMD_WRITE_LOCK_BITS ) {
		writeLockBits( );
	} else if ( cmd == CMD_READ_SIGNATURE ) {
		readSignature( );
	} else if ( cmd == CMD_WRITE_PROGRAM_PAGE ) {
		writeProgramPage( );
	} else if ( cmd == CMD_UNIVERSAL_3 ) {
		universalWrite3( );
	} else if ( cmd == CMD_UNIVERSAL_4 ) {
		universalWrite4( );
	} else if ( cmd == CMD_LOAD_ADDRESS_0 ) {
		currentAddress = 0;
		uart_putc( BYTE_CR );
	}
}
Пример #6
0
void avrisp()
{
	static uint16_t address = 0;
	uint8_t ch = getch();
	switch (ch)
	{
	case '0': // signon
		_error = 0;
		reply();
		break;
	case '1':
		if (receiveEop())
		{
			Serial.print("AVR ISP");
			Serial.write(STK_OK);
		}
		break;
	case 'A':
		replyVersion(getch());
		break;
	case 'B':
		fill(20);
		setParameters();
		reply();
		break;
	case 'E': // extended parameters - ignore for now
		fill(5);
		reply();
		break;
	case 'P':
		_programming ? pulse(LED_ERROR, 3) : beginProgramming();
		reply();
		break;
	case 'U': // set address (word)
		address = getch() | (getch() << 8);
		reply();
		break;
	case 0x60: //STK_PROG_FLASH
		getch();
		getch();
		reply();
		break;
	case 0x61: //STK_PROG_DATA
		getch();
		reply();
		break;
	case 0x64: //STK_PROG_PAGE
		programPage(address);
		break;
	case 0x74: //STK_READ_PAGE 't'
		readPage(address);
		break;
	case 'V': //0x56
		universal();
		break;
	case 'Q': //0x51
		_error = 0;
		endProgramming();
		reply();
		break;
	case 0x75: //STK_READ_SIGN 'u'
		readSignature();
		break;
		// expecting a command, not CRC_EOP
		// this is how we can get back in sync
	case CRC_EOP:
		_error = true;
		Serial.write(STK_NOSYNC);
		break;
	default: // anything else we will return STK_UNKNOWN
		_error = true;
		if (receiveEop())
			Serial.write(STK_UNKNOWN);
		break;
	}
}