XT2640OperatingManual 13July2016 Page135of187
' Uses a 2 second timeout to receive a complete line (far longer than needed)
Dim Timer As Stopwatch = Stopwatch.StartNew()
Dim rx_lf As Boolean = False
ReceiveString = “”
While (Not (rx_lf))
Dim rx_data(1024) As Byte
Dim rx_index As Integer = 0
Dim bytes As Integer = 0
HidUart_Read(usbdevice, rx_data, 1024, bytes)
' Because we configured a 0 read timeout this will return immediately if there’s no
' characters
While (bytes)
If (rx_data(rx_index) = 10) Then
rx_lf = True
Exit While
End If
rx_index += 1
bytes -= 1
End While
ReceiveString += System.Text.Encoding.ASCII.GetString(rx_data, 0, rx_index)
If (Timer.ElapsedMilliseconds > 2000) Then
' Timeout occurred – need to take some action here
Timer.Stop()
Exit Function
End If
End While
24.1.3.3 SUMMARYOFPR OVIDEDDLLFUNCTIONS
InallfunctioncallsrequiringaPIDand/orVID,youmustusethevaluesnotedabovefortheXT2640.
ThedefinitionsforthefunctionshownbelowuseaClanguageformforclarity;donotusethecallsexactlyasshowninsteadusethe
headerprovidedforthespecificlanguagebeingused.
CAUTION–theprovidedDLLfilesalsocontainotherfunctions,youmustnotcalltheseotherfunctionsotherwiseitmayrenderthe
XT2640permanentlyinoperative.
HidUart_GetNumDevices
ThisfunctionreturnsthenumberofdevicesconnectedtothehostwithmatchingvendorandproductID(VID,PID).
HID_UART_STATUS HidUart_GetNumDevices (DWORD* numDevices, WORD vid, WORD pid)
numDevices
—Returnsthenumberofdevicesconnectedonreturn.
vid—FilterdeviceresultsbyvendorID.
pid—FilterdeviceresultsbyproductID.
ReturnValue:HID_UART_STATUS=HID_UART_SUCCESS,HID_UART_INVALID_PARAMETER
HidUart_GetString
Thisfunctionreturnsanull‐terminatedvendorIDstring,productIDstring,serialstring,devicepathstring,manufacturer
string,orproductstringforthedevicespecifiedbyanindexpassedin
deviceNum.Theindexforthefirstdeviceis0andthe
lastdeviceisthevaluereturnedby
HidUart_GetNumDevices()–1.
HID_UART_STATUS HidUart_GetString (DWORD deviceNum, WORD vid, WORD pid, char*
deviceString, DWORD options)
deviceNum
—Indexofthedeviceforwhichthestringisdesired.
vid—FilterdeviceresultsbyvendorID.
pid—FilterdeviceresultsbyproductID.
deviceString—VariableoftypeHID_UART_DEVICE_STRING whichwillcontainaNULLterminatedASCIIdevicestringon
return.Thestringis260bytes.
options—DeterminesifdeviceStringcontainsavendorIDstring,productIDstring,serialstring,devicepathstring,
manufacturerstring,orproductstring.
ReturnValue:HID_UART_STATUS=HID_UART_SUCCESS,HID_UART_DEVICE_NOT_FOUND,
HID_UART_INVALID_PARAMETER,HID_UART_DEVICE_ACCESS_ERROR
HidUart_GetOpenedString
Thisfunctionreturnsanull‐terminatedvendorIDstring,productIDstring,serialstring,devicepathstring,manufacturer
string,orproductstringforthedevicespecifiedby
device.
HID_UART_STATUS HidUart_GetOpenedString (HID_UART_DEVICE device, char* deviceString,
DWORD options)
device
—DeviceobjectpointerasreturnedbyHidUart_Open().
deviceString—VariableoftypeHID_UART_DEVICE_STRINGwhichwillcontainaNULLterminatedASCIIdevicestringon
return.Thestringis260bytes.
options—DeterminesifdeviceStringcontainsavendorIDstring,productIDstring,serialstring,devicepathstring,
manufacturerstring,orproductstring.
ReturnValue:HID_UART_STATUS=HID_UART_SUCCESS,HID_UART_INVALID_DEVICE_OBJECT,
HID_UART_INVALID_PARAMETER,HID_UART_DEVICE_ACCESS_ERROR