[ create a new paste ] login | about

Link: http://codepad.org/n7L6nkha    [ raw code | fork ]

C++, pasted on Dec 15:
UINT8 bufferS[2];
	UINT8 buffer[7];
	UINT8 x0=0,x1=0,y0=0,y1=0,z0=0,z1=0;
	INT16 x=0, y=0, z=0;
	DWORD i=0,bytesReturned = 0;
	stringstream ss;
	string temp;
	
	while (1)
	{
		ReadFile(device, &bufferS, 1, &bytesReturned, NULL);
		if(bufferS[0]==0x73){
			printf("it found the s string\n");
			break;
		}
	}

	while (ReadFile(device, &bufferS, 1, &bytesReturned, NULL) > 0)
	{
		
		
		
		if(bytesReturned==1){
			
			buffer[i]=bufferS[0];
			//cout <<bytesReturned;
			//printf(" %x ",buffer[i]);
			//printf("%d",i);
			i++;
			
		}else{
			//i=0;
			//printf("\n byte lost! byte number: %d \n",i);
		}

		if(i==6){
			x=(buffer[1]<<8)| buffer[0];
			y=(buffer[3]<<8)| buffer[2];
			z=(buffer[5]<<8)| buffer[4];
			printf("\n%6d %6d %6d\n",x,y,z);
			i=0;
			//printf("\n");
		}
		
		
		//cout << hex << temp;
		
	}


Create a new paste based on this one


Comments: