它有附一些.h檔
// --------------------------------------------------------------------------
// IOTIEEE.H - Driver488/Wxx Library Header
//
// This file declares constants, typedef's and prototypes for the
// Driver488/Wxx API Library. Other API library files:
//
// IOTSLPIB.DLL - The Driver488 API dynamic-link library (DLL)
// IOTSLPIB.LIB - The Driver488 API import library
// IOTERROR.H - Error codes.
//
// -------------------------------------------------------------------------- #ifndef IOTIEEE_H
#define IOTIEEE_H // The Windows API Header
#include // Driver488 Error Codes
#include "ioterror.h" // This header uses a "C"-style interface.
#ifdef __cplusplus
extern "C" {
#endif // -----------------
// --- Constants ---
// ----------------- // Term flags.
#define TERMIN 1 // Input terminators
#define TERMOUT 2 // Output terminators // Can be used with some functions in place of a valid device handle.
#define NODEVICE -1 //
#define ON 1
#define OFF 0 // SPollList Flags
#define ALL -1 // Perform function on all devices.
#define WHILE_SRQ -2 // Stop if SRQ line becomes unasserted.
#define UNTIL_RSV -3 // Stop on the first device whose RSV bit is set. // Some Common IEEE488 Multi-line Commands
#define TAG(x) ((UCHAR)(0x40 | (x)))
#define LAG(x) (0x20 | (x))
#define SCG(x) (0x60 | (x))
#define PPE(x) (0x60 | (x))
#define UNL 0x3f
#define UNT 0x5f
#define SPE 0x18
#define SPD 0x19 // This is actually a Windows API function call that creates the default window
// message ID used by OnEvent and OnDigEvent. During a program session it can
// be called repeatedly, always returning the same value.
//
// NOTE: OnEventSetup can be used to change the window message ID used by
// the event notification functions.
#define WM_IEEE488EVENT (RegisterWindowMessage((LPSTR)"WM_IEEE488EVENT")) // -------------
// --- Types ---
// -------------
// Device handle. Returned by OpenName and used by most functions to
// identify a device or interface.
typedef int DevHandleT, *DevHandlePT; // Error Code. Returned by GetError.
typedef enum _IOT_ERROR_LEVEL ErrorCodeT; // Interface status structure. Used by the Status function to return
// information about the current status of an interface.
typedef struct {
BOOL reserved0; // reserved
BOOL reserved1; // reserved
BOOL SRQ ; // TRUE: the SRQ line is asserted.
BOOL reserved2; // reserved
BOOL reserved3; // reserved
BOOL reserved4; // reserved
BOOL reserved5; // reserved
BOOL reserved6; // reserved
BOOL reserved7; // reserved
BOOL reserved8; // reserved
BOOL reserved9; // reserved
BYTE Primaddr ; // Interface's primary bus address
BYTE reservedA; // reserved
}
IeeeStatusT, *IeeeStatusPT; // Termination structure type
typedef struct _IOT_TERMT {
BOOL EOI; // TRUE to enable EOI
BOOL EightBits; // reserved
int nChar; // Number of termination characters
BYTE termChar[2]; // The 8-bit values of the termination characters to use.
} TermT, *TermPT; // ControlLine Codes
//
// Each of these corresponds to an IEEE488 bus line. If the bit is on
// it means that the scorresponding line is asserted.
typedef enum {
clEOI = 0x80, // EOI - End or Identify
clSRQ = 0x40, // SRQ - Service Request
clNRFD = 0x20, // NRFD - Not Ready for Data
clNDAC = 0x10, // NDAC - Not Data Accepted
clDAV = 0x08, // DAV - Data Valid
clATN = 0x04, // ATN - Attention
}
ControlLineT, *ControlLinePT; // Enter & Output Completion Codes
typedef enum {
ccCount = 0x0001, // specified number of chars transfered
ccBuffer = 0x0002, // buffer count exhausted
ccTerm = 0x0004, // terminator character(s) detected
ccEnd = 0x0008, // END signal (EOI) detected
ccChange = 0x0010, // unexpected change of I/O signals
ccStop = 0x0020, // transfer terminated by program command
ccDone = 0x4000, // transfer has terminated
ccError = 0x8000
}
CompCodeT, *CompCodePT; // Arm Condition Codes
typedef enum {
acSRQ = 0x0400, // The SRQ control line has been asserted.
acDigMatch = 0x1000, // The digital match byte was seen. (PCI488 and AT488pnp only)
}
ArmCondT; // "Opaque" 32-bit value that can be passed to the OnEvent handlers.
//typedef void *OpaqueP;
typedef LPARAM OpaqueP; // -------------------
// --- Prototypes ---
// ------------------- //
// Open / Close functions
//
DevHandleT WINAPI OpenName( LPSTR devName );
int WINAPI Close( DevHandleT devHandle ); DevHandleT WINAPI MakeDevice( DevHandleT devHandle, LPSTR name );
DevHandleT WINAPI MakeNewDevice( LPSTR iName, LPSTR aName, BYTE primary, BYTE secondary, TermPT In, TermPT Out, DWORD timeout ); //
// Bus Configuration
//
int WINAPI KeepDevice ( DevHandleT devHandle );
int WINAPI RemoveDevice( DevHandleT devHandle ); //
// Error Handling
//
int WINAPI Error( DevHandleT handle, BOOL display );
ErrorCodeT WINAPI GetError ( DevHandleT devHandle, LPSTR errText );
ErrorCodeT WINAPI GetErrorList( DevHandlePT devHandleList, LPSTR errText, DevHandlePT errHandle ); //
// Interface/Device configuration and control
//
int WINAPI Abort ( DevHandleT devHandle );
int WINAPI AutoRemote ( DevHandleT devHandle, BOOL flag );
int WINAPI BusAddress ( DevHandleT devHandle, BYTE primary, BYTE secondary );
int WINAPI Clear ( DevHandleT devHandle );
int WINAPI Local ( DevHandleT devHandle );
int WINAPI Lol ( DevHandleT devHandle );
int WINAPI Remote ( DevHandleT devHandle );
int WINAPI Reset ( DevHandleT devHandle );
int WINAPI Term ( DevHandleT devHandle, TermT *term, DWORD termFlag );
int WINAPI TimeOut ( DevHandleT devHandle, DWORD millisec );
int WINAPI Trigger ( DevHandleT devHandle ); int WINAPI ClearList ( DevHandlePT devHandleList );
int WINAPI LocalList ( DevHandlePT devHandleList );
int WINAPI RemoteList ( DevHandlePT devHandleList );
int WINAPI TriggerList( DevHandlePT devHandleList ); //
// Interface/Device information/status
//
int WINAPI CheckListener( DevHandleT devHandle, BYTE primary, BYTE secondary );
int WINAPI FindListeners( DevHandleT devHandle, BYTE primary, LPWORD listener, DWORD limit );
int WINAPI Hello ( DevHandleT devHandle, LPSTR message );
int WINAPI Status ( DevHandleT devHandle, IeeeStatusPT status );
int WINAPI TimeOutQuery ( DevHandleT devHandle, DWORD *millisec );
int WINAPI TermQuery ( DevHandleT devHandle, TermT *term, int TermType ); int WINAPI SPoll ( DevHandleT devHandle );
int WINAPI SPollList( DevHandlePT devHandleList, LPBYTE result, BYTE flag ); int WINAPI PPoll ( DevHandleT devHandle );
int WINAPI PPollConfig ( DevHandleT devHandle, BYTE ppresponse );
int WINAPI PPollUnconfig ( DevHandleT devHandle );
int WINAPI PPollDisable ( DevHandleT devHandle );
int WINAPI PPollDisableList( DevHandlePT devHandleList ); //
// Input / Output
// LONG WINAPI EnterX ( DevHandleT devHandle, LPBYTE data, DWORD count, BOOL forceAddress, TermT *term, BOOL reserved, LPDWORD compStat);
LONG WINAPI OutputX( DevHandleT devHandle, LPBYTE data, DWORD count, BOOL last, BOOL forceAddress, TermT *term, BOOL reserved, LPDWORD compStat); // EnterX Shorthand Macros dh, data , count , forceAddr, termP, , compStat
#define Enter(dh,data) EnterX( dh, (LPBYTE)(data), (DWORD) sizeof (data), TRUE , NULL , 0 , NULL )
#define EnterN(dh,data,count) EnterX( dh, (LPBYTE)(data), count , TRUE , NULL , 0 , NULL )
#define EnterMore(dh,data) EnterX( dh, (LPBYTE)(data), (DWORD) sizeof (data), FALSE , NULL , 0 , NULL )
#define EnterNMore(dh,data,count) EnterX( dh, (LPBYTE)(data), count , FALSE , NULL , 0 , NULL ) // OutputX Shorthand Macros dh, data , count , last , forceAddr, termP, , compStat
#define Output(dh,data) OutputX( dh, (LPBYTE)(data), (DWORD)strlen((LPSTR)(data)), TRUE , TRUE , NULL , 0 , NULL )
#define OutputN(dh,data,count) OutputX( dh, (LPBYTE)(data), count , FALSE, TRUE , NULL , 0 , NULL )
#define OutputMore(dh,data) OutputX( dh, (LPBYTE)(data), (DWORD)strlen((LPSTR)(data)), TRUE , FALSE , NULL , 0 , NULL )
#define OutputNMore(dh,data,count) OutputX( dh, (LPBYTE)(data), count , FALSE, FALSE , NULL , 0 , NULL ) //
// OnEvent Functions
//
int WINAPI Arm ( DevHandleT devHandle, ArmCondT condition );
int WINAPI Disarm( DevHandleT devHandle, ArmCondT condition ); typedef void (*EventFuncT)( DevHandleT dh, UINT eventMask ); int WINAPI OnEvent ( DevHandleT devHandle, HWND hWnd, OpaqueP lParam );
int WINAPI OnEventVDM ( DevHandleT devHandle, EventFuncT func );
int WINAPI OnEventSetup( DevHandleT devHandle, UINT uWMID, LPDWORD pdwStatus ); //
// Digital I/O Support
//
int WINAPI DigRead ( DevHandleT devHandle );
int WINAPI DigWrite( DevHandleT devHandle, BYTE byDigData );
int WINAPI DigSetup( DevHandleT devHandle, BOOL bLowOut, BOOL bHighOut ); int WINAPI DigArm ( DevHandleT devHandle, BOOL bArm );
int WINAPI DigArmSetup( DevHandleT devHandle, BYTE byMatchValue ); typedef void (*DigEventFuncT)( DevHandleT devHandle, LPARAM lParam ); int WINAPI OnDigEvent ( DevHandleT devHandle, HWND hWnd , OpaqueP lParam );
int WINAPI OnDigEventVDM( DevHandleT devHandle, DigEventFuncT func, OpaqueP lParam ); //
// Low-Level Bus Control
// int WINAPI ControlLine( DevHandleT devHandle ); int WINAPI Listen ( DevHandleT devHandle, BYTE primary, BYTE secondary );
int WINAPI Talk ( DevHandleT devHandle, BYTE primary, BYTE secondary ); int WINAPI MyListenAddr( DevHandleT devHandle );
int WINAPI MyTalkAddr ( DevHandleT devHandle ); int WINAPI UnListen( DevHandleT devHandle );
int WINAPI UnTalk ( DevHandleT devHandle ); int WINAPI SendCmd ( DevHandleT devHandle, LPBYTE commands, DWORD count );
int WINAPI SendData( DevHandleT devHandle, LPBYTE data , DWORD count );
int WINAPI SendEoi ( DevHandleT devHandle, LPBYTE data , DWORD count ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//
// Obsolete library calls
//
// - For compatibility with pre-existing programs these functions still
// exist in IOTSLPIB.DLL, but now they return IOT_ERROR (-1) and set the
// Driver488 error code to IOT_OBSOLETE. Any source code files that use
// these functions will have to be edited before re-compilation.
//
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//
// int WINAPI PassControl ( DevHandleT devHandle );
// int WINAPI Request ( DevHandleT devHandle, BYTE spstatus );
// int WINAPI SysController( DevHandleT dh, BOOL flag );
//
// LONG WINAPI Buffered( DevHandleT devHandle );
// int WINAPI Finish ( DevHandleT devHandle );
// int WINAPI Resume ( DevHandleT devHandle, BOOL monitor );
// int WINAPI Stop ( DevHandleT devHandle );
// int WINAPI Wait ( DevHandleT devHandle );
//
// int WINAPI IOAddress( DevHandleT devHandle, DWORD addr );
// int WINAPI IntLevel( DevHandleT devHandle, int channel );
// int WINAPI DmaChannel( DevHandleT devHandle, int channel );
// int WINAPI ClockFrequency( DevHandleT devHandle, int freq );
//
// VOID WINAPI ByeByeDriver( VOID );
//
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * #ifdef __cplusplus
}
#endif #endif // IOTIEEE_H ------------------------------------------------------------- // --------------------------------------------------------------------------
// CIEEE488.H - Personal488 Command API Library C Header
//
// This header declares a C "wrapper" class for the "C"-style
// prototypes in IOTIEEE.H. The type definitions and macros in IOTIEEE.H
// are not encapsulated by this class.
//
// This file is intended as a "C "-style header for the Personal488
// Command API Library. It is not an attempt to create an object-oriented
// library interface.
//
// See the notes that appear after the class declaration.
// -------------------------------------------------------------------------- // Windows Header
#include // Includes the "C"-style function prototypes, type definitions and macros.
#include "iotieee.h" // The Enter and Output macros in IOTIEEE.H cannot be used along with this
// class declaration.
#undef Enter
#undef Output // Class Wrapper for the API Commands.
class CIeee488
{
private:
// This is a private member that holds the handle of an open
// interface or device. Read-only access to this member is
// provided by a type-conversion operator.
DevHandleT m_dh; public:
// Each of these constructors creates an object and opens a device.
// There is one of these for each of the Open member functions.
CIeee488( LPSTR pszName ) {
Open( pszName );
}
CIeee488( DevHandleT dh, LPSTR newName ) {
Open( dh, newName );
} CIeee488( LPSTR iName, LPSTR aName, BYTE pid, BYTE sid, TermPT In, TermPT Out, DWORD tOut ) {
Open( iName, aName, pid, sid, In, Out, tOut );
} // Default constructor. Creates an object with no device handle. One
// of the Open member functions can be called subsequently to open a
// device or interface.
CIeee488() { m_dh = -1; } // Class destructor. Automatically closes the handle.
~CIeee488() { if (IsOpen()) Close(); } // This allows the caller to access the private device handle member
// by using the object name wherever a DevHandleT value is expected.
operator DevHandleT () { return m_dh; } //
// Open/Close Members
//
// Opens the named interface or device.
int Open( LPSTR devName ) {
return m_dh = ::OpenName( devName );
}
// Creates and opens a copy of an open device and assigns it the given name.
int Open( DevHandleT dh, LPSTR newName ) {
return m_dh = ::MakeDevice( dh, newName );
}
// Creates and opens a new device from the given parameters.
int Open( LPSTR iName, LPSTR aName, BYTE pid, BYTE sid, TermPT In, TermPT Out, DWORD tOut ) {
return m_dh = ::MakeNewDevice( iName, aName, pid, sid, In, Out, tOut );
}
BOOL IsOpen() { return 0 <= m_dh; } // Closes the interface or device and de-initializes the internal handle.
int Close() {
int ret = ::Close( m_dh );
m_dh = -1;
return ret;
} int KeepDevice () { return ::KeepDevice ( m_dh );}
int RemoveDevice() { return ::RemoveDevice( m_dh );} //
// Input/Output
//
LONG Enter( LPBYTE data, DWORD count,
BOOL forceAddress = TRUE, TermT *term = NULL,
BOOL async = FALSE, LPDWORD completStat = NULL )
{
return ::EnterX( m_dh, data, count, forceAddress, term, async, completStat );
} LONG Output( LPBYTE data, DWORD count,
BOOL last = TRUE, BOOL forceAddress = TRUE, TermT *term = NULL,
BOOL async = FALSE, LPDWORD completStat = NULL )
{
return ::OutputX( m_dh, data, count, last, forceAddress, term, async, completStat );
} // Short-hand form of Output for string data.
LONG Output( LPSTR pszCmd ) { return Output( (LPBYTE)pszCmd, strlen( pszCmd )); } int SendCmd ( LPBYTE cmds, DWORD len ) { return ::SendCmd ( m_dh, cmds, len ); }
int SendData( LPBYTE data, DWORD len ) { return ::SendData( m_dh, data, len ); }
int SendEoi ( LPBYTE data, DWORD len ) { return ::SendEoi ( m_dh, data, len ); } //
// Interace/Device Control and Configuration
//
int Abort () { return ::Abort ( m_dh ); }
int Clear () { return ::Clear ( m_dh ); }
int ControlLine () { return ::ControlLine ( m_dh ); }
int Local () { return ::Local ( m_dh ); }
int Lol () { return ::Lol ( m_dh ); }
int MyListenAddr() { return ::MyListenAddr( m_dh ); }
int MyTalkAddr () { return ::MyTalkAddr ( m_dh ); }
int PassControl () { return ::PassControl ( m_dh ); }
int Remote () { return ::Remote ( m_dh ); }
int Reset () { return ::Reset ( m_dh ); }
int SPoll () { return ::SPoll ( m_dh ); }
int Trigger () { return ::Trigger ( m_dh ); }
int UnListen () { return ::UnListen ( m_dh ); }
int UnTalk () { return ::UnTalk ( m_dh ); }
int PPoll () { return ::PPoll ( m_dh ); }
int PPollDisable () { return ::PPollDisable ( m_dh ); }
int PPollUnconfig() { return ::PPollUnconfig( m_dh ); }
int PPollConfig ( BYTE ppresponse ) { return ::PPollConfig ( m_dh, ppresponse ); } int BusAddress( BYTE pad, BYTE sad ) { return ::BusAddress( m_dh, pad, sad ); }
int Listen ( BYTE pad, BYTE sad ) { return ::Listen ( m_dh, pad, sad ); }
int Talk ( BYTE pad, BYTE sad ) { return ::Talk ( m_dh, pad, sad ); } int CheckListener( BYTE pad, BYTE sad ) { return ::CheckListener( m_dh, pad, sad ); }
int FindListeners( BYTE pad, LPWORD listener, DWORD limit ) {
return ::FindListeners( m_dh, pad, listener, limit );
} int AutoRemote( BOOL flag ) { return ::AutoRemote( m_dh, flag ); }
int Hello ( LPSTR message ) { return ::Hello ( m_dh, message ); }
int Request( BYTE spstatus ) { return ::Request( m_dh, spstatus ); }
int Status ( IeeeStatusPT status ) { return ::Status ( m_dh, status ); } int Term( TermT *ts, DWORD termFlag ) { return ::Term( m_dh, ts, termFlag );}
int TermQuery( TermT *termP, int TermType ) { return ::TermQuery( m_dh, termP, TermType ); } int TimeOut( DWORD millisec ) { return ::TimeOut( m_dh, millisec );}
int TimeOutQuery( DWORD *millisec ) { return ::TimeOutQuery( m_dh, millisec ); }
//
// Asynchronous Transfer Control
//
LONG Buffered() { return ::Buffered( m_dh ); }
int Finish () { return ::Finish ( m_dh ); }
int Stop () { return ::Stop ( m_dh ); }
int Wait () { return ::Wait ( m_dh ); } int Resume( BOOL monitor ) { return ::Resume( m_dh, monitor ); }
//
// Event Notification
//
int Arm ( ArmCondT condition ) { return ::Arm ( m_dh, condition ); }
int Disarm( ArmCondT condition ) { return ::Disarm( m_dh, condition ); } int OnEvent ( HWND hWnd, OpaqueP lParam ) { return ::OnEvent ( m_dh, hWnd, lParam ); }
int OnEventVDM( EventFuncT func ) { return ::OnEventVDM( m_dh, func ); }
//
// Error Handling
//
int Error( BOOL display ) { return ::Error( m_dh, display ); }
ErrorCodeT GetError( LPSTR errText ) { return ::GetError( m_dh, errText );} //
// Digital I/O
//
int DigRead () { return ::DigRead ( m_dh ); }
int DigWrite( BYTE byDigData ) { return ::DigWrite( m_dh, byDigData ); } int DigSetup( BOOL bLowOut, BOOL bHighOut ) { return ::DigSetup( m_dh, bLowOut, bHighOut ); }
int DigArm ( BOOL bArm ) { return ::DigArm ( m_dh, bArm ); }
int DigArmSetup( BYTE byMatchValue ) { return ::DigArmSetup( m_dh, byMatchValue ); }
int OnDigEvent ( HWND hWnd, OpaqueP lParam ) { return ::OnDigEvent ( m_dh, hWnd, lParam ); }
int OnDigEventVDM( DigEventFuncT func, OpaqueP lParam ) { return ::OnDigEventVDM( m_dh, func, lParam ); }
}; //
// Class Wrapper for the TermT structure.
//
// This class encapsulates a TermT strucure. to be defined inside a function
// argument list. In some cases it may be more convenient than defining and
// initializing a TermT structure prior to calling the function. The following
// examples show three different methods of calling the Term() function, two
// using a CTerm object.
//
// 1) Define and initialize TermT structure prior to the call.
// TermT term;
// term.nChar = 2;
// term.termChar[0] = 13;
// term.termChar[1] = 10;
// term.EOI = TRUE;
// Term( dh, &term, TERMIN );
//
// 2) Define and initialize a CTerm object prior to the call.
// CTerm cterm( 2, 13, 10, TRUE );
// Term( dh, cterm, TERMIN );
//
// 3) Use a temporary CTerm object as an argument to the function.
// Term( dh, CTerm( 2, 13, 10, TRUE ), TERMIN );
//
class CTerm
{
public: // A terminator structure as declared in IOTIEEE.H
TermT term; // This constructor initializes the internal TermT structure. Every
// argument is given a default value.
CTerm( int nTerms = 0, BYTE byTermA = 0, BYTE byTermB = 0,
BOOL bEoi = TRUE, BOOL bEightBits = TRUE )
{
term.nChar = nTerms;
term.termChar[0] = byTermA;
term.termChar[1] = byTermB;
term.EOI = bEoi;
term.EightBits = bEightBits;
} // This allows a CTerm object to be used wherever a TermPT is expected.
operator TermPT () { return &term; }
}; // NN NN OOO TTTTTT EEEEEEE SSSSS
// NNN NN OO OO TTTTTT EE EE SS SS
// NNNN NN OO OO T TT T EE E SS SS
// NNNNNNN OO OO TT EE E SS
// NN NNNN OO OO TT EEEE SSS
// NN NNN OO OO TT EE E SS
// NN NN OO OO TT EE E SS SS
// NN NN OO OO TT EE EE SS SS
// NN NN OOO TTTT EEEEEEE SSSSS // It is also possible to use shortened versions of the member functions
// Enter and Output because several of the arguments have default values.
// Here are some examples that are similar to the macros provided by the
// "C"-style header:
/*
CIeee488 dev( "DeviceOne" );
char data[256];
dev.Enter( data, sizeof data ); // like macro: Enter
dev.Enter( data, 10 ); // like macro: EnterN
dev.Enter( data, sizeof data, FALSE ); // like macro: EnterMore
dev.Enter( data, 10 , FALSE ); // like macro: EnterNMore
strcpy( data, "e?x" );
dev.Output( data ); // like macro: Output
dev.Output( data, 10 , FALSE, TRUE ); // like macro: OutputN
dev.Output( data, strlen( data ), TRUE , FALSE ); // like macro: OutputMore
dev.Output( data, 10 , FALSE, FALSE ); // like macro: OutputNMore
*/ // The list-oriented functions are not encapsulated by this class.
//
// int ClearList ( DevHandlePT dhList );
// int LocalList ( DevHandlePT dhList );
// int RemoteList ( DevHandlePT dhList );
// int PPollDisableList( DevHandlePT dhList );
// int TriggerList ( DevHandlePT dhList );
// int SPollList ( DevHandlePT dhList, LPBYTE result, BYTE flag );
// ErrorCodeT GetErrorList( DevHandlePT dhList, LPSTR errText, DevHandlePT errHandle );
//
// To use them, initialize a device handle array by accessing the private m_dh
// members through the automatic type-conversion operators as shown below.
/*
CIeee488 one( "DeviceOne" );
CIeee488 two( "DeviceTwo" );
CIeee488 thr( "DeviceThree" ); DevHandleT list[] = { one, two, thr }; ClearList( list );
*/ 看的懂得人可以幫忙一下嗎