openmv与stm32串口通信

求问openmv检测到的色块坐标(x,y)用usart串口发送给32该如何接收?存储到哪里?
如果定义一个数组,用返回值不断更新数组中的内容,该如何做到?
求解,谢谢!!


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>

int serial_open(const char *device, int baudrate) {
    struct termios tio;
    memset(&tio, 0, sizeof(tio));
    tio.c_cflag = CS8 | CLOCAL | CREAD;
    tio.c_cc[VTIME] = 5;
    cfsetospeed(&tio, baudrate);
    cfsetispeed(&tio, baudrate);
    int fd = open(device, O_RDWR | O_NOCTTY);
    if (fd < 0) {
      perror(device);
      return -errno;
    }
    tcsetattr(fd, TCSANOW, &tio);
    return fd;
}

int main(int argc, char** argv) {
    int fd = serial_open("/dev/ttyUSB0", 115200); //根据实际情况修改端口和波特率
    if (fd < 0) {
        return fd;
    }
    char buf[256];
    int len;
    while (1) {
        len = read(fd, buf, sizeof(buf)-1);
        if (len > 0) {
            buf[len] = '\0';
            printf("%s", buf);  //打印收到的数据
        }
    }
    close(fd);
    return 0;
}