Skip to content

Commit 4608131

Browse files
committed
Now bridge.py is able to tell his version on startup
1 parent b5df2c5 commit 4608131

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

bridge/packet.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,20 @@
2525
##
2626
## Copyright 2013 Arduino LLC (http://www.arduino.cc/)
2727

28-
import os, tty, termios, select
28+
import tty, termios, select
2929
from contextlib import contextmanager
3030
from sys import stdin, stdout
3131
from subprocess import call
3232

3333
@contextmanager
3434
def cbreak():
35-
if hasattr(stdin, "fileno") and os.isatty(stdin.fileno()):
36-
old_attrs = termios.tcgetattr(stdin)
37-
tty.setcbreak(stdin)
38-
tty.setraw(stdin)
35+
old_attrs = termios.tcgetattr(stdin)
36+
tty.setcbreak(stdin)
37+
tty.setraw(stdin)
3938
try:
4039
yield
4140
finally:
42-
if hasattr(stdin, "fileno") and os.isatty(stdin.fileno()):
43-
termios.tcsetattr(stdin, termios.TCSADRAIN, old_attrs)
41+
termios.tcsetattr(stdin, termios.TCSADRAIN, old_attrs)
4442

4543
class CRC:
4644
def __init__(self, file):
@@ -94,7 +92,7 @@ def run(self, data):
9492
call(['/usr/bin/blink-start', '100'])
9593
return chr(2)
9694
call(['/usr/bin/blink-stop'])
97-
return chr(0)
95+
return chr(0) + '101' # send the actual bridge version
9896

9997
class PacketReader:
10098
def __init__(self, processor):

0 commit comments

Comments
 (0)