Home Page About Us
Links to other internet sites Contact Us

Source Code of "sampleRepeatFactor.cpp"

///////////////////////////////////////////////////////////////////////////////////////////////////////////// // // sampleRepeatFactor.cpp: main procedure of sample "RepeatFactor" // // copyright (c) 2002, 2003, 2004 by Paul R. ADAM // all rights reseved // read the "http://www.ParaPort.net/TermsOfUse.html" // // more information on "http://www.ParaPort.net" // ///////////////////////////////////////////////////////////////////////////////////////////////////////////// #include <stdio.h> #include "../include/ParaPortDll.h" #include "../include/ParaPortCycle.h" ///////////////////////////////////////////////////////////////////////////////////////////////////////////// int main( int argc, char *argv[ ] ) { printf( "test program \"RepeatFactor\"\n\n" ); ParaPortDll* Dll = ParaPortDll::getSingleton( ); HANDLE Handle; if ( !Dll->loadLibrary( "../../bin/ParaPort.dll" ) ) { printf( "Error: %d in Dll->loadLibrary( \"../../bin/ParaPort.dll\" );\n", GetLastError( ) ); ParaPortDll::deleteSingleton( ); getchar( ); return 1; } // open port char* PortName = argc == 2 ? argv[ 1 ] : "LPT1"; printf( "Port: %s\n", PortName ); Handle = Dll->openPort( PortName ); if ( Handle == INVALID_HANDLE_VALUE ) { printf( "Error: %d in Dll->openPort( \"%s\" );\n", GetLastError( ), PortName ); ParaPortDll::deleteSingleton( ); getchar( ); return 2; } ParaPortCycle Cycle[ 10 ]; Cycle[ 0 ].setData( 0x00 ); Cycle[ 0 ].clearInit( ); Cycle[ 0 ].clearLineFeed( ); Cycle[ 0 ].clearSelectIn( ); Cycle[ 0 ].clearStrobe( ); Cycle[ 1 ].setData( 0x01 ); Cycle[ 1 ].setInit( ); Cycle[ 2 ].setData( 0x02 ); Cycle[ 2 ].clearInit( ); Cycle[ 3 ].setData( 0x03 ); Cycle[ 3 ].setLineFeed( ); Cycle[ 3 ].setRepeatFactor( 1 ); Cycle[ 4 ].setData( 0x04 ); Cycle[ 4 ].clearLineFeed( ); Cycle[ 5 ].setData( 0x05 ); Cycle[ 5 ].setSelectIn( ); Cycle[ 5 ].setRepeatFactor( 2 ); Cycle[ 6 ].setData( 0x06 ); Cycle[ 6 ].clearSelectIn( ); Cycle[ 7 ].setData( 0x07 ); Cycle[ 7 ].setStrobe( ); Cycle[ 7 ].setRepeatFactor( 4 ); Cycle[ 8 ].setData( 0x08 ); Cycle[ 8 ].clearStrobe( ); Cycle[ 9 ].setData( 0x09 ); if ( !Dll->executeCycle( Handle, Cycle, sizeof( Cycle ) / sizeof( Cycle[ 0 ] ) ) ) printf( "Error: %d in Dll->executeCycle( );\n", GetLastError( ) ); for ( int i = 0; i < sizeof( Cycle ) / sizeof( Cycle[ 0 ] ); i ++ ) { printf( "i: %d\n", i ); if ( !Dll->executeCycle( Handle, Cycle + i, 1 ) ) printf( "Error: %d in Dll->executeCycle( );\n", GetLastError( ) ); getchar( ); } Dll->closePort( Handle ); ParaPortDll::deleteSingleton( ); getchar( ); return 0; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////

Copyright (c) 2002, 2003, 2004 by , v2.0, read the Terms of Use

 

Documentation about ParaPort
Source code of ParaPort
Licenses for ParaPort
Download Software
Customer Feedback

Last Site Update: 07.01.2004

Current Site Release: v2.0 b2

Current Software Release: v2.0 beta b3