-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPiCW_CheckPort.py
More file actions
executable file
·44 lines (37 loc) · 997 Bytes
/
PiCW_CheckPort.py
File metadata and controls
executable file
·44 lines (37 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python3
# PiCW_CheckPort.py
# - a port monitoring daemon for TX control
import time
import sys
import InputOutputPort as port
import KeyingControl as key
import StraightKeyer as stk
# disable responses for all input ports
#
port.bind(port.In_A, stk.null_action)
port.bind(port.In_B, stk.null_action)
port.bind(port.In_C, stk.null_action)
# monitoring TX control port
# for maxcount*interval seconds
#
# If TX control port being
# activated whole continuously,
# deactivate the port.
interval=1
# sync to timeout of sendable_dots
maxcount=max(int(key.sendable_dots*key.dotlen*2/interval), 1)
count=0
while True:
for i in (range(maxcount)):
time.sleep(interval)
stat=port.check_port(port.Out_T)
if stat==1:
count += 1
if maxcount<=count:
key.space()
count=0
else:
count=0
sys.stdout.write(str(stat))
sys.stdout.flush()
print(' : {:2d}'.format(count))