armadsen / ORSSerialPort

Serial port library for Objective-C and Swift macOS apps
MIT License
755 stars 183 forks source link

I would rather wait for all data to be sent before continuing with the next line of code #181

Closed moyun-yinyun closed 2 years ago

moyun-yinyun commented 3 years ago

i wan't sync write data how to set, Thank you!

armadsen commented 2 years ago

Sorry it took so long to get to your question. There isn't currently a way to do this, and I'm not likely to add it because it significantly complicates the API, and in general I don't think it makes sense to structure code this way. If you have control of the serial protocol, you're better off designing it so the device on the other end sends an acknowledgement of some sort, and you wait until you receive that to continue on with the next task rather than blocking waiting for the send to finish.

ORSSerialPort's request/response API will help you here.