You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
726 B

#include <string.h>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
#include "uart.hpp"
using namespace std;
using namespace iflytop;
#define UART_NAME "/dev/ttyS0"
int main(int argc, char const* argv[]) {
Uart uart;
uart.open(UART_NAME, "115200");
thread th([&]() {
//
while (true) {
char buf[1024];
memset(buf, 0, 1024);
int size = uart.receive(buf, 1024, 10);
if (size > 0) {
cout << "receive:" << buf << endl;
}
}
});
while (true) {
printf("tx hello\n");
uart.send("hello", 5);
sleep(1);
}
}