我正在尝试制作一个程序来读取串口。在这个端口上,我收到波特率为875000的数据。这种情况并不常见,我没有成功修改它。我做了一个小C程序来做到这一点,但它不适用于875000 ...这里的代码的一部分与串口的编程:
#include
#include
#include
#include
#include
#include
#include
#include "test.h"
void read_Serial_Port(const char* DEVICE_PORT)
{
int file;
struct ktermios options;
unsigned int nCountMax = 60;
bool b;
file = open(DEVICE_PORT, O_RDONLY | O_NOCTTY | O_NDELAY);
if(file == -1){perror("Unable to open the serial port
");}
//printf("Serial port open successful !
");
int speed = atoi("875000");
ioctl(file, TCGETS2, &options);
options.c_ispeed = speed;
options.c_ospeed = speed;
options.c_cflag |= (CLOCAL | CREAD);
options.c