- •Important Information
- •Warranty
- •Copyright
- •Trademarks
- •Organization of This Manual
- •Conventions Used in This Manual
- •Related Documentation
- •Customer Communication
- •Introduction
- •Classes of External Code
- •Supported Languages
- •Macintosh
- •Microsoft Windows 3.1
- •Microsoft Windows 95 and Windows NT
- •Solaris
- •Steps for Creating a CIN
- •1. Place the CIN on a Block Diagram
- •2. Add Input and Output Terminals to the CIN
- •Input-Output Terminals
- •Output-Only Terminals
- •3. Wire the Inputs and Outputs to the CIN
- •4. Create .c File
- •Special Macintosh Considerations
- •5. Compile the CIN Source Code
- •Macintosh
- •THINK C for 68K (Versions 5-7)
- •Symantec C++ 8.0 for Power Macintosh
- •Metrowerks CodeWarrior for 68K
- •Metrowerks CodeWarrior for Power Macintosh
- •Microsoft Windows 3.x
- •Watcom C Compiler
- •Microsoft Windows 95 and Windows NT
- •Microsoft SDK C/C++ Compiler
- •Visual C++ for Windows 95 or Windows NT
- •Solaris 1.x
- •Solaris 2.x
- •6. Load the CIN Object Code
- •LabVIEW Manager Routines
- •Online Reference
- •Pointers as Parameters
- •Debugging External Code
- •DbgPrintf
- •Debugging CINs Under Windows 95 and Windows NT
- •Debugging CINs Under Sun or Solaris
- •Debugging CINs Under HP-UX
- •Introduction
- •CIN .c File
- •How LabVIEW Passes Fixed Sized Data to CINs
- •Scalar Numerics
- •Scalar Booleans
- •Refnums
- •Clusters of Scalars
- •Return Value for CIN Routines
- •Examples with Scalars
- •1. Place the CIN on the Block Diagram
- •2. Add Two Input and Output Terminals to the CIN
- •3. Wire the Inputs and Outputs to the CIN
- •4. Create the CIN Source Code
- •5. Compile the CIN Source Code
- •Macintosh
- •THINK C for 68K and Symantec C++
- •Microsoft Windows 3.x
- •Watcom C Compiler
- •Microsoft Windows 95 and Windows NT
- •Microsoft SDK Compiler
- •Microsoft Visual C++ Compiler
- •Solaris 1.x, Solaris 2.x, and HP-UX
- •6. Load the CIN Object Code
- •Comparing Two Numbers, Producing a Boolean Scalar
- •How LabVIEW Passes Variably Sized Data to CINs
- •Alignment Considerations
- •Arrays and Strings
- •Paths (Path)
- •Clusters Containing Variably Sized Data
- •Resizing Arrays and Strings
- •SetCINArraySize
- •NumericArrayResize
- •Examples with Variably Sized Data
- •Concatenating Two Strings
- •Working with Clusters
- •CIN Routines
- •Data Spaces and Code Resources
- •CIN Routines: The Basic Case
- •Loading a VI
- •Unloading a VI
- •Loading a New Resource into the CIN
- •Compiling a VI
- •Running a VI
- •Saving a VI
- •Aborting a VI
- •Multiple References to the Same CIN
- •Reentrancy
- •Code Globals and CIN Data Space Globals
- •Examples
- •Using Code Globals
- •Using CIN Data Space Globals
- •Calling a Windows 3.1 Dynamic Link Library
- •Calling a 16-Bit DLL
- •1. Load the DLL
- •2. Get the address of the desired function
- •3. Describe the function
- •4. Call the function
- •Example: A CIN that Displays a Dialog Box
- •The Block Diagram
- •The CIN Code
- •Compiling the CIN
- •Optimization
- •Introduction
- •Creating Shared External Subroutines
- •External Subroutine
- •Macintosh
- •THINK C Compiler and CodeWarrior 68K Compiler
- •MPW Compiler
- •Solaris 1.x, Solaris 2.x, and HP-UX
- •Calling Code
- •Macintosh
- •THINK C Compiler
- •CodeWarrior 68K Compiler
- •MPW Compiler
- •Solaris 1.x, Solaris 2.x, and HP-UX
- •Simple Example
- •External Subroutine Example
- •Compiling the External Subroutine
- •Macintosh
- •THINK C Compiler and CodeWarrior 68K Compiler
- •MPW Compiler
- •Microsoft Windows 3.1
- •Watcom C Compiler
- •Microsoft Windows 95 and Windows NT
- •Solaris 1.x, Solaris 2.x, and HP-UX
- •Calling Code
- •Compiling the Calling Code
- •Macintosh
- •THINK C Compiler
- •CodeWarrior 68K Compiler
- •MPW Compiler
- •Microsoft Windows 3.1
- •Watcom C Compiler
- •Microsoft Windows 95 and Windows NT
- •Solaris 1.x, Solaris 2.x, and HP-UX
- •Introduction
- •Basic Data Types
- •Scalar Data Types
- •Booleans
- •Numerics
- •Complex Numbers
- •char Data Type
- •Dynamic Data Types
- •Arrays
- •Strings
- •C-Style Strings (CStr)
- •Pascal-Style Strings (PStr)
- •LabVIEW Strings (LStr)
- •Concatenated Pascal String (CPStr)
- •Paths (Path)
- •Memory-Related Types
- •Constants
- •Memory Manager
- •Memory Allocation
- •Static Memory Allocation
- •Dynamic Memory Allocation: Pointers and Handles
- •Memory Zones
- •Using Pointers and Handles
- •Simple Example
- •Reference to the Memory Manager
- •Memory Manager Data Structures
- •File Manager
- •Introduction
- •Identifying Files and Directories
- •Path Specifications
- •Conventional Path Specifications
- •Empty Path Specifications
- •LabVIEW Path Specification
- •File Descriptors
- •File Refnums
- •Support Manager
- •Allocating and Releasing Handles
- •Allocating and Releasing Pointers
- •Manipulating Properties of Handles
- •AZHLock
- •AZHPurge
- •AZHNoPurge
- •AZHUnlock
- •Memory Utilities
- •ClearMem
- •MoveBlock
- •SwapBlock
- •Handle and Pointer Verification
- •Memory Zone Utilities
- •File Manager Data Structures
- •File/Directory Information Record
- •File Type Record
- •Path Data Type
- •Permissions
- •Volume Information Record
- •File Manager Functions
- •Performing Basic File Operations
- •FCreate
- •FCreateAlways
- •FMClose
- •FMOpen
- •FMRead
- •FMWrite
- •Positioning the Current Position Mark
- •FMSeek
- •FMTell
- •Positioning the End-Of-File Mark
- •FGetEOF
- •FSetEOF
- •Flushing File Data to Disk
- •FFlush
- •FExists
- •FGetAccessRights
- •FGetInfo
- •FGetVolInfo
- •FSetAccessRights
- •FSetInfo
- •Getting Default Access Rights Information
- •FGetDefGroup
- •FListDir
- •FNewDir
- •Copying Files
- •FCopy
- •Moving and Deleting Files and Directories
- •FMove
- •FRemove
- •Locking a File Range
- •FLockOrUnlockRange
- •Matching Filenames with Patterns
- •FStrFitsPat
- •Creating Paths
- •FAddPath
- •FAppendName
- •FAppPath
- •FEmptyPath
- •FMakePath
- •FNotAPath
- •FRelPath
- •Disposing Paths
- •FDisposePath
- •Duplicating Paths
- •FPathCpy
- •FPathToPath
- •Extracting Information from a Path
- •FDepth
- •FDirName
- •FName
- •FNamePtr
- •FVolName
- •FArrToPath
- •FFlattenPath
- •FPathToArr
- •FPathToAZString
- •FPathToDSString
- •FStringToPath
- •FTextToPath
- •FUnFlattenPath
- •Comparing Paths
- •FIsAPath
- •FIsAPathOrNotAPath
- •FIsEmptyPath
- •FPathCmp
- •Determining a Path Type
- •FGetPathType
- •FIsAPathOfType
- •FSetPathType
- •Manipulating File Refnums
- •FDisposeRefNum
- •FIsARefNum
- •FNewRefNum
- •FRefNumToFD
- •FRefNumToPath
- •Byte Manipulation Operations
- •Mathematical Operations
- •For THINK C Users
- •RandomGen
- •String Manipulation
- •BlockCmp
- •CPStrCmp
- •CPStrIndex
- •CPStrInsert
- •CPStrRemove
- •CPStrReplace
- •CPStrSize
- •CToPStr
- •HexChar
- •IsAlpha
- •IsDigit
- •IsLower
- •IsUpper
- •LStrCmp
- •LToPStr
- •PPStrCaseCmp
- •PPStrCmp
- •PStrCaseCmp
- •PStrCat
- •PStrCmp
- •PStrCpy
- •PStrNCpy
- •PToCStr
- •PToLStr
- •StrCat
- •StrCmp
- •StrCpy
- •StrLen
- •StrNCaseCmp
- •StrNCmp
- •StrNCpy
- •ToLower
- •ToUpper
- •Utility Functions
- •BinSearch
- •QSort
- •Time Functions
- •ASCIITime
- •DateCString
- •DateToSecs
- •MilliSecs
- •SecsToDate
- •TimeCString
- •TimeInSecs
- •Microsoft Windows 3.1, Windows 95, and Windows NT
- •Macintosh
- •How do I debug my CIN?
- •Can LabVIEW be used to call a DLL in Windows?
- •Glossary
- •Index
Chapter 1 CIN Overview
For example, to build a Power Macintosh makefile for a CIN named myCIN, execute the following command:
LVMakeMake -PPC myCIN > myCIN.ppc.make
## creates the makefile
You can then use the MPW make tool to build your CIN, as shown in the following commands.
make -f myCIN.ppc.make> myCIN.makeout
##creates the build commands myCIN.makeout
##executes the build commands
You should load the .lsb file this application produces into your LabVIEW CIN node.
Microsoft Windows 3.x
Microsoft Windows 3.x is a 16-bit operating system. Most applications written for it are 16-bit applications. A 16-bit application faces several obstacles when working with large amounts of information, such as manipulating arrays that require more than 64 kilobytes of memory.
LabVIEW is a 32-bit application without most of the inherent limitations found in 16-bit applications. Because of the way that CINs are linked to VIs, however, LabVIEW can use only code compiled for 32-bit applications. This is because CINs reside in the same memory space as VIs and work with LabVIEW data. To create CINs, a compiler must be able to create 32-bit relocatable object code.
The only compiler that currently supports the correct format of executables is Watcom C. The following section lists the steps for compiling a CIN with the Watcom compiler.
Watcom C Compiler
With the Watcom C compiler, you create a specification that includes the name of the file you want to create, relevant directories, and any external subroutines or object files the CIN needs. (External subroutines are described in Chapter 4, External Subroutines.) You then use the wmake utility included with Watcom to compile the CIN.
© National Instruments Corporation |
1-29 |
LabVIEW Code Interface Reference Manual |
Chapter 1 CIN Overview
In addition to compiling the CIN, the makefile directs wmake to put the CIN in the appropriate form for LabVIEW.
The makefile should look like the following pseudocode. You should append .lvm to the makefile name to indicate that this is a LabVIEW makefile.
name = name |
Name for the code; indicates the base |
|
name for your CIN. The source code |
|
for your CIN should be in name.c. |
|
The code created by the makefile is |
|
placed in a new file, name.lsb |
|
(.lsb is a mnemonic for LabVIEW |
|
subroutine). |
type = type |
Type of external code you want to |
|
create. For CINs, you should use a type |
|
of CIN. |
codeDir = codeDir |
Complete or partial pathname to the |
|
directory containing the .c file used |
|
for the CIN. |
wcDir = wcDir |
Complete or partial pathname to the |
|
directory containing the Watcom |
|
compiler. |
CinToolsDir = CinToolsDir |
|
|
Complete or partial pathname to the |
|
LabVIEW cintools directory, |
|
which is located in the LabVIEW |
|
directory. This directory contains |
|
header files you can use for creating |
|
CINs, and tools that the wmake utility |
|
uses to create the CIN. |
inclDir = inclDir |
(optional) Complete or partial |
|
pathname to a directory containing any |
|
additional .h files. |
objFiles = objFiles |
(optional) List of additional object |
|
files (files with an .obj extension) |
|
that your code needs to compile. |
|
Separate the names of files with |
|
spaces. |
LabVIEW Code Interface Reference Manual |
1-30 |
© National Instruments Corporation |
Chapter 1 CIN Overview
subrNames = subrNames (optional) List of external subroutines the CIN calls. You need subrNames only if the CIN calls external subroutines. Separate the names of subroutines with spaces.
!include $(CinToolsDir)\generic.mak
Execute the wmake command by entering the following in DOS.
wmake /f <name of your CIN>.lvm
Note: The wmake utility sometimes erroneously stops a make with an incorrectly reported error when it is run in the DOS shell within Windows. If this happens, run it in normal DOS.
The wmake utility scans the specified LabVIEW makefile and remembers the defined values. The last line of the makefile,
!include $(CinToolsDir)\generic.mak, instructs wmake to compile the code resource based on instructions in the generic.mak file, which is stored in the cintools directory. The wmake utility compiles the code and then transforms it into a form that LabVIEW can use. The resulting code is stored in a name.lsb file, where name is the CIN name given in the name line of the makefile.
Note: You cannot link most of the Watcom C libraries to your CIN because precompiled libraries contain code that cannot be properly resolved by LabVIEW when it links a VI to a CIN. If you try to call those functions, your CIN may crash.
LabVIEW provides functions that correspond to many of the functions in these libraries. These functions are described in subsequent chapters of this manual. If you need to call a function that is not supplied by LabVIEW, you can access the function from a dynamic link library (DLL). A CIN can call a DLL using the techniques described in the Watcom C manuals. A DLL can call any function from the C libraries. See Chapter 3, CIN Advanced Topics, for information on calling a DLL.
© National Instruments Corporation |
1-31 |
LabVIEW Code Interface Reference Manual |