Hello, first post from me.
I'm creating an application with a loop to manipulate hardware I/O on a Raspberry Pi Zero (single core).
The main loop is running with a delay/sleep at the end to create a fixed cycle time.
I would like to create a CLI (command line interface) to be able to communicate with the program i made.
So i implemented a readln(command) and then use a case statement loop to output information with writeln(..) to correspond to the input command.
If i was to implement the readln in the main loop it would block the cycle until a command is entered, this is not good since i want the main loop running all the time.
So i started looking at threads. I implemented the readln and case in a procedure/function and started a beginThread to run it in parallell. It kinda works but the result is not really what i expected. The main loops keep going so thats good, but the writeln output from the CLI function is offset on every line on the command line and there is no echo back on the keystrokes like a normal readln do but it seems to register because the first command followed by enter outputs, but subsequent inputs require multiple enters before it registers the command, also first new keystrokes seems to register as enter for some reason. (Its a little hard to explain in detail)
I have tried looking for a solution to this and ive read alot of documentation and forums but nothing seems to correspond to this type of case.
This is a hobby project btw.
(My background in Pascal is two weeks
allthough i have a background in electrical and automation engineering with programming in Structured Text that is losely based on Pascal which lowered the bar. I also have experience in Verilog programming of FPGA/CPLD's.)
Edit: Changed title to solved.