@@ -97,6 +97,21 @@ class Protocol(IntEnum):
9797 GSIDNA = 1
9898
9999
100+ _BAUD = [
101+ 1200 ,
102+ 2400 ,
103+ 4800 ,
104+ 9600 ,
105+ 19200 ,
106+ 38400 ,
107+ 56000 ,
108+ 57600 ,
109+ 115200 ,
110+ 230400 ,
111+ 921600
112+ ]
113+
114+
100115class CmdSuggester (Suggester ):
101116 PATH = re .compile (r"^(\w+(?:\.\w+)*)([\.\(]?)" )
102117
@@ -306,6 +321,13 @@ def compose(self) -> ComposeResult:
306321 allow_blank = False ,
307322 id = "select_protocol"
308323 )
324+ yield Label ("Baud" )
325+ yield Select (
326+ [(str (b ), b ) for b in _BAUD ],
327+ allow_blank = False ,
328+ value = 9600 ,
329+ id = "select_baud"
330+ )
309331 with HorizontalGroup (id = "hg_buttons" ):
310332 yield Button ("Test Connection" , id = "btn_test_com" )
311333 yield Button (
@@ -417,9 +439,10 @@ def btn_connect_pressed(self, event: Button.Pressed) -> None:
417439 )
418440 self .app .bell ()
419441 return
442+ baud = cast (int , self .query_one ("#select_baud" , Select ).value )
420443 try :
421444 log = get_app_logger (self , port .value )
422- com = open_serial (port .value )
445+ com = open_serial (port .value , speed = baud )
423446 match self .query_one ("#select_protocol" , Select ).value :
424447 case Protocol .GEOCOM :
425448 self .protocol = GeoCom (com , log )
@@ -433,6 +456,7 @@ def btn_connect_pressed(self, event: Button.Pressed) -> None:
433456 event .button .disabled = True
434457 self .query_one ("#edit_com" , Input ).disabled = True
435458 self .query_one ("#select_protocol" , Select ).disabled = True
459+ self .query_one ("#select_baud" , Select ).disabled = True
436460 self .query_one ("#tab_cmd" , TabPane ).disabled = False
437461
438462 self .notify ("Connection successful." , title = "Success" )
@@ -462,6 +486,7 @@ def btn_disconnect_pressed(self, event: Button.Pressed) -> None:
462486 event .button .disabled = True
463487 self .query_one ("#edit_com" , Input ).disabled = False
464488 self .query_one ("#select_protocol" , Select ).disabled = False
489+ self .query_one ("#select_baud" , Select ).disabled = False
465490 self .query_one ("#tab_cmd" , TabPane ).disabled = True
466491 self .sub_title = ""
467492 except Exception as e :
0 commit comments