¿ªÔÆÌåÓý

Re: Implement a uBITX Memory Manager Program


 

First, thank you for suggesting a good solution.

I used arduino for the first time. Looking at the original code, most of them were implemented as polling.
As you all know, interrupts can have a small impact on the main thread. I could not use it without knowing the exact structure of the interruption of Arduino.

So I solved the problematic parts of the original source polling method in the same way as JACK mentioned above.
Like the RTOS, the delay function seems to be blocked in (delay)called thread, but, it handles the work of another thread.
In the RTOS, when one thread stopped progressing by mutex or semaphore, I got a hint from another thread that without being affected. It seemed to be able to solve the problem while maintaining the original polling method. so I solved this problem by creating a delay to do the background work with priority (for cw keying...)

These are things I did not know about Arduino. If I have a chance to learn Arduino later, I will study and programming again.
If I did not know about Arduino and made you feel confused by what I was talking about, I will be careful in the future.

Thanks.
KD8CEC

2018-01-11 6:44 GMT+09:00 Pavel Milanes Costa <pavelmc@...>:

EXACTLY!

If you are in a delay() routine (or trigger one of them) while you receive a serial request from the CAT system the MCU will queue the request until the delay fishes and you check for the serial data availability, as long as 2 seconds per some of the delay(2000) in the code...

Arduino will answer back but out of sync with the PC app, then wsjt/mixw/hrd/fldig/hamlib etc will disconnect as "radio did not respond."

The link Jack posted has the idea of using millis instead of delays I mentioned in my email.


Some more URL to deep on this and stop using delay() for EVERTHING:

(See Notes and Warnings at the bottom)



From the hand od Lady Ada (Adafruits) a complete tutorial step by step with code...



Cheers, Pavel.


El 10/01/18 a las 14:28, Jack Purdum via Groups.Io escribi¨®:
The Arduino delay() function is a blocking function, which means the delay() does not disable interrupts and means that interrupt events can be missed. You can write your own delay routine that does disable interrupts which queues the interrupt(s). Most programmers who are using interrupts write their own delay routine. See:




Jack, W8TEE



From: Pavel Milanes Costa <pavelmc@...>
To: [email protected]
Sent: Wednesday, January 10, 2018 1:51 PM
Subject: Re: [BITX20] Implement a uBITX Memory Manager Program

You are asking for a hammer to break an egg.
A quick search of the word "delay(" in the ubitx sources returned 52 hits, with a quite amount of them being 500 msec or more.
Get rid of the blocking delays and the CAT control will work flawlessly. Been there done that for a project.
Note: you can do a dirty hack and build a fast as hell non blocking delay of any length routine breaking the amount of time by smaller chunks and check for serial commands in the meanwhile, 10 millis worked for me... but this is a dirty trick, you can also try to reprogram the routines that depends on delays with a account for millis instead or thinking out of the box... at the end refactoring will lead to a smaller firmware that the dirty hack...
Even with interrupt routines (that you don't use) it can be worked out, they can be changed to work in "flag flip, do next" instead of "do this code right now" and it will work.
73 Pavel CO7WT.


El 10/01/18 a las 11:51, Ian Lee escribi¨®:
If you are wondering about RTOS, I think RTOS should be monitoring most interrupts as much as possible.

However, the questioner is curious about the timeout.?Timeouts will only occur in the original source of uBITX.
Suppose that you press the menu button once and wait for the next button in the while statement.
Let wsjt-x transmit the protocol that reads the frequency once every 500ms, and if there is no response, it displays an error and disconnects.
When the user presses the button to select the menu and wonders whether to move the band or change the CW tone, 500ms flows and wsjt-x displays an error and disconnects.

This is a problem that can be easily solved using an interrupt or an RTOS.?
For this reason I talked about the interrupt and the RTOS.?If you are wondering about RTOS, please feel free to ask.
I will explain in detail what I know.

2018-01-10 23:28 GMT+09:00 Michael Monteith via Groups.Io <michael_r_monteith=yahoo.com@groups.io>:
Ian,
?I've been wondering if RTOS might be an option to handle all the interrupts etc?


73, Michael
KM4OLT


--
Best 73
KD8CEC / Ph.D ian lee
kd8cec@...
(my blog)

-- 
73 CO7WT, Pavel.



Virus-free.

-- 
73 CO7WT, Pavel.



--
Best 73
KD8CEC / Ph.D ian lee
kd8cec@...
(my blog)

Join [email protected] to automatically receive all group messages.