Exemplo n.º 1
0
ParallelPort::ParallelPort(QSettings &s) : settings(s)
{
    port        = defaultParallelPort.toULong();
    initialized = false;
    initSuccess = false;
    stereoPinStatus=false;
    hLib        = LoadLibraryA("inpout32.dll");

    if (hLib == NULL) {
        QString tmp = "LoadLibrary inpout32.dll failed";
        emit(parallelPortError(tmp));
        return;
    }

    // get the address of the function

    inp32fp = (inpfuncPtr) GetProcAddress(hLib, "Inp32");
    if (inp32fp == NULL) {
        QString tmp = "GetProcAddress for Inp32 Failed.";
        emit(parallelPortError(tmp));
        return;
    }

    oup32fp = (oupfuncPtr) GetProcAddress(hLib, "Out32");
    if (oup32fp == NULL) {
        QString tmp = "GetProcAddress for Oup32 Failed.";
        emit(parallelPortError(tmp));
        return;
    }
    initSuccess = true;
}
Exemplo n.º 2
0
ParallelPort::~ParallelPort()
{
    QString port= settings.value(s_radios_pport,defaultParallelPort).toString();
    if (parallelFD != -1) {
        int err = ioctl(parallelFD, PPRELEASE);
        if (err == -1) {
            QString tmp = "Error releasing " + port;
            emit(parallelPortError(tmp));
            return;
        }
        err = close(parallelFD);
        if (err == -1) {
            QString tmp = "Error closing " +  port;
            emit(parallelPortError(tmp));
            return;
        }
    }
}
Exemplo n.º 3
0
/*!
   set a pin  p=(2:9) high
 */
void ParallelPort::PinHigh(const int p)
{
    if (!initialized | (p < 2) | (p > 9)) return;

    char data = 0;
    int  err  = ioctl(parallelFD, PPRDATA, &data); // read port data
    if (err == -1) {
        QString tmp = "ERROR: Can't read from " +  settings.value(s_radios_pport,defaultParallelPort).toString();
        emit(parallelPortError(tmp));
        return;
    }
    char b = 1 << (p - 2);
    if (!(data & b)) {
        data += b;
        err   = ioctl(parallelFD, PPWDATA, &data);
        if (err == -1) {
            QString tmp = "ERROR: Can't write to " +  settings.value(s_radios_pport,defaultParallelPort).toString();
            emit(parallelPortError(tmp));
        }
    }
}
Exemplo n.º 4
0
void ParallelPort::initialize()
{
    bool ok=false;
	QString pstring=settings.value(s_radios_pport,defaultParallelPort).toString();
    port= pstring.toULong(&ok,0);
    if (!ok) {
        port = defaultParallelPort.toULong();
        QString tmp = "port <" + pstring + "> invalid, using port "+defaultParallelPort;
        emit(parallelPortError(tmp));
    }
	initialized=true;
}
Exemplo n.º 5
0
/*!
   Note that user must be in lp group to access /dev/parport

   Will attempt to drop privleges after getting port access.
 */
void ParallelPort::initialize()
{
    QString port= settings.value(s_radios_pport,defaultParallelPort).toString();
    if (parallelFD != -1) {
        int err = ioctl(parallelFD, PPRELEASE);
        if (err == -1) {
            QString tmp = "Error releasing " + port;
            emit(parallelPortError(tmp));
            return;
        }
        err = close(parallelFD);
        if (err == -1) {
            QString tmp = "Error closing " + port;
            emit(parallelPortError(tmp));
            return;
        }
    }
    parallelFD = open(port.toAscii().data(), O_RDWR);
    if (parallelFD == -1) {
        QString tmp = "Can't open " + port;
        emit(parallelPortError(tmp));
        return;
    }
    int err = ioctl(parallelFD, PPCLAIM);
    if (err == -1) {
        QString tmp = "ERROR: Can't claim " + port;
        emit(parallelPortError(tmp));
        return;
    }
    int mode = IEEE1284_MODE_COMPAT;
    if (ioctl(parallelFD, PPNEGOT, &mode)) {
        QString tmp = "ERROR: can't set " + port + " to IEEE1284 compat mode";
        emit(parallelPortError(tmp));
        return;
    }

    initialized = true;
}