Ejemplo n.º 1
0
void FtpClient::handleError(QAbstractSocket::SocketError socketError)
{
    qDebug() << "FtpClient:: " << port << " handleError()";
    switch (socketError) {
    case QAbstractSocket::RemoteHostClosedError:
        qDebug() << tr("RemoteHostClosedError");
        break;
    case QAbstractSocket::HostNotFoundError:
        qDebug() << tr("The host was not found. Please check the "
                                    "host name and port settings.");
        break;
    case QAbstractSocket::ConnectionRefusedError:
       qDebug() << tr("The connection was refused by the peer. "
                                    "Make sure the Wall-E server is running, "
                                    "and check that the host name and port "
                                    "settings are correct.");
        break;
    case QAbstractSocket::NetworkError:
        qDebug() << tr("An error occurred with the network. "
                                     "Host unreachable.");
    default:
        qDebug() << tr("The following error occurred: %1 %2.")
                                 .arg(tcpSocket->errorString(), QString::number(socketError));
    }

    // emit error
    emit deviceStateChanged(DeviceManager::ErrorState);
    emit deviceError(socketError);

}
Ejemplo n.º 2
0
void UsbWidget::setLeds(const unsigned char *state) {
    Q_ASSERT( sizeof(state) == 8 );
    if ( handle == NULL or not pool_timer->isActive() ) return;

    int cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_LEDS_SET_STATUS, 0, 0, reinterpret_cast<char*>(const_cast<unsigned char*>(state)), 8, 5000);
    if ( cnt < 0 ) deviceError();
}
Ejemplo n.º 3
0
void UsbWidget::setIntensity(int k) {
    if ( handle == NULL ) return;

    int cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_LEDS_SET_INTENSITY, k, 0, NULL, 0, 5000);
    if ( cnt < 0 ) deviceError();
    
    QSettings settings;
    settings.setValue("usb/intensity",k);
}
Ejemplo n.º 4
0
void DualshockPad::initialCycle() {
#if 0
    uint8_t setupCommand[5] = {0xF4, 0x42, 0x0c, 0x00, 0x00}; //Tells controller to start sending changes on in pipe
    if (!sendHIDReport(setupCommand, 5, HIDReportType::Feature, 0xF4))
    {
        deviceError("Unable to send complete packet! Request size %x\n", sizeof(setupCommand));
        return;
    }
    uint8_t btAddr[8];
    receiveHIDReport(btAddr, sizeof(btAddr), HIDReportType::Feature, 0xF5);
    for (int i = 0; i < 6; i++)
        m_btAddress[5 - i] = btAddr[i + 2]; // Copy into buffer reversed, so it is LSB first
#endif
}
Ejemplo n.º 5
0
UHandler::UHandler (QWidget *parent) : QObject (parent)
{
	// initializing public variables	
	ccof = 0.02;	// AD conversion coefficient.
//	cres = 0;	// AD conversion result variable
	readbuf = 0;	// buffer variable for the incoming data

	char boardID[] = "USBModuleV01";	// hardware ID
	char devprID[] = "www.bgb.netii.net";  // developer's ID

	usb_init ();
	if (!openDevice (&handle, USBDEV_SHARED_VENDOR, devprID, USBDEV_SHARED_PRODUCT, boardID)){
		emit deviceError();
	}
//	fprintf (stderr, "UHandler: constructor did all successful.\n");
}
Ejemplo n.º 6
0
void UsbWidget::update() {
    if ( handle == NULL ) return;

    unsigned char *buffer = new unsigned char [8];
    int cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, CUSTOM_RQ_KEY_GET_STATUS, 0, 0, reinterpret_cast<char*>(buffer), sizeof(buffer), 5000);
    if ( cnt < 0 ) deviceError();

    for (int k=0; k<8; k++) {
        if ( old_buffer[k] != buffer[k]) {
            for (int l=0; l<8; l++) {
                if ( (old_buffer[k] & (1<<l)) != (buffer[k] & (1<<l)) ) {
                    emit padPressed(k,l,(buffer[k] & (1<<l)) != 0);
                }
            }
        }
    }

    delete [] old_buffer;
    old_buffer = buffer;
}
Ejemplo n.º 7
0
void UsbWidget::setLed(bool on) {
    if ( handle == NULL ) return;

    int cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_LED_SET_STATUS, on, 0, NULL, 0, 5000);
    if ( cnt < 0 ) deviceError();
}
Ejemplo n.º 8
0
void UsbWidget::setLayer(int k) {
    if ( handle == NULL ) return;

    int cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_LEDS_SET_LAYER, k, 0, NULL, 0, 5000);
    if ( cnt < 0 ) deviceError();
}
Ejemplo n.º 9
0
void FtpClient::handleProxyAuthenticationRequired ( const QNetworkProxy & proxy, QAuthenticator * authenticator )
{
    qDebug() << "FtpClient:: " << port << " handleProxyAuthenticationRequired";
    emit deviceStateChanged(DeviceManager::ErrorState);
    emit deviceError(QAbstractSocket::ProxyAuthenticationRequiredError);
};
Ejemplo n.º 10
0
void FtpClient::handleHostFound()
{
    qDebug() << "FtpClient:: " << port << " handleHostFound";
    emit deviceStateChanged(DeviceManager::ErrorState);
    emit deviceError(QAbstractSocket::HostNotFoundError);
};