Good. There is a program that configures / dev / ttyS0. It sends messages on this port. Tell me how to listen to incoming and outgoing messages on this port.
cat / dev / ttyS0 only works when I connect the device I want to control and it sends its messages to the port, I see them.
But what my program is trying to send to the port I can not track.
I create a FHandel pointer to the / dev / ttyS0 port, with the necessary settings.
int FHandle; void Uart::Open() { int flags |= O_RDWR | O_NOCTTY; FHandle = open("/dev/ttyS0", flags); if(FHandle == InvalidHandleValue) throw UartExcept; termios newSettings; bzero(&newSettings, sizeof(termios)); cfsetospeed(&newSettings, B9600); cfsetispeed(&newSettings, B9600); newSettings.c_cflag |= CS8; newSettings.c_cflag |= (CLOCAL|CS8|CREAD); newSettings.c_cflag &= ~(CRTSCTS|CSIZE|PARENB); newSettings.c_cc[VMIN] = 0; newSettings.c_cc[VTIME] = 3; newSettings.c_iflag = INPCK | IGNPAR; if(tcsetattr(FHandle, TCSANOW, &newSettings) == -1) throw UartException; } In a certain place send buffer
UInt32 Uart::Write(const Byte *_inputBuffer, UInt32 _bufferOffset, UInt32 _numberOfBytesToWrite) { ssize_t result; if (FWOverlapped == nullptr) result = write(FHandle, _inputBuffer + _bufferOffset, _numberOfBytesToWrite); return (UInt32)result; } How to intercept these messages that I send using the program?
Thank you for your time.