Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

straight key locks on #23

Open
hcarter333 opened this issue Mar 5, 2024 · 1 comment
Open

straight key locks on #23

hcarter333 opened this issue Mar 5, 2024 · 1 comment

Comments

@hcarter333
Copy link
Owner

For more than one reason, the straight key on the rig has locked on several times causing me to have to lower the rig to reset the software. The first issue was that long dtimes were being erroneously sent. I placed a limiter in the client side script. That worked, but then, when a long message was sent, the key locked on again.

Change the host script so that long values greater than 2000 will be ignored.

Add positive feedback to skeyer.py to indicate that the message has been received and the WiFi channel to the Pico is available again. (I believe the pico might become unavailable.)

Add a command, light/unlocksk, that resets dtime and utime and expires all sleep commands.

ChatGPT, aka Penelope, suggests

import threading
import time

# Function to perform the task you want to interrupt
def task():
    print("Task started")
    time.sleep(10)  # Replace 10 with the duration of your sleep

# Function to stop the task
def stop_task():
    print("Task stopped")

# Start the task in a separate thread
thread = threading.Thread(target=task)
thread.start()

# Wait for a certain duration before stopping the task
time.sleep(5)  # Replace 5 with the duration after which you want to stop the task

# Check if the thread is still alive
if thread.is_alive():
    # If the thread is still running, interrupt it
    thread.join(timeout=0)
    if thread.is_alive():
        # If the thread is still alive after joining, it didn't respond to the interrupt
        print("Task could not be stopped")
    else:
        print("Task stopped successfully")
else:
    print("Task has already completed")

# If the task is not completed within the timeout, assume it's not responding to the interrupt

but cautions that

"This approach allows you to interrupt a long-running task, such as a sleep command, in Python. However, keep in mind that not all tasks can be interrupted this way, especially if they're performing blocking I/O operations or other non-interruptible tasks."

However, I don't thinkk this will be an issue, becasue we turn on the GPIO pin, and then sleep.

@hcarter333
Copy link
Owner Author

This solution might work, but goes back to threads which I'm trying, (perhaps incorrectly), to avoid on the Pico-W.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant