XT2640OperatingManual 13July2016 Page137of187
ThisfunctionflushesthereceivebufferintheXT2640andtheHIDdriver.
HID_UART_STATUS HidUart_FlushBuffers (HID_UART_DEVICE device, BOOL flushTransmit, BOOL
flushReceive)
device
—DeviceobjectpointerasreturnedbyHidUart_Open().
flushTransmit—SettoTRUEtoflushthedevicetransmitbuffer.
flushReceive—SettoTRUEtoflushthedevicereceivebufferandHIDreceivebuffer.
ReturnValue:HID_UART_STATUS=HID_UART_SUCCESS,HID_UART_INVALID_DEVICE_OBJECT,
HID_UART_DEVICE_IO_FAILED
HidUart_Cancello
ThisfunctioncancelsanypendingHIDreadsandwrites.
HID_UART_STATUS HidUart_CancelIo (HID_UART_DEVICE device)
device
—DeviceobjectpointerasreturnedbyHidUart_Open().
ReturnValue:HID_UART_STATUS=HID_UART_SUCCESS,HID_UART_INVALID_DEVICE_OBJECT,
HID_UART_DEVICE_IO_FAILED
HidUart_SetTimeouts
Setsthereadandwritetimeouts.TimeoutsareusedforHidUart_Read()andHidUart_Write().Thedefaultvaluefortimeouts
is1000ms,buttimeoutscanbesettowaitforanynumberofmillisecondsbetween0and0xFFFFFFFF.
HID_UART_STATUS HidUart_SetTimeouts (HID_UART_DEVICE device, DWORD readTimeout, DWORD
writeTimeout)
device
—DeviceobjectpointerasreturnedbyHidUart_Open().
readTimeout—HidUart_Read()operationtimeoutinmilliseconds.
writeTimeout—HidUart_Write()operationtimeoutinmilliseconds.
ReturnValue:HID_UART_STATUS=HID_UART_SUCCESS,HID_UART_INVALID_DEVICE_OBJECT
Note‐Ifreadtimeoutsaresettoalargevalueandnodataisreceived,thentheapplicationmayappearunresponsive.Itis
recommendedtosettimeoutsappropriatelybeforeusingthedevice.
HidUart_SetUartConfig
Setsthebaudrate,databits,parity,stopbits,andflowcontrol.Caution,thissetsparameterswithintheXT2640–doNOT
alterthesesettingsfromthoseshownbelow.
HidUart_SetUartConfig(device,115200,HID_UART_EIGHT_DATA_BITS,HID_UART_NO_PARITY,
HID_UART_SHORT_STOP_BIT,HID_UART_RTS_CTS_FLOW_CONTROL)
device—DeviceobjectpointerasreturnedbyHidUart_Open().
ReturnValue:HID_UART_STATUS=HID_UART_SUCCESS,HID_UART_INVALID_PARAMETER,
HID_UART_INVALID_DEVICE_OBJECT,HID_UART_DEVICE_IO_FAILED
24.1.4 GPIB INTERFACE
TheGPIBcapabilities,asdefinedbyIEEE488.1areSH1AH1T6L4SR1RL1PP1DC1DT0C0E2.
24.1.4.1 CONNECTINGTOTHEGPIBIN TERFAC E
Itisrecommendedtouseahighquality,shielded,GPIBcable.SuitablecablesareavailablefromXiTRONinaselectionoflengths.
24.1.4.2 REMOTEAN DLOCALOPERATION
TheGPIBitselfhasaprotocolforestablishingandcontrollingthelocal/remotestateoftheXT2640sotherearenoXT2640
commandsrequiredtodosoasforotheravailableinterfaces.Thefrontpanelbutton(shownwhenintheremotestate)requeststhat
thelocalstatebeentered,butitistheGPIBinterfacewhichactuallycontrolsthatstateandmaydenythatrequest.
24.1.4.3 WRITINGSOFTWARETOCONTROLTHEXT2640VIAGPIB
GenerallymessagesandcontrolsaresentandreceivedviatheGPIBusingcallsintotheDLLdriverprovidedbythemanufacturerof
thespecificGPIBcontrollerbeingusedinthecomputer.Youshouldconsultthedocumentationprovidedwiththecontroller
regardingwritingsoftwaretocommunicatewiththeXT2640.
24.1.4.3.1 TerminatingCommand Sets
Inadditiontothecommandterminatorcharactersdescribedin24.2.1.1theuseoftheEOIsignaloftheGPIBinterfacemaybeused.
24.1.4.3.2 ReceivingResponsesviatheGPIBInterface
TheXT2640alwaysterminatesallresponseswiththeCRandLFcharactersasintheotheravailableinterfaces,howeverfortheGPIB
interfacetheEOIinterfacesignalisalsoassertedwiththeLFcharacter.
UnliketheotherinterfacesavailablefortheXT2640,theGPIBrequiresanactionfromthecontrollertobeabletoreceiveresponse
informationfromtheXT2640.ThisactivitycouldoccurintheGPIBinterfacewhennoresponseisavailable.
ManydevicessimplyholdtheGPIBinterfacewhenthisoccursandrelyonatimeoutoccurringatthecontrollertoreleasetheGPIB.
TheXT2640alwaysprovidesaresponse,andthatresponseisalwaysterminatedbytheCRandLFcharacters(thelaterwithEOI
asserted).IfthereisnoresponsethentherearenoresponsecharactersprecedingtheCR,buttheCRandLF+EOIcharactersare
alwaystransmitted.Inthismannerthebusitselfdoesnotbecome“hung”whenthisoccurs,butinsteadyoumustconsiderthe
possibilityofreceivingaresponsewhichcontainsnothinginyoursoftware.