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
commit4a124e150b3451b84efb8966951ee66bf8cf4e5c (patch)
treec19587bef718e2113fccfe6f49848cdc1eeac5a2
parent391d94f10317b267a342228ff9a422240f91dfe9 (diff)
downloadpyserial-4a124e150b3451b84efb8966951ee66bf8cf4e5c.tar.gz
add .fileno() for easy use with select (platform dependent code)
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk@129 f19166aa-fa4f-0410-85c2-fa1106f25c8a
-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,