There is nothing fancy.Added one tab in gui.lua and a new lua file for that tab that just contains my buttons.Which buttons are copy/pasted from other buttons and i just changed the commands
It doesn't matter if it is "fancy" or not, it is much more difficult to give you specific advice when I don't know what you are actually doing.
Since you post about the problems you encounter, I assume you want help. If you do want help, it's in your interest to make it as easy as possible for those who volunteer their time and effort to help you. Providing as much specific detail as you can about the problem is a good way to do that.
Anyway, in this case it seems like the errutil.wrap code I suggested earlier should give you better diagnostics in your buttons.
So i have to turn some cmd to cmdwait.Is there a rule ?What commands need to be "cmdwait"?
As I said, you should wait for the previous command to finish before issuing a new one. You can use cmdwait with any command that uses write_status, which AFAIK is just about everything but quit. Note that depending how your code is set up, using cmdwait in the gui may make it effectively lock up until the command finishes.
I suspect there is some other underlying problem causing the queue to fill up, it seems unlikely that you would be issuing more than 15 commands to the same camera in rapid succession. I wouldn't be surprised if it was somehow related to the communication errors, but I don't see exactly how that would happen, and not knowing the specific sequence of event I can only speculate.