summaryrefslogtreecommitdiff
path: root/documentation/shortintro.rst
diff options
context:
space:
mode:
authorChris Liechti <cliechti@gmx.net>2015-12-17 19:43:59 +0100
committerChris Liechti <cliechti@gmx.net>2015-12-17 19:43:59 +0100
commit9ad044afd3ba15749178adb27af2591f2bb1c054 (patch)
tree9af7ec4ae712300b70259a43201d199560a29586 /documentation/shortintro.rst
parent3e02f7052747521a21723a618dccf303065da732 (diff)
downloadpyserial-git-9ad044afd3ba15749178adb27af2591f2bb1c054.tar.gz
doc update
Diffstat (limited to 'documentation/shortintro.rst')
-rw-r--r--documentation/shortintro.rst11
1 files changed, 10 insertions, 1 deletions
diff --git a/documentation/shortintro.rst b/documentation/shortintro.rst
index e08f737..4cbdda7 100644
--- a/documentation/shortintro.rst
+++ b/documentation/shortintro.rst
@@ -10,7 +10,7 @@ Open port at "9600,8,N,1", no timeout::
>>> import serial
>>> ser = serial.Serial('/dev/ttyUSB0') # open serial port
>>> print(ser.name) # check which port was really used
- >>> ser.write(b"hello") # write a string
+ >>> ser.write(b'hello') # write a string
>>> ser.close() # close port
Open named port at "19200,8,N,1", 1s timeout::
@@ -44,6 +44,15 @@ Get a Serial instance and configure/open it later::
>>> ser.is_open
False
+Also supported with context manager::
+
+ serial.Serial() as ser:
+ ser.baudrate = 19200
+ ser.port = 'COM1'
+ ser.open()
+ ser.write(b'hello')
+
+
Readline
========
Be carefully when using :meth:`readline`. Do specify a timeout when opening the