-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ecbba3
commit 5355796
Showing
10 changed files
with
155 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*out | ||
*logs | ||
*actions | ||
*notifications | ||
*tools | ||
plugins | ||
user_trunk.yaml | ||
user.yaml | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[settings] | ||
profile=black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Prettier friendly markdownlint config (all formatting rules disabled) | ||
extends: markdownlint/style/prettier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
rules: | ||
quoted-strings: | ||
required: only-when-needed | ||
extra-allowed: ["{|}"] | ||
key-duplicates: {} | ||
octal-values: | ||
forbid-implicit-octal: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Generic, formatter-friendly config. | ||
select = ["B", "D3", "E", "F"] | ||
|
||
# Never enforce `E501` (line length violations). This should be handled by formatters. | ||
ignore = ["E501"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This file controls the behavior of Trunk: https://docs.trunk.io/cli | ||
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml | ||
version: 0.1 | ||
cli: | ||
version: 1.21.0 | ||
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) | ||
plugins: | ||
sources: | ||
- id: trunk | ||
ref: v1.4.5 | ||
uri: https://github.com/trunk-io/plugins | ||
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes) | ||
runtimes: | ||
enabled: | ||
- node@18.12.1 | ||
- python@3.10.8 | ||
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) | ||
lint: | ||
enabled: | ||
- actionlint@1.6.27 | ||
- bandit@1.7.8 | ||
- black@24.3.0 | ||
- checkov@3.2.60 | ||
- git-diff-check | ||
- isort@5.13.2 | ||
- markdownlint@0.39.0 | ||
- osv-scanner@1.7.0 | ||
- prettier@3.2.5 | ||
- ruff@0.3.5 | ||
- trivy@0.50.1 | ||
- trufflehog@3.71.0 | ||
- yamllint@1.35.1 | ||
actions: | ||
enabled: | ||
- trunk-announce | ||
- trunk-check-pre-push | ||
- trunk-fmt-pre-commit | ||
- trunk-upgrade-available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
class CWMessageSender: | ||
def __init__(self, radio_controller): | ||
self.radio_controller = radio_controller | ||
|
||
def send_cw_message(self, message): | ||
self.radio_controller.send_command(f'KYR1;TX2;MN080;{message};MN255;KYR0;') | ||
class CWMessageSender: | ||
|
||
def __init__(self, radio_controller): | ||
self.radio_controller = radio_controller | ||
|
||
def send_cw_message(self, message): | ||
self.radio_controller.send_command(f"KYR1;TX2;MN080;{message};MN255;KYR0;") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
from cw_message_sender import CWMessageSender | ||
from radio_controller import RadioFactory | ||
|
||
class CWMessageSenderFactory: | ||
@staticmethod | ||
def create_cw_message_senders(): | ||
available_radios = RadioFactory.detect_radios() | ||
return [CWMessageSender(RadioFactory.create_radio(port)) for port in available_radios] | ||
from cw_message_sender import CWMessageSender | ||
from radio_controller import RadioFactory | ||
|
||
|
||
class CWMessageSenderFactory: | ||
|
||
@staticmethod | ||
def create_cw_message_senders(): | ||
available_radios = RadioFactory.detect_radios() | ||
return [ | ||
CWMessageSender(RadioFactory.create_radio(port)) | ||
for port in available_radios | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
from cw_message_sender_factory import CWMessageSenderFactory | ||
|
||
if __name__ == "__main__": | ||
cw_senders = CWMessageSenderFactory.create_cw_message_senders() | ||
|
||
if cw_senders: | ||
try: | ||
while True: | ||
message = input("Enter CW message to send (or type 'exit' to quit): ") | ||
if message.lower() == 'exit': | ||
break | ||
|
||
for cw_sender in cw_senders: | ||
cw_sender.send_cw_message(message) | ||
|
||
# Read CW signals | ||
for cw_sender in cw_senders: | ||
cw_signal = cw_sender.radio_controller.read_cw_signal() | ||
print("Received CW signal from", cw_sender.radio_controller.port, ":", cw_signal) | ||
|
||
except KeyboardInterrupt: | ||
pass | ||
finally: | ||
for cw_sender in cw_senders: | ||
cw_sender.radio_controller.close() | ||
else: | ||
print("No Icom radios detected.") | ||
from cw_message_sender_factory import CWMessageSenderFactory | ||
|
||
if __name__ == "__main__": | ||
cw_senders = CWMessageSenderFactory.create_cw_message_senders() | ||
|
||
if cw_senders: | ||
try: | ||
while True: | ||
message = input("Enter CW message to send (or type 'exit' to quit): ") | ||
if message.lower() == "exit": | ||
break | ||
|
||
for cw_sender in cw_senders: | ||
cw_sender.send_cw_message(message) | ||
|
||
# Read CW signals | ||
for cw_sender in cw_senders: | ||
cw_signal = cw_sender.radio_controller.read_cw_signal() | ||
print( | ||
"Received CW signal from", | ||
cw_sender.radio_controller.port, | ||
":", | ||
cw_signal, | ||
) | ||
|
||
except KeyboardInterrupt: | ||
pass | ||
finally: | ||
for cw_sender in cw_senders: | ||
cw_sender.radio_controller.close() | ||
else: | ||
print("No Icom radios detected.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
import serial.tools.list_ports | ||
import time | ||
|
||
class RadioController: | ||
def __init__(self, port): | ||
self.port = port | ||
self.ser = serial.Serial(port, 9600, timeout=1) | ||
|
||
def send_command(self, command): | ||
self.ser.write(command.encode()) | ||
time.sleep(0.1) # Wait for the radio to process the command | ||
|
||
def read_cw_signal(self): | ||
# Implement logic to read CW signal from the radio | ||
# For example, read from serial port and interpret Morse code | ||
cw_signal = self.ser.readline().decode().strip() # Example assuming Morse code is sent over serial | ||
return cw_signal | ||
|
||
def close(self): | ||
self.ser.close() | ||
|
||
class RadioFactory: | ||
@staticmethod | ||
def detect_radios(): | ||
return [port.device for port in serial.tools.list_ports.comports() if 'Icom' in port.description] | ||
|
||
@staticmethod | ||
def create_radio(port): | ||
return RadioController(port) | ||
import time | ||
|
||
import serial.tools.list_ports | ||
|
||
|
||
class RadioController: | ||
|
||
def __init__(self, port): | ||
self.port = port | ||
self.ser = serial.Serial(port, 9600, timeout=1) | ||
|
||
def send_command(self, command): | ||
self.ser.write(command.encode()) | ||
time.sleep(0.1) # Wait for the radio to process the command | ||
|
||
def read_cw_signal(self): | ||
# Implement logic to read CW signal from the radio | ||
# For example, read from serial port and interpret Morse code | ||
cw_signal = ( | ||
self.ser.readline().decode().strip() | ||
) # Example assuming Morse code is sent over serial | ||
return cw_signal | ||
|
||
def close(self): | ||
self.ser.close() | ||
|
||
|
||
class RadioFactory: | ||
|
||
@staticmethod | ||
def detect_radios(): | ||
return [ | ||
port.device | ||
for port in serial.tools.list_ports.comports() | ||
if "Icom" in port.description | ||
] | ||
|
||
@staticmethod | ||
def create_radio(port): | ||
return RadioController(port) |