为什么不工作我的串行通信? [英] Why is my serial communication not working?

查看:352
本文介绍了为什么不工作我的串行通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看着在手动(第177页)为DE2而据我的理解应该是可以通过腻子和一个USB转串口线到板做比如串行通讯,所以我从手动程序:

I looked in the manual (page 177) for the DE2 and as far as I understand it should be possible to do serial communication for instance via putty and a usb-to-serial cable to the board, so I take the program from the manual:

/* 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

And I try to run it as Nios2 hardware but then I get this message when I have configured std i/o to use uart

打印到终端:无法打开UART:没有这样的文件或目录

,然后当我用一个终端程序连接(腻子串行连接),它无法连接。我究竟做错了什么?我试图在谟化子性质改变STD的I / O UART,但没有帮助。你能帮助我吗?

And then when I connect with a terminal program (putty serial connection) it doesn't connect. What am I doing wrong? I tried in the propeties of the projet to change the std i/o to uart but that didn't help. Can you help me?

推荐答案

如何调试串行通讯:

把你的9针串行电缆,把一个跳线插针2和3在一起。你可以用一个回形针或者你有什么得心应手。销2和3是TX和RX。如果将它们连接在一起,你从电脑发送的任何命令将由电脑接收。你已经创建了一个串行回环!

Take your 9 pin serial cable and put a jumper pins 2 and 3 together. You can use a paperclip or whatever you have handy. Pins 2 and 3 are TX and RX. If you connect them together, any command you send from the computer will be received by the computer. You have created a serial loopback!

打开腻子,尝试连接到您的串行电缆。按下键盘上的任意键。波特率,事情并不重要,因为它是一个回送。

Open Putty, try to connect to your serial cable. Hit any key on your keyboard. Baud rate and things don't matter because it's a loopback.

如果你看到你发出的终端上接收的,你的串行电缆作品的人物!如果没有,你有一个问题,你的有线或用腻子。我曾与串行通讯过去曾与腻子的问题。尝试下载万亿期限如果你有腻子不连接问题。

If you see the character you sent out received on the terminal, your serial cable works! If not, you have a problem with your cable or with putty. I have had issues with putty in the past with serial communication. Try downloading Tera Term if you have a problem with Putty not connecting.

或者找到你的串行电缆新的驱动程序!祝你好运。

Or find new drivers for your serial cable! Good luck.

这篇关于为什么不工作我的串行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆