输出可读的十六进制,带有来自串口的printf [英] Output readable hex with printf from serial port

查看:119
本文介绍了输出可读的十六进制,带有来自串口的printf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i尝试将数据从串口写入终端屏幕。

数据将被格式化并打印出来使用printf命令



printf(Data%x,&c);



该程序将是正确的...它告诉我十六进制。

但是打印的十六进制不正确...十六进制的值有错误。



当我尝试将原始数据写入文件并阅读时:



cat / dev / ttyUSB0 | xxd



输出是否正确。



任何人都可以帮助我吗?



通过

Hi all,

i try to write data from serial port to my terminal screen.
The Data will be formated and print out with the printf command

printf(" Data %x ",&c);

The programm will be correct... it shows me the hex.
But the printed hex are not correct... The hex have the wrong value.

When i try to write the raw Data to a file and read this with:

cat /dev/ttyUSB0 | xxd

the Output will be correct.

Can anyone help me?

By

推荐答案

Quote:

printf(Data%x,& c);

printf(" Data %x ",&c);

可能上面的行应该是

Probably the above line should be instead

printf(" Data %x ", c);



但是很难提供帮助没有看到更多的代码。


However it is difficult to help without seeing more code.


THX ...

那个标志&是我的错误......
THX...
That Sign "&" was my mistake...


这篇关于输出可读的十六进制,带有来自串口的printf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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