USB Communication API

Communication between the PC and Commander core is done using the Windows-compatible DLL API functions shown below. Windows programming languages that use a DLL, such as Visual BASIC, Visual C++, Java, Python, LabVIEW, etc. can be used to communicate with the Commander core.

Typical communication transaction time for sending a command from the PC and getting a reply from the controller using the SendReceiveCommander API function is typically a millisecond. This value will vary with the CPU speed and type of command requested.

The DLL file CMDHidApi.dll (Windows 32bit), CMDHidApi64.dll (Windows 64bit), or CMDHidApiLinux.so are needed to access these API functions. These DLL files are not included with this product, download them from our website. 

Versions

There are 2 versions of the USB DLL.

  • v1.0 only works with firmware version 3.0.0 - 3.04.9
    • Uses the HID protocol to communicate with the Commander board.
    • Available for Windows x64 and x86 platforms.
  • v2.0 works with firmware version 3.05.0 and later. It is fully backwards compatible with v1.0.
    • Uses a custom protocol to communicate with the Commander board. This allows for faster communication and more features.
    • Available for Windows x64 and x86 platforms, and Linux platforms.
    • Requires a driver installation on Windows.


The differences in the 2 versions API calls are as follows:


V 2.0 Function name

V 1.0 Function name

Description

GetCommanderAPIversion(int* mainVer, int* minVer, int*  build)


GetCommanderHIDversion(int* mainVer, int* minVer, int* build)

Obtains the version of the Commander API.

Returns error code.

GetCommanderCount()

GetCommanderHIDnumber()

Returns the number of Commander boards connected to the computer


GetCommanderID(int index, char* name)

GetCommanderHIDName(int index, char* name) 

Obtains the ID name of the Commander board at the specified index.

Returns error code.



OpenCommanderByID(CommanderDeviceHandle* pHandle, char* name)

OpenCommanderHID(HANDLE* pHandle, char* name) 

Opens a connection to the Commander board with the specified name and obtains the handle to the connection.

Returns error code.


OpenCommanderByIndex(CommanderDeviceHandle** device, int index)

n/a

Opens a connection to the Commander board with the specified index and obtains the handle to the connection.

Returns error code.

CloseCommander(CommanderDeviceHandle* pHandle)

CloseCommanderHID(HANDLE* pHandle)


Closes the connection to Commander board with the specified handle.

Returns error code


SendReceiveCommander(CommanderDeviceHandle* pHandle, char* command, char* reply)

SendReceiveCommanderHID(HANDLE* pHandle, char* command, char* reply)



Sends a char based command to the Commander board with the specified handle and obtains a char based reply.

Returns error code.


SendCommander(CommanderDeviceHandle* pHandle, char* command)

n/a


Sends a char based command to the Commander board with the specified handle and does not expect a reply.

Returns error code.

SendReceiveBytesCommander(CommanderDeviceHandle* device, uint8_t* command, size_t command_length, uint8_t* reply, size_t reply_length)


n/a

Sends a byte based command to the Commander board with the specified handle and obtains a bytes based reply.

Returns error code.

SendBytesCommander(CommanderDeviceHandle* device, uint8_t* command, size_t length)


n/a

Sends a byte based command to the Commander board and does not expect a reply.

Returns error code.

StreamDataToCommander(CommanderDeviceHandle* device, uint8_t* data, size_t length) 

n/a

Sends multiple byte based commands to Commander at once.

Returns error code.


DLL/API functions

In this section