如何以5位存储8位存储数据 [英] How Can I Send Data Stored In 8 Bits In 5 Bits
本文介绍了如何以5位存储8位存储数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在数据以8位的形式串行传输现在我想以50位的速度发送5位
Presently data is going serially in the form of 8 bits now i want to send it on 5 bits on 50 bps
推荐答案
这很复杂:如果你的意思是你想要将每个字符5位作为文本类型数据发送,然后使用 Base64 [ ^ ] - 根据您的框架,有多种方法可以转换为/从base64:< br $> b $ b
Google:Base64 [ ^ ]
如果你使用.NET框架,那么这些是可用的:
Convert.ToBase64 [ ^ ]
Convert.FromBase64 [ ^ ]
That's complicated: if you mean you want to send 5 bits per character as text-type data, then look at using Base64[^] - depending on what your framework is, there are various ways to convert to / from base64:
Google: Base64[^]
If you apop uses the .NET framework, then these are available:
Convert.ToBase64[^]
Convert.FromBase64[^]
正如Griff所说,请遵循Base64的原则。请注意,这是一种将8位字符数组转换为6位字符数组的方法,因此您必须实现自己的解决方案以转换为5位字符。
简单地说,你取五个8位字符,将它们放在一个足够长的整数中(例如至少40位,实际上意味着一个64位整数)并在一个读出5位时间,形成8个5位字符。另一方面,你颠倒了这个过程。
现在,关于如何以50 bps传输5位字符,这完全取决于操作系统,以及串行硬件。各种UART和其他通信芯片的接受程度有限。
As Griff says, go for the principle of Base64. Note that this is a method for transposing an array of 8-bit characters into an array of 6-bit characters, so you will have to implement your own solution to transpose into 5-bit characters.
Simply put, you take five 8-bit characters, put them together in one integer of sufficient length (e.g. at least 40 bits, which effectively means a 64-bit integer) and read out five bits at a time, to form eight 5-bit characters. On the other end, you reverse the process.
Now, as for how to transfer 5-bit characters at 50 bps, that depends entirely on the operating system, and the serial hardware. There are limitations in what various UARTs and other communication chips accept.
这篇关于如何以5位存储8位存储数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文