[PyQt] QAbstractSocket usage problem, what am I doing wrong?
Jens Jorgensen
jbj1 at ultraemail.net
Sun May 17 09:42:12 BST 2009
Jens Jorgensen wrote:
> Hello,
>
> I have a small application that provides some glue between Skype and an
> external usb "phone" device. I originally wrote this application under
> gtk and am porting it to kde/qt. Everything worked fine under gtk so
> there's no problem with the non-framework-related logic. The phone has
> buttons on it that I read from a hidraw device (character device). It
> looks like the right way to get read events for this is to use
> QAbstractSocket:
>
> def open_phone_hid(self, path) :
> if path == tjphone_hal_udi :
> iobj =
> dbus.Interface(system_bus.get_object("org.freedesktop.Hal",
> tjphone_hal_udi), 'org.freedesktop.Hal.Device')
> self.fd =
> os.open(str(iobj.GetProperty('linux.device_file')), os.O_RDONLY)
> self.src_id =
> QtNetwork.QAbstractSocket(QtNetwork.QAbstractSocket.UnknownSocketType,
> None)#gobject.io_add_watch(self.fd, gobject.IO_IN, self.tj_phone_input)
> self.src_id.setSocketDescriptor(self.fd)
> self.connect(self.src_id, QtCore.SIGNAL('readyRead()'),
> self.tj_phone_input)
> self.numbers = ''
> self.printmsg('TJPhone on')
> return True
>
> So the above code executes fine, but when I press a button on the phone
> the console I am running the script from fills with this message,
> repeating endlessly:
>
> QNativeSocketEngine::hasPendingDatagrams() was called by a socket other
> than QAbstractSocket::UdpSocket
>
> My function tj_phone_input is never called. Is there perhaps a problem
> in the QAbstractSocket code itself or am I doing something wrong?
>
>
I hate when I do this, but after sending this email I realized there
must be some lower-level mechanism available than QAbstractSocket. So
unfortunately /after/ sending the above email I dug it up:
QSocketNotifier. I've got that working and everything is working
swimmingly now. Hopefully this email will serve as a cautionary tale to
someone googling about the same kind of thing in future.
--
Jens B. Jorgensen
jbj1 at ultraemail.net
More information about the PyQt
mailing list