源码如下(文档中的uart例程):
#include <stdio.h>
#include <unistd.h>
#include <wiringx.h>
int main() {
printf(“code line is: 7\n”);
struct wiringXSerial_t wiringXSerial = {9600, 8, ‘n’, 1, ‘n’};
char buf[1024];
int str_len = 0;
int i;
int fd;
printf(“code line is: 12\n”);
if(wiringXSetup(“duo”, NULL) == -1) {
wiringXGC();
return -1;
}
if ((fd = wiringXSerialOpen("/dev/ttyS4", wiringXSerial)) < 0) {
printf("Open serial device failed: %d\n", fd);
wiringXGC();
return -1;
}
// wiringXSerialPuts(fd, "Duo Serial Test\n");
while(1)
{
str_len = wiringXSerialDataAvail(fd);
//printf("str_len is: %d\n",str_len);
if (1) {
i = 0;
printf("i is: %d\n", i);
while (1)
{
printf("code line is: 35\n");
buf[i++] = wiringXSerialGetChar(fd);
printf("Duo UART receive: %s\n", buf);
}
}
}
wiringXSerialClose(fd);
return 0;
}
但是串口检测不到有数据接收,报错如下:
stm32可以发送数据给电脑,并且可以在串口助手中显示出来。
duo文档中的uart例程也能跑通。
但是将二者接到一起duo就接收不到数据,这是为什么呢?
排除接线原因,波特率也换过不同的试过,但还是不行
跪求大神解答/(ㄒoㄒ)/~~