コード例 #1
0
ファイル: ftpclient.cpp プロジェクト: korhore/Wall-E
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);

}
コード例 #2
0
ファイル: UsbWidget.cpp プロジェクト: elcerdo/avr
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();
}
コード例 #3
0
ファイル: UsbWidget.cpp プロジェクト: elcerdo/avr
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);
}
コード例 #4
0
ファイル: DualshockPad.cpp プロジェクト: AxioDL/boo
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
}
コード例 #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");
}
コード例 #6
0
ファイル: UsbWidget.cpp プロジェクト: elcerdo/avr
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;
}
コード例 #7
0
ファイル: UsbWidget.cpp プロジェクト: elcerdo/avr
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();
}
コード例 #8
0
ファイル: UsbWidget.cpp プロジェクト: elcerdo/avr
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();
}
コード例 #9
0
ファイル: ftpclient.cpp プロジェクト: korhore/Wall-E
void FtpClient::handleProxyAuthenticationRequired ( const QNetworkProxy & proxy, QAuthenticator * authenticator )
{
    qDebug() << "FtpClient:: " << port << " handleProxyAuthenticationRequired";
    emit deviceStateChanged(DeviceManager::ErrorState);
    emit deviceError(QAbstractSocket::ProxyAuthenticationRequiredError);
};
コード例 #10
0
ファイル: ftpclient.cpp プロジェクト: korhore/Wall-E
void FtpClient::handleHostFound()
{
    qDebug() << "FtpClient:: " << port << " handleHostFound";
    emit deviceStateChanged(DeviceManager::ErrorState);
    emit deviceError(QAbstractSocket::HostNotFoundError);
};