summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2005-01-15 20:32:51 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2005-01-15 20:32:51 +0000
commit8753bbc34ea822b447a55d55a8710e0f5b0d5c47 (patch)
treec19587bef718e2113fccfe6f49848cdc1eeac5a2
parent5d4d0bdd01317bd158329afab39439fea89bdc35 (diff)
downloadpyserial-git-8753bbc34ea822b447a55d55a8710e0f5b0d5c47.tar.gz
add .fileno() for easy use with select (platform dependent code)
-rw-r--r--pyserial/serial/serialposix.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/pyserial/serial/serialposix.py b/pyserial/serial/serialposix.py
index 22a0336..d3bbc26 100644
--- a/pyserial/serial/serialposix.py
+++ b/pyserial/serial/serialposix.py
@@ -13,7 +13,7 @@
import sys, os, fcntl, termios, struct, select
from serialutil import *
-VERSION = "$Revision: 1.24 $".split()[1] #extract CVS version
+VERSION = "$Revision: 1.25 $".split()[1] #extract CVS version
#Do check the Python version as some constants have moved.
if (sys.hexversion < 0x020100f0):
@@ -374,6 +374,11 @@ class Serial(SerialBase):
raise portNotOpenError
fcntl.fcntl(self.fd, FCNTL.F_SETFL, FCNTL.O_NONBLOCK)
+ def fileno(self):
+ """For easier of the serial port instance with select.
+ WARNING: this function is not portable to different platforms!"""
+ if self.fd is None: raise portNotOpenError
+ return self.fd
if __name__ == '__main__':
s = Serial(0,