Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tip
Example: in TE0300DLL.dll, the buffer size is fixed to 2 kbyte, while in TE_USB_FX2_CyAPI.dll you are free to choose 4 kbyte or more.

Function translation

| |
Dewesoft C++ DLLTrenz Electronic C++ DLL
HANDLE m_handle = 0;CCyUSBDevice *USBdevList = new CCyUSBDevice((HANDLE)0,CYUSBDRV_GUID,true);
cout << endl << TE0300_ScanCards() << endl;cout << endl << TE_USB_FX2_ScanCards(USBdevList) << endl;
TE0300_Open(&m_handle, 0)
Wiki Markup
!=0;TE_USB_FX2_Open(USBdevList, 0)!=0;
TE0300_Open(&m_handle, 1)
Wiki Markup
!=0;TE_USB_FX2_Open(USBdevList, 1)!=0
TE0300_Close(&m_handle);TE_USB_FX2_Close(USBdevList);
TE0300_SendCommand(handle, cmd, cmd_length, reply, &reply_length, timeout)TE_USB_FX2_SendCommand(USBdevList, cmd, cmd_length, reply, reply_length, timeout)
Note
titleNote 1

...

TE_USB_FX2_Open(USBdevList, x) acts more as a SelectCard() function because the list (handles) of USB devices is already created in USBdevList.

 

The TE_USB_FX2_Close() function takes an already initialized USB device list (USBDeviceList) and closes the handle to the Trenz Electronic device driver, if one is open. This function closes all internal handles of USBDeviceList.

Warning about derived variables

Icon
If TE_USB_FX2_Close() is called, then dynamically allocated members of the CCyUSBDevice class are de-allocated. And, all "shortcut" pointers to elements of the EndPoints array (ControlEndPt, IsocIn/OutEndPt, BulkIn/OutEndPt, InterruptIn/OutEndPt) are reset to NULL.
Icon
This function does not differ much from from its homonym of the previous TE0300DLL.dll; the only difference is that this function closes a handle (like TE0300DLL.dll) to the driver but the handle is not exposed to user because it is not exposed by USBDeviceList (unlike TE0300DLL.dll).

In the code, it is possible to call TE_USB_FX2_Open() where TE0300_Open() is used.

In the code, it is possible to call TE_USB_FX2_Close() where TE0300_Close() is used, but

  • it is rare that you would ever need to call TE_USB_FX2_Close() explicitly (though doing so would not cause any problems). 
  • TE_USB_FX2_Open() realize automatically much of the TE_USB_FX2_Close() work.
Icon

Other internal handles (inside USBDeviceList) are automatically closed by TE_USB_FX2_Open() function when another handle to the device driver is already open (i.e. a TE_USB_FX2_Open() has been successfully used before). It is a behavior inherithed by CyAPI.dll Open() function.


Note 2:
In the code, it is possible to call TE_USB_FX2_Open() where TE0300_Open() is used.In the code, it is possible to call TE_USB_FX2_Close() where TE0300_Close() is used, but it is rare that you would ever need to call TE_USB_FX2_Close() explicitly (though doing so would not cause any problems). The TE_USB_FX2_Close() function closes the handle to the Trenz Electronic device driver, if one is open.
If TE_USB_FX2_Close() is called, then dynamically allocated members of the CCyUSBDevice class are de-allocated. And, all "shortcut" pointers to elements of the EndPoints array (ControlEndPt, IsocIn/OutEndPt, BulkIn/OutEndPt, InterruptIn/OutEndPt) are reset to NULL.
Close is automatically carried out by the TE_USB_FX2_Open() function, if a handle to the device driver is already open (i.e. a TE_USB_FX2_Open() has been successfully used before).

...