Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/nto/bak2/train_speed.cpp

Go to the documentation of this file.
00001 #include <j2k/Fred/Standard.hpp>
00002 #include <iostream.h>
00003 #include <sys/types.h>
00004 #include <sys/stat.h>
00005 #include <fcntl.h>
00006 #include <j2k/nto/Basic_PThread.cpp>
00007 #include <j2k/nto/conio.h>
00008 
00009 #include "speed.cpp"
00010 
00011 class Fred : public Basic_PThread
00012 {
00013   int fd;
00014   char buf[ 80 ];
00015 
00016 public:
00017 
00018   Fred() : Basic_PThread() 
00019   { 
00020     fd = open( "/dev/ser1", O_RDWR );
00021     memset( buf, 0, 80 );
00022   }
00023 
00024   virtual ~Fred()
00025   {
00026     close( fd );
00027   }
00028 
00029   void w( char* b, size_t sz )
00030   {
00031     write( fd, b, sz );
00032   }
00033 
00034   void speed( int spd )
00035   {
00036     char* s = setSpeed( 3, spd, TRUE, TRUE );
00037     write( fd, s, strlen( s ) );
00038   }
00039   
00040   virtual void run()
00041   {
00042     printf( "RUN" );
00043     fflush( stdout );
00044     for(;;)
00045     {
00046     int e = read( fd, buf, 1 );
00047     printf( "[%s]", buf );
00048     fflush( stdout );
00049     }
00050   }
00051 
00052 };
00053 
00054 
00055 int main()
00056 {
00057   Fred f;
00058   f.start();
00059   f.join();
00060 
00061   char c = 0; //[2] = { 0,0 };
00062 
00063 
00064   for(;;)
00065   {
00066     fflush( stdin  );
00067     fflush( stdout );
00068     c = getche();
00069     fflush( stdin  );
00070     fflush( stdout );
00071  
00072     if ( c == '.' )
00073       c = 13;
00074 
00075     if ( c >= '0' && c <= '9' )
00076     {
00077       int spd = c - '0';
00078       printf( "%d", spd );
00079       f.speed( spd );
00080     } else if ( c >= 'a' && c <= 'z' )
00081     {
00082       int spd = c - 'a' + 10;
00083       printf( "%d", spd );
00084       f.speed( spd );
00085     } else {
00086     f.w( &c, 1 );
00087     } 
00088   }  
00089   
00090   return 0;
00091 }

Generated on Sun Oct 14 18:46:38 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001