So I have seen many discussions about people writing their own programs to communicate with marlin and having problems with when to successfully send commands however most of them just say you can send after ok has been received but that does not seem to work. I feel like I must be missing something and was hoping someone here could help point me in the right direction.
Here is what I am trying to do,
I am creating my own user interface to allow functionality for some specific printing techniques but am having trouble sending a file of G and M code in a reliable manner.
If I try to send a command every time I receive an "ok", the communication stops after sending a blocking command like G28 because the program seems to keep sending commands which are discarded then the programs stops getting oks. When it is just a stream of g code the buffer fills up, when I handle the buffer filling up or sending blocking commands by resending commands that are replied to with "echo:busy: processing\n" sometimes they are processed and sometimes they are not processed meaning some commands are received twice or even 3 times.
I feel like I have tried every way to handle communication without writing my own planner to estimate time for command completion but from what I have seen I don't think that is necessary. Does anyone perhaps know how matter control or the other UI's out there perform their communication, I have tried looking through the code but haven't found anything that helps me. I know it looks as easy as send after an ok but I feel there must be more to it than that.
If anyone has any ideas I could explore I would greatly appreciate it.
serial comms settings
opened for read and write
Baud rate: 250 000
Data bits: 8
Parity: No parity
stop bits: one stop
flow control: no flow control