How to write C# programs using the new DLL starting from the old DLL.
There are some major differences between the two DLLs.
...
Dewesoft C++ DLL | Trenz Electronic C# DLL | |||||||||||||||
HANDLE m_handle = 0; | CyUSBDevice TE_USB_FX2_USBDevice = null;
| |||||||||||||||
cout << endl << TE0300_ScanCards() << endl; | int NumberOfCardAttached = TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_ScanCards(ref USBdevList); | |||||||||||||||
TE0300_Open(&m_handle, 0)!=0 | TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_Open
| |||||||||||||||
TE0300_Open(&m_handle, 1)!=0 | TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_Open | |||||||||||||||
TE0300_Close(&m_handle); | TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_Close
| |||||||||||||||
TE0300_SendCommand(handle, cmd, cmd_length, reply, &reply_length, timeout) | TE_USB_FX2.TE_USB_FX2.TE_USB_FX2_SendCommand |
Dewesoft C++ DLL | Trenz Electronic C# DLL | |
void ResetFX2FifoStatus(HANDLE handle) { cout << endl << "Resetting all FIFOs" << endl; byte
reply[64]; int
int cmd_length = 64; int
= 64;
= 0xA4;//command RESET_FIFO_STATUS
= 0;//RESET all FIFOs ifFIFOs cmd, cmd_length, reply, &reply_length, 1000)) cout <<
<< endl;
= 0xA0;//command INITIALIZEINITIALIZE = 1;//FIFO mode ifmode cmd, cmd_length, reply, &reply_length, 1000)) cout <<
<< endl;
| static void ResetFX2FifoStatus(CyUSBDevice TE_USB_FX2_USBDevice) { if
== null) {
device is selected"); return; }
all FIFOs");
cmd = new byte[64];
reply = new byte[64]; int
= 64; int
= 64; uint
= 100000;
= (byte)FX2_Commands.RESET_FIFO_STATUS;
= 0; //reset all fifos iffifos TE_USB_FX2_USBDevice, ref cmd, ref cmd_length, ref reply, ref reply_length, TIMEOUT_MS) == false)
Send Command Reset all fifos");
= (byte)FX2_Commands.INITALIZE; //0xA0;//command INITIALIZEINITIALIZE = 1;//FIFO mode ifmode TE_USB_FX2_USBDevice, ref cmd, ref cmd_length, ref reply, ref reply_length, TIMEOUT_MS) == false)
Switch Mode Fifo Mode");
|
Dewesoft C++ DLL | Trenz Electronic C# DLL | Code Block | | language | cpp
---|---|---|---|---|
void ReadData(unsigned int handle) { int packetlen =
int packets = 1200;
* data; data = new byte
memory
test
start
(unsigned int i = 0; i < packets; i++) { packetlen =
(TE0300_GetData(handle, data+total_cnt, &packetlen, PI_EP6,TIMEOUT_MS)) { cout <<
<< endl;
+= packetlen;
= ElapsedTime.Stop(false);
StopWatch timer
test
data; } Code Block | | language | c#static void ReadDataFPGAIntegrity(CyUSBDevice TE_USB_FX2_USBDevice, int BUFFER_SIZE, uint TIMEOUT_MS)
(TE_USB_FX2_USBDevice == null) {
device is selected");
packets = 1200;
data = new byte[packetlen*packets];
buffer = new byte[packetlen];
total_cnt = 0;
errors = 0;
PI_EP6 = 6;
bResultXfer = false;
TE_USB_FX2_USBDevice, MB_Commands.FX22MB_REG0_START_TX, TIMEOUT_MS);
test
= 0;
= 0;
stopWatch = new Stopwatch();
(int i = 0; i < packets; i++) { packetlen =
(byte* buf = &data[total_cnt] ) bResultXfer =) TE_USB_FX2_USBDevice, ref buffer, ref packetlen, PI_EP6, TIMEOUT_MS,BUFFER_SIZE);
data, total_cnt, packetlen);
(bResultXfer == false) {
Get Data");
+= packetlen;
ts = stopWatch.Elapsed;
TE_USB_FX2_USBDevice, MB_Commands.FX22MB_REG0_STOP, TIMEOUT_MS);
test
|
Dewesoft C++ DLL | Trenz Electronic C# DLL |
void WriteData(unsigned int handle) | static void WriteData(CyUSBDevice TE_USB_FX2_USBDevice, int BUFFER_SIZE, uint TIMEOUT_MS) |
...