我查看了 DE2 的手册(第 177 页),据我所知,它应该可以进行串行通信,例如通过油灰和 USB 到串行电缆到板上,所以我从手册中获取程序:
/* A simple program that recognizes the characters 't' and 'v' */
#include <stdio.h>
#include <string.h>
int main ()
{
char* msg = "Detected the character 't'.\n";
FILE* fp;
char prompt = 0;
fp = fopen ("/dev/uart1", "r+"); //Open file for reading and writing
if (fp)
{
while (prompt != 'v')
{ // Loop until we receive a 'v'.
prompt = getc(fp); // Get a character from the JTAG UART.
if (prompt == 't')
{ // Print a message if character is 't'.
fwrite (msg, strlen (msg), 1, fp);
}
if (ferror(fp))// Check if an error occurred with the file pointer
clearerr(fp); // If so, clear it.
}
fprintf(fp, "Closing the JTAG UART file handle.\n");
fclose (fp);
}
return 0;
}
我尝试将它作为 Nios2 硬件运行,但是当我将 std i/o 配置为使用 uart 时收到此消息
nios2-terminal: can't open uart: No such file or directory
然后当我连接终端程序(腻子串行连接)时,它没有连接。我究竟做错了什么?我尝试在项目的特性中将 std i/o 更改为 uart,但这并没有帮助。你能帮助我吗?