我如何知道用于与我的串行端口通信的十六进制?

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

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

问题描述

背景信息:我正在使用 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

我已准备好学习,我不要求直接回答.我希望我在 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 的《代码》一书很好地帮助您停止谈论十六进制".

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".

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

本文标题为:我如何知道用于与我的串行端口通信的十六进制?

基础教程推荐