⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpleappcpp.cpp

📁 CardBus代码驱动等有用资料
💻 CPP
字号:
// simpleappCpp.cpp : Defines the entry point for the console application.
//
#include "Ioctls.h"
#include "stdafx.h"
#include <winioctl.h>
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main(int argc, char* argv[])
	{							

	time_t start, end;
	double diff;

	DWORD retcode = 0;
	int address = 0;

	DWORD noOfBytesWritten = 0;
	unsigned int noOfBytesToWrite;
	unsigned int buffer_ptr;

	unsigned char bufferWithValuesToWrite[1028];
	unsigned char tempBufferWithValuesToWrite[1024];


	HANDLE hdevice = CreateFile("\\\\.\\comblock_cardbus_0", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
	if (hdevice == INVALID_HANDLE_VALUE)
		{
		printf("Unable to open com1300 - error %d\n", GetLastError());
		return 1;
		}
	//else
	//	printf("succesfully opened handle\n");


	FILE *fp;	
	fp = fopen("PRBS11_1bw.bin", "rb");

	noOfBytesToWrite = 0;

	time(&start);

		
	while(!feof(fp)){
		buffer_ptr = 0;
		noOfBytesToWrite = fread(tempBufferWithValuesToWrite, sizeof(unsigned char), 1024, fp);
		if(noOfBytesToWrite == 0)
			break;
		else{
			while(noOfBytesToWrite > 0){
				memcpy(&bufferWithValuesToWrite[0 + buffer_ptr], &address, 4);
				memcpy(&bufferWithValuesToWrite[4 + buffer_ptr], &tempBufferWithValuesToWrite[buffer_ptr],noOfBytesToWrite); 

				DeviceIoControl(hdevice, IO_WRITE_8_BIT_FIX_ADDR, &bufferWithValuesToWrite[buffer_ptr], 
								4+noOfBytesToWrite, NULL, 0, &noOfBytesWritten, NULL);
				noOfBytesToWrite -= noOfBytesWritten;
				buffer_ptr += noOfBytesWritten;
			}
		}
	}

	time(&end);

	diff = difftime(end,start);
	printf("time taken %f seconds\n", diff);

		
	fclose(fp);

	CloseHandle(hdevice);
	//printf("succesfully closed handle\n");


	return retcode;
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -