pySerial: how to check the current baud rate
<p>I have a device (<a href="http://www.robotshop.com/media/files/pdf/datasheet-sen-11792.pdf" rel="nofollow">GT511C3 fingerprint scanner</a>) that I am connecting to Raspberry Pi and programming it using <a href="http://pyserial.readthedocs.io/en/stable/index.html" rel="nofollow">Python Serial module</a>. The GT511 device has a default baud rate of 9600, and there is capability of changing the it. Once you change the GT511 baudrate, it keeps this setting until next restart.</p>

<p>The question is if there is a way for me to check the current baud rate of the connected device (in case the device was already programmed, and connected by a different host). I know it is possible to do it using <code>stty</code>:</p>

<pre><code>$&gt; stty &lt; /dev/ttyAMA0
speed 57600 bud; line = 0
...
</code></pre>

<p>Is there a way to do it using Python serial or any other module, or do I have to write an iterative checking procedure to find it out?</p>

<p><strong>UPDATE 1:</strong>
Current solution I use to find the accepted baud rate:</p>

<pre><code>ser = serial.Serial('/dev/ttyAMA0')
ser.timeout = 0.5
for baudrate in ser.BAUDRATES:
    if 9600 &lt;= baudrate &lt;= 115200:
        ser.baudrate = baudrate
        ser.write(packet)
        resp = ser.read()
        if resp != '':
            break
if ser.baudrate &gt; 115200:
    raise RuntimeError("Couldn't find appropriate baud rate!")
</code></pre>

<p><strong>UPDATE 2:</strong>
Please, stop suggesting <code>serial.baudrate</code> - this is <strong>NOT</strong> what I am asking.</p>