LabWindows/CVI

General Programming Guidelines

The following guidelines relate to general programming practices.

  • Base your instrument driver on an existing instrument driver or one of the class templates.
  • Avoid declaring function names that exceed 79 characters.
  • Choose an instrument prefix that uniquely identifies the instrument driver.
  • Make the base filename of the instrument driver files the same as the prefix for the instrument driver and the base filename of the .fp file. For example, the filenames for a driver might be tek2430a.fp, tek2430a.sub, tek2430a.c, and tek2430a.h.
  • Use only the VISA I/O library to perform instrument I/O where possible.
  • Use only the VISA data types.
  • Include ivi.h in the include file for your instrument driver. This file includes both vpptype.h and visa.h.
  • Declare functions that do not return values as void. You must include a return value control in a panel for functions that return values.
  • Avoid declaring large arrays within instrument drivers because arrays use large amounts of memory.
  • Do not use the FmtOut, printf, and User Interface Library functions.
  • Avoid using Advanced Analysis Library functions in instrument drivers. Many LabWindows/CVI users do not have the Advanced Analysis Library, which is available only with the LabWindows/CVI Full Development System.
  • Test all the instrument drivers you create. Test them in LabWindows/CVI and in stand-alone applications.
  • Avoid declaring global or static local variables. Instead, create attributes to store the data.
  • If it is an error for the user to set an attribute when the instrument is in certain configurations, you must check for these conditions in the check callback rather than the write callback. Because the default check callback uses only the range table, you must create a custom callback for this purpose. However, you can call Ivi_DefaultCheckCallback in your custom callback.
  • Use only the IVI memory allocation functions to dynamically allocate memory in your instrument driver.