Example #1
0
void MobileApp::updateDownloadableList()
{
    QList <QString> dl;
    groups.clear();

    ReadFileToList(SAVEDBOOKLIST, dl, "UTF-8");
    parseDLFile(dl);

    //show aprorpriate widgets
    ui->downloadSTKWidget->setCurrentIndex(1);


    //Clear the old list
    ui->downloadListWidget->clear();

    //Build the new list
    for (int i=0; i<groups.size(); i++)
    {
        if (groups[i].downloadState != 0)
        {
            QListWidgetItem *lwi;
            lwi= new QListWidgetItem(groups[i].name + " (" + QString::number(groups[i].downloadSize)
                                     + /* "/" + QString::number(groups[i].fullSize) + */ " MB)");
            if (autoInstallKukBooksFlag && groups[i].name.contains("הרחבה"))
                lwi->setCheckState(Qt::Checked);
            else
                lwi->setCheckState(Qt::Unchecked);
            lwi->setWhatsThis(stringify(i));
            lwi->setToolTip("False");
            if(groups[i].hidden)
                lwi->setTextColor(QColor("gray"));

            ui->downloadListWidget->addItem(lwi);
            ui->downloadListWidget->setEnabled(true);
        }
    }

    if(autoInstallKukBooksFlag)
        downloadStart();

}
Example #2
0
// start download of the selected books.
void MobileApp::on_downloadBTN_clicked()
{
    downloadStart();
}
bool parseInput(char instr[])
{
	LONG    lLastError = ERROR_SUCCESS;

	// Make instr lower.
	_strlwr_s(instr,INPUT_BUFFER_SIZE);

	if (strcmp(instr,"exit")==0) return false; // If exit, exit.
	else if (strcmp(instr,"go")==0)
	{
		// Download program.
		if (hf.isValid())
			printf("GO!\n");
		else 
			printf("Un-GO!\n");

		// First connect
		scp.open();
		//serialSetConnected(true);
		// download program
		downloadStart(&scp,&hf);

	}
	else if (strcmp(instr,"load debug")==0)
	{
		// Load debug app.
	}
	else if (strcmp(instr,"load")==0)
	{
		// load regular app.
		if (hf.loadHex(FILEPATH1,true)) { printf("File %s loaded sucessfully!\n",hf.filepath); printf("File size: %lu, upper addr: %lu, lower addr: %lu\n",hf.getLength(),hf.getAddrUpper(),hf.getAddrLower()); }
		else { printf(hf.lastError); }

	}
	/*
	else if (strcmp(instr,"put")==0)
	{
		// Put dummy packet

		unsigned char canmsg[17];
		canmsg[0]=253;
		canmsg[16]=250;
		if (isConnected())
			{
			lLastError = serial.Write(canmsg,17);
			if (lLastError != ERROR_SUCCESS)
			{
				printf("Unable to send data\n");
			}
		} else { printf("Err! No connected to serial port.\n"); }
	}
*/

	else if (strcmp(instr,"conn")==0)
	{
		// Connect to serial port.

		if (isConnected()) { printf("Err! Alredy connected to serial port.\n"); }
		else { serialSetConnected(true); }
	}
	else if (strcmp(instr,"diss")==0)
	{		
		// Dissconnect from serial port.

		if (!isConnected()) { printf("Err! Not connected to serial port.\n"); }
		else { serialSetConnected(false); }
	}
	else if (strcmp(instr,"test2")==0)
	{
		//serialReaderStart(&serial);
	}
	else if (strcmp(instr,"test2 stop")==0)
	{
		//serialReaderStop();
	}
	else if (strcmp(instr,"test3")==0)
	{
		DCB dcb;
		HANDLE hCom;
		bool fSuccess;


	   hCom = ::CreateFile(_T("COM2"),
						GENERIC_READ | GENERIC_WRITE,
						0,    // must be opened with exclusive-access
						0, // no security attributes
						OPEN_EXISTING, // must use OPEN_EXISTING
						FILE_FLAG_OVERLAPPED,    // not overlapped I/O
						0  // hTemplate must be NULL for comm devices
						);

	   if (hCom == INVALID_HANDLE_VALUE) 
	   {
		   // Handle the error.
		   printf ("Err: %d.\n",GetLastError());
	   }


		// Build on the current configuration, and skip setting the size
	   // of the input and output buffers with SetupComm.

	   fSuccess = GetCommState(hCom, &dcb);

	   if (!fSuccess) 
	   {
		  // Handle the error.
		  printf ("GetCommState failed with error %d.\n", GetLastError());
	   }

		// Fill in DCB: 57,600 bps, 8 data bits, no parity, and 1 stop bit.

	   dcb.BaudRate = CBR_57600;     // set the baud rate
	   dcb.ByteSize = 8;             // data size, xmit, and rcv
	   dcb.Parity = NOPARITY;        // no parity bit
	   dcb.StopBits = ONESTOPBIT;    // one stop bit

	   fSuccess = SetCommState(hCom, &dcb);

	   if (!fSuccess) 
	   {
		  // Handle the error.
		  printf ("SetCommState failed with error %d.\n", GetLastError());
	   }

	   printf ("Serial port successfully reconfigured.\n");
		


	}
	else if (strcmp(instr,"test4")==0)
	{

		scp.open();
	
		char data[] = "hej";
		unsigned char data2[17];

		CanProtoMessage cpm(0x01,0x01,0x01,0x01,1,(unsigned char *)data);
		
		cpm.getBytes(data2);

		scp.write(data2,17);

		//serialReaderStartSerCon(&scp);

		//scp.close();
	}
	else if(strcmp(instr,"tick")==0)
	{ 
      printf ("actual:%ld\n", GetTickCount());

	}
	else if (strcmp(instr,"test")==0)
	{
		// Debug for testing canProtoMessage

		unsigned char dat[8];
		
		for (int i=0;i<8;i++) dat[i]=0x10+i*2;
		
		unsigned char dat2[17];

		CanProtoMessage cpm1(0x07,0x91,0x10,0x87,8,&dat[0]);
		
		cpm1.getBytes(&dat2[0]);
	

		CanProtoMessage cpm2(&dat2[0],1);
	
		if (cpm1.equals(&cpm2)) printf("OK!\n"); else printf("Not OK!\n");

	}
	else
	{
		printf("Command not found.\n");
	}

	printf("Main: ");

	return true;
}