On Tuesday, February 7, 2023 at 7:33:51 PM UTC-5,
[email protected] wrote:
On Tuesday, February 7, 2023 at 5:15:02 PM UTC-7, Jach Feng wrote:
hansolosnah 在 2023年2月8日 星期三清晨6:54:15 [UTC+8] 的信中寫道:
My question is: What makes Forth suitable for diagnostics?
ziloo
First, Forth is an interactive environment which helps much on diagnostics job. Second, not like other "interactive" script languages such as Python or JavaScript, Forth is very close to the hardware.
Jach is right --- Forth is great for diagnosing hardware.
The technician can write a one or two-line Forth word that causes something to happen
in the outside world, then execute that word on the command-line (outer interpreter).
If he keeps his eye on the oscilloscope when he hits the [enter] key, he can see if the
result in the outside world is what he expected.
Diagnostic software is possible in C, but is much more difficult.
The technician has to write a C program, not just a single C function, then run
that program on the board. C is not interactive --- getting the board to do something
in the outside world is a laborious process --- it could take an hour to do in C
what can be done in one minute in Forth.
I have used interactive C before. I believe it was a product from the company that had VxWorks, don't recall their name (maybe the VxWorks company?) The debugging tool would allow lines of C to be entered. Worked about as well as you might expect, but
it was interactive.
Some of the adventures I've had using C. I was once working on the hardware for a board and had a software guy working with me. I was trying to move forward with the process and he was focusing on one routine that had been written to encapsulate a
specific memory bus operation, something like a single 16 bit transfer, rather than 32 bits or something. This routine had just one line of actual code I believe, or maybe two lines, one to do the bus operation and one to put the result into the format
for returning the value. The guy kept analyzing this tiny module and could not explain to me why this was taking forever. I offered to explain it to him, but no, he wanted to "understand" it. Finally, I was going to fall asleep, so I left. I don't
think the issue was ever resolved. I have no idea how such a simple thing could require so much effort to understand. But you know how C is, get the address of this and use it as a pointer to that...
I'm working with my brother who is much more a businessman and much less technical. He has a little gadget that does a very simple translation of a serial data stream. So far, the only person with a good solution to the problem was from this group and
has an MCU running Forth. So we are probably going to let him program it in Forth. The specification is so simple, it would not be much code in any language, but in Forth, I'm thinking maybe five words, ten words tops.
Initialize
begin
read_line
translate_line
send_line
1 +
dup 20 >= if output_header drop 0 then
again
read_line reads a line of text from a serial port, terminated by \r\n, while not overflowing the input buffer.
translate_line has to add formatting characters to the date and time / and :, while removing the two leading characters.
send_line just sends the data out a serial port.
output_header sends five lines of fixed text to the output serial port.
This is so simple, it almost writes itself. The C code was not terribly more complex, but I think it used C++ on an arduino and used memory allocation!
--
Rick C.
- Get 1,000 miles of free Supercharging
- Tesla referral code -
https://ts.la/richard11209
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)