I'm currently trying to make a programm to read a serial port. On this port I receive data with a baud rate of 875000. It's really uncommon and I don't succeed to modified it. I've make a little C programm to do that but it didn't work with 875000... Here some part of the code with the programmation of the serial port :
#include <stdio.h>
#include <stdlib.h>
#include <asm/termios.h>
#include <sys/fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#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\n");}
//printf("Serial port open successful !\n");
int speed = atoi("875000");
ioctl(file, TCGETS2, &options);
options.c_ispeed = speed;
options.c_ospeed = speed;
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag |= PARENB;
options.c_cflag |= PARODD;
options.c_cflag &= ~CBAUD;
options.c_cflag |= BOTHER;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
ioctl(file, TCSETS2, &options);
//printf("Reading serial port ...\n\n");
b = readMessage(file, nCountMax);
if (b == 0){printf("Error while reading serial port\n");}
//else printf("\nSerial port read successful\n");
close(file);
//printf("Serial port closed\n");
};
options.c_ispeed = options.c_ospeed = 875000;
instead ofint speed = atoi("115200"); ...
– chux - Reinstate Monica