Interfacing with the ActiveTwo digital IO port via C++

Post Reply
Lloyd
Posts: 25
Joined: Fri Mar 26, 2004 7:46 pm
Location: Wilmington, NC, USA
Contact:

Interfacing with the ActiveTwo digital IO port via C++

Post by Lloyd » Fri Feb 21, 2014 3:43 am

I have engaged a software developer to develop a piece of code to set events directly on the ActiveTwo digital output port via the C++ developer kit and USB driver. He is not an experienced C++ developer and is having some problems with getting the initialization to work. To my understanding, his confusion seems to relate to the recommendation to use a PCHAR data type in "BOOL USB_WRITE(HANDLE hdevice, PCHAR data);" and the related suggestions to use the following method for both initialization and disabling the USB interface:

"Call USB_WRITE...use an array of 64 zero bytes for the "data" input."

as compared to the suggestion to initiate handshaking by the method

"Call again USB_WRITE, inputs are "handle" (from step 1) and "data", this time use an array of 1 byte of 255 (FF) followed by 63 zero bytes for the "data" input."

I think that the issue stems from the fact that FF is a half byte so FF plus 63 zero bytes does not total 64 bytes. I will direct him here for the dialog, but it would be nice if a driver / C++ expert would get in on this and help him along.

Here are some comments from him and code snippets:

"Below is the code I have implemented based on the following link http://www.biosemi.com/faq/make_own_acq ... ftware.htm.

I have taken out most of the rest of the class for simplicities sake. In addition you will note that I am not creating a file pointer as of yet since I am simply trying to activate and write to the port (Biosemi device).

When I initially plugin the Biosemi device, with the LED dongle attached (a 37-pin plug with LED's to indicate the high/low state of each of the digital output bits), all but two of the red LEDs (on the special dongle) are lit. As I step through my code, using modal dialogs to act as breakpoints, ALL the LEDs go out when I make the call to “enable the handshake”. The green LED on the front (next to the USB connector) never lights and the only way to turn any of the red back on is to un-plug and re-plug in the device.

The calls to OPEN_DRIVER_ASYNC, the one to start the acquisition, and READ_MULTIPLE_SWEEPS are all being made in the constructor of the class since it would seem they would only need to be called once at the beginning of the process.

// CActiveDataPortImpl

class ATL_NO_VTABLE CActiveDataPortImpl :

public CComObjectRootEx<CComSingleThreadModel>,

public CComCoClass<CActiveDataPortImpl, &CLSID_ActiveDataPortImpl>,

public IDispatchImpl<IActiveDataPort, &__uuidof(IActiveDataPort),

&LIBID_DataPortExtensionLibrary>

{

public:

CActiveDataPortImpl()

{

bool nStatus = false;

BSTR * boolStatus;

// get the handle....

// check it exists

hdevice=OPEN_DRIVER_ASYNC();

if (!hdevice)

{

"

pmac
Posts: 70
Joined: Thu Jan 21, 2010 2:51 pm
Location: Canada

Re: Interfacing with the ActiveTwo digital IO port via C++

Post by pmac » Sat Feb 22, 2014 1:00 am

Lloyd:

1. You can see a C language initialization sequence that works in the source code for the test program Labview_DLL_SyncTest
that comes in the driver download package. The source code is in file labview_dll_synctest.cpp.

2. With regard to putting the READ_MULTIPLE_SWEEPS call in the class constructor, take note of the warning in the last
message in this thread
http://www.biosemi.nl/forum/viewtopic.php?f=7&t=554&p=1550&hilit=read_multiple#p1550

Paul

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest