用read函数去读取串口数据 为何read函数的第三个参数设置的数越大的时候read到数据就越少呢(第三个数越大,往image.image文件里写入的数据就越少) why? 我读取的内容是传过来的一张jpeg格式的图片内容
while (1)
{
of.open("image.image", ios::app|ios::out);
if (of.is_open())
{
res = read(fd, buf, 1);设置成1的时候读取的数据算是比较完整了
buf[res] = '\0';
string str = buf;
of<<str;
of.flush();
of.close();
}
else
{
cout<<"of open error!!!!!"<<endl;
}
}