专用连接/文本输出,用于与串行设备通信

I am a software developer currently entering the world of programming for physical devices through a serial interface and some aspects are foreign or unknown to me.

One such aspect is figuring out how connections to a serial device behave during concurrent reading and writing.

Let me explain: I have a serial device mounted on /dev/ttyACM0 for example, and I have to develop a routine which reacts to output from that device, triggered by a variety of outside sources. That means I have a program which opens a connection that constantly and asynchronously reads the output.

Example in golang:

func main() {
    go listenForUpdates() //create an asynchronous routine
    //something else that keeps the program running
}

func listenForUpdates() {
    for {
        //blocks until device sends some output
        responseAsBytes, err := serialController.Readline("/dev/ttyACM0") 
        if err != nil {
            panic(err)
        }
        response := string(responseAsBytes)
        //do something with response
    }
}

Besides that, I have other routines which open a new connection to write to the device and also expect some output specific to what was written.

func execute() {
    err := serialController.Write("/dev/ttyACM0", "MY_COMMAND")
    if err != nil {
        panic(err)
    }
    //expects a certain output to be sent
    responseAsBytes, err := serialController.Readline("/dev/ttyACM0")
    if err != nil {
        panic(err)
    }
    response := string(responseAsBytes)
    //do something with response
}

So my question is: Which Readline operation reads the output triggered by the Write operation? Is it the one in the asynchronous routine (even though it's a separate connection), or is it the one called directly after the Write operation?

Imagine the device is receiving lots of traffic and that I need some guarantee that the output I am reading after a Write operation is not something related to the operation itself, or that I am executing many Write operations and the outputs dont get mixed up.

Any clarifying answer or documentation to help me figure this out is greatly appreciated.

(I posted here since it's more related to serial devices than programming)