Twisted Serialport and Disappearing Serial Port Devices

I use twisted.internet.serialport so that my program is constantly connected to the device on the serial port.

Unfortunately, my serial port is just a USB device, which means that it can be turned off or reset the OS at any time (port 2 is disabled by the hub (EMI?), Re-enabled ...). I see that pyserial has been supporting this for several weeks and is throwing a SerialException.

What I would like to do is try to connect to a serial port that just disappears every few seconds.

So, is there a way, how can I say that I apologized to notify me of the disconnection? Or should I go ahead and write a thread wrapper for pyserial?

thank

+3
source share
2 answers

http://twistedmatrix.com/trac/ticket/3690 may be related.

The ticket appears to be locked with proper Windows support. I'm not sure if this disconnect event will cause a lost twisted intercom detection code, but I would expect it (even without the new pyserial version).

You can probably try to link the branch associated with this ticket to make sure that it does what you want, at least. And if so, maybe you could help get the actual ticket permission (soon < )

+1
source

, - connectionLost() .

, :

class fixedSerialPort(SerialPort):
    def connectionLost(self, reason):
        SerialPort.connectionLost(self, reason)
        self.protocol.connectionLost(reason)

Twisted 10.1 ( ubuntu) 8.1 ( debian). . .

+1

Source: https://habr.com/ru/post/1764031/


All Articles