Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

parallel.cpp

Go to the documentation of this file.
00001 // PTF - Psychological Test Framework 00002 // http://ptf.sourceforge.net 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU Library General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 #include <ptf/environment/parallel.hpp> 00019 #include <ptf/core/timeinterval.hpp> 00020 #include <sys/io.h> 00021 #include <stdexcept> 00022 00026 Parallel::Parallel() { 00027 // nothing to do here 00028 } 00029 00033 Parallel::~Parallel() { 00034 // nothing to do here 00035 } 00036 00046 void Parallel::output(short pattern, timespec wait) { 00047 // i386 code path ---------------------------------------------------------- 00048 #ifdef __i386__ 00049 // get access to the ports 00050 if (ioperm(0x378, 3, 1)) { 00051 // something went wrong 00052 throw std::runtime_error("Error setting permissions on parallel port."); 00053 } 00054 // set the data signals (D0-7) of the port 00055 outb(pattern, 0x378); 00056 // wait 00057 TimeInterval duration; 00058 duration.measureA(); 00059 duration.measureB(); 00060 while (duration.compareDifference(wait) > 0) { 00061 duration.measureB(); 00062 } 00063 // set the data signals (D0-7) of the port to n0 00064 outb(0, 0x378); 00065 #endif 00066 // i386 code path ends ------------------------------------------------------- 00067 }

Generated on Fri Dec 17 14:54:23 2004 for Psychological Test Framework by doxygen 1.3.8