我如何知道十六进制用于与我的串行端口通信? [英] How do I know the Hexadecimal to use to communicate with my serial port?

查看:182
本文介绍了我如何知道十六进制用于与我的串行端口通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景信息:我使用Visual Studio 2005在对话框中编写MFC / C ++。如果我缺少任何信息或任何必要的东西回答我的问题,请原谅我。我将每天从上午9点到下午5点30分检查一次,因此请随时询问任何更多的背景信息。

Background information: I am using Visual Studio 2005 to write MFC/C++ on a dialog box. Please pardon me if I lack out any information or anything essential to answer my question. I will be checking this everyday from 9am - 5:30pm, so please don't hesitate to ask for any more background information.

我知道如何打开,阅读,使用MFC / C ++写入和关闭串行端口。问题是我不知道要发送到串口。我看到我的同事发送十六进制,如下:

I do know how to Open, Read, Write and Close a serial port using MFC/C++. The problem is I do not know what to send to the serial port. I have seen my colleagues sending Hexadecimal as such:


21 04 07 00 08 00 0F 22

21 04 07 00 08 00 0F 22

我的工作是在rx和tx板的以下图形上显示信号,噪声和阈值。 rx和tx板位于事物的底部:(ttp://www.joyfay.com/images/fei833/POSsystem/SSS05.jpg)

My job is to display signal, noise and threshold onto the following graphs from the rx and tx board. The rx and tx boards are located at the bottom of things as such: (ttp://www.joyfay.com/images/fei833/POSsystem/SSS05.jpg)


  1. http://tinypic.com/ view.php?pic = 2qdbnf8& s = 8#.U_7vU_mSxnQ

  2. http://tinypic.com/view.php?pic=29vxzmg&s=8#.U_7vi_mSxnQ

  1. http://tinypic.com/view.php?pic=2qdbnf8&s=8#.U_7vU_mSxnQ
  2. http://tinypic.com/view.php?pic=29vxzmg&s=8#.U_7vi_mSxnQ

我准备好学习,我不是要求直接的答案。我希望我的同学在Stack Overflow的编程老师可以帮助我在这里。非常感谢。

I am ready to learn and I am not asking for direct answers. I hope my fellow programming seniors in Stack Overflow can help me out here. Many thanks.

推荐答案

您必须找到您正在说话的设备的文档。它应该为您提供用于交换数据的协议。

You will have to dig up the documentation for the device you are talking to. It should provide you with the protocol that's used to exchange data. Ask your colleagues about it, they surely know where that documentation is located.

我只能从

21 04 07 00 08 00 0F 22

21 04 07 00 08 00 0F 22

0x21字节可能是起始字节指示帧的开始。设备使用它来同步自身,以便检测帧的开始。 0x22字节可能是结束字节,确认不再有字节需要跟随。设备使用它来知道帧是完全接收的,因此它可以处理数据。 0x04字节可能是一个长度字节,它编码了多少数据字节。其中似乎是0x07,0x00,0x08,0x00。它们编码的很不可猜测,它可能是两个16位的值,例如7和8. 0x0f字节可能是数据字节的校验和,用于验证数据字节是否未损坏。

The 0x21 byte is likely to be the start byte that indicates the start of the frame. The device uses it to synchronize itself in order to detect the start of a frame. The 0x22 byte is likely to be the end byte, a confirmation that no more bytes are expected to follow. The device uses it to know that the frame was received in full so it can process the data. The 0x04 byte is likely to be a length byte, it encodes how many data bytes follow. Which appear to be 0x07, 0x00, 0x08, 0x00. Pretty unguessable what they encode, it might be two 16-bit values for example, 7 and 8. The 0x0f byte is probably the checksum of the data bytes, used to verify that the data bytes were not corrupted.

非常粗糙的猜测,请阅读文档以确定。当然,和你的同事谈论它,没有什么点要求一个完全陌生人在互联网上,当你有人知道在你旁边的隔间的事实。 Petzold的书Code很好,可以帮助你停止谈论十六进制。

Very rough guesses, read the documentation to know for sure. And of course talk to your colleagues about it, little point in asking a completely stranger on the Internet when you have people that know the facts in the cubicle next to yours. Petzold's book "Code" is pretty good to help you stop talking about "hex".

这篇关于我如何知道十六进制用于与我的串行端口通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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