SCPI message exchange control implementation
Here is an open source library that I have tested and found to work perfectly.

I wish there was more to this answer but simply put, the work is all already done for you.

https://github.com/j123b567/scpi-parser