2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-21 17:11:58 +00:00

Add carrier detect to autocons sample

For genesis, not necessarily relevant, but may be
very relevant for OS behaviors in other contexts.
This commit is contained in:
Jarrod Johnson 2019-03-14 09:33:58 -04:00
parent 163b29a07c
commit f1e83d938b

View File

@ -1,3 +1,4 @@
import fcntl
import os
import struct
import termios
@ -46,6 +47,8 @@ def do_serial_config():
currattr = termios.tcgetattr(ttyf)
currattr[4:6] = [0, termiobaud[retval['speed']]]
termios.tcsetattr(ttyf, termios.TCSANOW, currattr)
retval['connected'] = bool(struct.unpack('<I', fcntl.ioctl(
ttyf, termios.TIOCMGET, '\x00\x00\x00\x00'))[0] & termios.TIOCM_CAR)
return retval