#include "hardwaresetup.h" #include #include "sys/io.h" #include //#define BASEPORT 0xe050 /* lp1 */ //#define BASEPORT 0x378 #define BASEPORT 0xd000 HardwareSetup::HardwareSetup() { if (ioperm(BASEPORT, 3, 1)) { //perror("ioperm"); } shellBefore = false; deaBefore = false; this->stop = 0; } void HardwareSetup::setStop(){ this->stop = 1; } HardwareSetup::~HardwareSetup(){ /*if (ioperm(BASEPORT, 3, 0)) { //perror("ioperm"); }*/ std::cout << "Hardware beendet" << std::endl; } void HardwareSetup::run(){ int index; while(!this->stop){ usleep(500); if(getDea()){ if(!deaBefore){ index = 1; deaBefore = true; emit Dea(); } else{ index += 1; //Debug //std::cout << index << std::endl; } } else{ deaBefore = false; } if(getShell()){ if(!shellBefore){ shellBefore = true; emit Shell(); } } else{ shellBefore = false; } } } bool HardwareSetup::getShell(){ int zahl[8] = {0}; if(findBit(zahl, inb(BASEPORT + 1))[7] == 1){ return true; } return false; } bool HardwareSetup::getDea(){ int zahl[8] = {0}; if(findBit(zahl, inb(BASEPORT + 1))[6] == 0 ){ return true; } return false; } int* HardwareSetup::findBit(int *array, int zahl){ if(zahl >=128){ array[7] = 1; zahl -= 128; } if(zahl >=64){ array[6] = 1; zahl -= 64; } if(zahl >=32){ array[5] = 1; zahl -= 32; } if(zahl >=16){ array[4] = 1; zahl -= 16; } if(zahl >=8){ array[3] = 1; zahl -= 8; } if(zahl >=4){ array[2] = 1; zahl -= 4; } if(zahl >=2){ array[1] = 1; zahl -= 2; } if(zahl >=1){ array[0] = 1; zahl -= 1; } return array; }