Umwandlung von Delphi nach C++

Code:
#include "stdafx.h"
#include "time.h"
#include "iowkit.h"

// Write simple value
BOOLEAN WriteSimple(IOWKIT_HANDLE devHandle, DWORD value)
{
	IOWKIT_REPORT rep;
	//int portnr;
	//printf("value ist %d, port ist %d\n",value,portnr);

	// Init report
	rep.ReportID = 0;
	rep.Value = 0xFFFFFFFF; //00000000;
	switch (IowKitGetProductId(devHandle))
	{
	// Write simple value to IOW40
	case IOWKIT_PRODUCT_ID_IOW40:
		rep.Bytes[portnr] = (UCHAR) value;
		return IowKitWrite(devHandle, IOW_PIPE_IO_PINS,
			(PCHAR) &rep, IOWKIT40_IO_REPORT_SIZE) == IOWKIT40_IO_REPORT_SIZE;
	// Write simple value to IOW24
	case IOWKIT_PRODUCT_ID_IOW24:
		rep.Bytes[3] = (UCHAR) value;
		return IowKitWrite(devHandle, IOW_PIPE_IO_PINS,
			(PCHAR) &rep, IOWKIT24_IO_REPORT_SIZE) == IOWKIT24_IO_REPORT_SIZE;
	default:
		return FALSE;
	}
}
int main(int argc, char* argv[]); 

int main(int argc, char* argv[])
{
	IOWKIT_HANDLE iows[IOWKIT_MAX_DEVICES];
	int i, j, fnum, relnum,portnr;
	ULONG bits;
	int numIows;
	IOWKIT_REPORT rep;
	WCHAR sn[9];
	BOOLEAN rc;
	DWORD pid;
	IOWKIT_HANDLE devHandle;


   //eingefügt zum Lesen von argc und argv
    printf("argc ist %d\n", argc);

	if (argc>0)
	{
		for (i=0;i<=argc-1;i++)
		{
		       printf("argv[%d] ist %s\n",i,argv[i]);
		}
	}
               if (argc==3)
	{
                  fnum=atoi(argv[1]);
	  portnr=atoi(argv[2]);
	  printf ("Fehlernummer ist %d\n",fnum);
	  printf ("device ist %d\n",portnr);
                 }
	else 
	{portnr=0;
	 printf("Portnummer wurde auf 0 gesetzt!\n");
	}
// Open device
.........................
......................	
// Init report
	// Report ID 0 is for writing to 32 input/output pins
	rep.ReportID = 0;
	printf("Blinking LEDs...\n");
	//srand(time(NULL));
	// Blinking'
	for (i = 0; i < 12; i++)
	{
		//bits = rand();
		// Make every IOW blink
		for (j = 0; j < numIows; j++)
		{
			// Write to simple endpoint
			//rc = WriteSimple(iows[j], fnum);
			printf(".");
			rc = WriteSimple(iows[j], fnum); //, portnr
			// Check for error
			if (!rc)
			printf("Cannot write, err %d\n", GetLastError());
		}
		// Sleep for 25ms
		Sleep(2500);
	}
	printf("\nBlinking complete\n");
	// Set LEDs off
	for (i = 0; i < numIows; i++)
		// Write to simple endpoint
		WriteSimple(iows[i], 0xFFFFFFFF);
	for(i = 0; i < 10; i++)
	{

		// Read immediate
		rc = IowKitReadImmediate(iows[0], &bits);
		//rc = IowKitReadImmediate(iows[0], &fnum);
		printf("%d) ReadImm(): rc=%d bits=%x\n", i, rc, bits);
		//printf("%d) ReadImm(): rc=%d fnum=%x\n", i, rc, fnum);
	
		Sleep(100);
	}
	// Close device
	IowKitCloseDevice(devHandle);
out:

	return 0;
}

OK, ich möchte in diese WriteSimple endpoints statt DWORD value --fnum schreiben, auch portnr (portnummer) auch int. Aber diese Funktion ist so deklariert, dass ich darf nur eine Wert schreiben. Diese fnum muss ich übertragen und auf meine Release schreiben(steuern) und dann dieser geschriebene Wert auf Ausgang lesen mit ReadImm.Diese ReadImm liest letzte Zustand.Damit ich sehe, was habe ich geschrieben, gibt se Lichtdioden, aber auf anderem Portnummer, deshalb brauche ich auch diese portnr.
Ich hoffe, dass ich meine Aufgabe gut erklärt habe. :) Wenn du kannst etwas raten, werde ich freuen.
Danke noch einmal :)
 
Zurück