Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3b00e7

Browse files
author
harunkurt.me
committed
add CppLinıxSerial library and a make cpp/example1.cpp
1 parenta326528 commitb3b00e7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

‎cpp/a.out‎

0 Bytes
Binary file not shown.

‎cpp/example1.cpp‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ using namespace mn::CppLinuxSerial;
44

55
intmain() {
66
// Create serial port object and open serial port at 57600 buad, 8 data bits, no parity bit, and one stop bit (8n1)
7-
SerialPortserialPort("/dev/ttyUSB0", BaudRate::B_57600, NumDataBits::EIGHT, Parity::NONE, NumStopBits::ONE);
7+
SerialPortserialPort("/dev/ttyUSB0", BaudRate::B_9600, NumDataBits::EIGHT, Parity::NONE, NumStopBits::ONE);
88
// Use SerialPort serialPort("/dev/ttyACM0", 13000); instead if you want to provide a custom baud rate
99
serialPort.SetTimeout(-1);// Block when reading until any data is received
1010
serialPort.Open();
1111

1212
// Write some ASCII data
13-
serialPort.Write("Hello");
13+
//serialPort.Write("Hello");
1414

1515
// Read some data back (will block until at least 1 byte is received due to the SetTimeout(-1) call above)
1616
std::string readData;
17-
serialPort.Read(readData);
17+
while(true){
18+
serialPort.Read(readData);
1819

1920
std::cout<< readData<<std::endl;
21+
}
22+
2023

2124
// Close the serial port
2225
serialPort.Close();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp