1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| #include "stdafx.h"
#include <windows.h>
#include <conio.h>
#include <cmath>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <ctime>
#include <cstring>
using namespace std;
#include "CyAPI.h"
#pragma comment(lib, "CyAPI.lib") // this links CyAPI.lib statically to the project
#pragma comment(lib, "ws2_32.lib")
static GUID GUID_CYUSB_CYPRESS_FX2 = {0xAE18AA60, 0x7F6A, 0x11D4, 0x97, 0xDD, 0x00, 0x01, 0x02, 0x29, 0xB9, 0x59};
static GUID GUID_KNJN_FX2 = {0x0EFA2C93, 0x0C7B, 0x454F, 0x94, 0x03, 0xD6, 0x38, 0xF6, 0xC3, 0x7E, 0x65};
#define BulkOutPipe0 USBDevice->EndPoints[1]
#define BulkInPipe1 USBDevice->EndPoints[2]
#define BulkOutPipe2 USBDevice->EndPoints[3]
#define BulkOutPipe3 USBDevice->EndPoints[4]
#define BulkInPipe4 USBDevice->EndPoints[5]
#define BulkInPipe5 USBDevice->EndPoints[6]
///////////////////////////////////////////////////
void main()
{
unsigned char buf[512000];
unsigned int i=0;
unsigned int b=0;
unsigned long int j=0;
unsigned int compt=0;
string const nomFic( "C:\Users\E2S\Desktop\Oscilloscope\Oscilloscope.csv");
ofstream nflux(nomFic.c_str());
CCyUSBDevice *USBDevice = new CCyUSBDevice(NULL, GUID_KNJN_FX2);
if(!nflux) cout<< "erreur ouverture du fichier"<<endl;
else {
LONG len= 512000;
BulkInPipe4->XferData((PUCHAR)buf, len);
for(int c=0; c<512000 ;c++) nflux << (unsigned int)buf[c]<< endl;
}
delete USBDevice;
printf("done - press a key to terminate");
_getch();
} |
Partager