Last active
December 23, 2023 17:03
-
-
Save ukicomputers/0a4f9aa8842a89ebb5fd09589f8c80fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fully working code for reading from serial port in Linux | |
// Tested on STM32F437ZG | |
#include <libserial/SerialPort.h> | |
#include <iostream> | |
using namespace LibSerial; | |
int main() { | |
SerialPort serial; | |
serial.Open("/dev/ttyUSB0"); | |
serial.SetBaudRate(BaudRate::BAUD_115200); | |
serial.SetFlowControl(FlowControl::FLOW_CONTROL_NONE); | |
while(1) { | |
std::string read; | |
serial.ReadLine(read); | |
std::cout << read; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment