Omega Speaker Systems TC-08 manual Handle any error conditions if result ==

Page 23

Technical reference

19

Example

The following code is a fragment of a C application which demonstrates how to open a

single unit with the asynchronous open unit functions:

//======================================================

//Opening a unit asynchronously //======================================================

//Tell the driver to start enumerating the unit in the background

//(usb_tc08_open_unit_async returns immediately)

result = usb_tc08_open_unit_async();

//handle any error conditions if (result == -1)

{

error_code = usb_tc08_get_last_error(0);

printf("Unit failed to open\nThe error code is %d", error_code);

//could terminate the application here

}

else if (result == 0)

{

printf("No USB TC08 units found");

//could terminate the application here

}

//No errors, so start polling usb_tc08_open_unit_progress

//continuously for its enumeration state

do

{

result = usb_tc08_open_unit_progress(&handle, &progress);

switch (result)

{

case USBTC08_PROGRESS_FAIL: // enum equates to: -1error_code = usb_tc08_get_last_error(0);

printf("Unit failed to open\nThe error code is %d", error_code);

//could terminate the application here break;

case USBTC08_PROGRESS_PENDING: // enum equates to: 0 printf("\nThe unit is %d percent enumerated", progress); Sleep(500); // wait for approx. half a second

break;

case USBTC08_PROGRESS_COMPLETE: // enum equates to: 1 printf("\n\nThe unit with handle '%d', opened successfully",

handle); break;

}

}

while (result == USBTC08_PROGRESS_PENDING);

//

//Start using the open unit

Image 23
Contents User’s Guide Servicing North America Contents Page Overview Installing the driver Connecting the USB TC-08Refresh TC-08 Users GuideTC-08 Channels window, double-click on Channel 1 unused Mains voltages Safety warningSafety grounding Maximum input rangeSpecifications How a thermocouple works Introduction IntroductionModes of operation Streaming mode ================================================== ExampleGet Single mode Usbtc08setmains handle, 0 // use 50Hz mains noise rejection Legacy mode Now do something with the cold junction temperature Driver routines Routine Description New USB and serial modeNew USB mode only Legacy mode onlyArguments New USB mode and legacy modeShort usbtc08openunit void None Returns Positive shortStore the handle in an array handlearrayi = newhandle Arguments None Returns Short usbtc08openunitasync voidHandle any error conditions if result == Progress HandleArguments handle Short tc08closeunit Short handleShort usbtc08stop Short handle Sixtyhertz Short usbtc08setmains Short handle, short sixtyhertzInterval Long usbtc08getminimumintervalms Short handleMinimum Info Short usbtc08getunitinfo Shorthandle, USBTC08INFO * infoUSBTC08MAXINFOCHARS characters long Short usbgetformattedinfo Handle Char UnitinfoStringlength User/Developer error codes Error Further information Code Short usbtc08getlasterror Short handleCode ErrorReserved error codes Tctype New USB mode onlyChannel Long usbtc08run Short handle, long interval Units TempOverflowflags Overflow Long usbtc08gettemp Short Handle Float * tempbufferTempbuffer TimesmsbufferShort Channel Units Fillmissing Long usbtc08gettempdeskew Short Handle Float * temp TimesShort usbtc08legacyrun Short handle Legacy mode onlyFilterfactor Filtered Short usbtc08legacygetcoldjunction Long * temp, short handle Driver version Number Short usbtc08legacygetdriverversion VoidVersion Short usbtc08legacygetversion Short * version, short handleCycle Short usbtc08legacygetcycle Long * cycle, short handleDelphi ProgrammingC++ Agilent VEE ExcelLabVIEW Visual BasicKey TroubleshootingCold junction compensation. See CJC GlossaryTechnical reference Page Index TC-08 Users Guide WARRANTY/DISCLAIMER Shop online at omega.com