[英]Terminal input serial commands, output Arduino Tx
I am somewhat of a beginner in this space 我在这个领域有点新手
I am using Arduino Mega2560 and interfacing it with a coin machine from a vending machine. 我正在使用Arduino Mega2560,并将其与自动售货机中的投币机接口。 The coin machine runs on a protocol called MDB (multi-drop bus) which is 9bit serial.
投币机基于称为9位串行MDB(多点总线)的协议运行。 I would normally use the Arduino IDE but that does not cater for 9-bit serial.
我通常会使用Arduino IDE,但这不能满足9位串行。 I have therefore decided to code using c and ubuntu 12.04.
因此,我决定使用c和ubuntu 12.04进行编码。 I have come across a usart setup function which can bitbash into 9bit mode.
我遇到过一个usart设置功能,该功能可以将bitbash转换为9bit模式。 I have installed avr-gcc avr-libc avrdude.
我已经安装了avr-gcc avr-libc avrdude。
The coin machine acts depending on serial data it recieves. 投币机根据接收到的串行数据起作用。 ie to reset it needs to read 100101010 from its Rx (this is a random 9-bit number, I am not sure what the true number is at this moment).
即要重置它,需要从其Rx读取100101010(这是一个随机的9位数字,我不知道目前的真实数字是多少)。 Another example would be if it recieves 10101111 on Rx it would dispense a coin of desired type etc. There are also various other commands like ack,poll, etc. So what I want to do is send the appropriate binary numbers out from the Arduino's Tx and into the coin machine's Rx and try get communication with the coin machine.
另一个示例是,如果它在Rx上接收到10101111,它将分配所需类型的硬币等。还有其他各种命令,例如ack,poll等。所以我要做的是从Arduino的Tx中发送适当的二进制数字并进入投币机的Rx,并尝试与投币机进行通信。
This was just for context but my main question is more general (lets assume we are working in 8bit mode): 这只是出于上下文,但是我的主要问题是更笼统的(假设我们在8位模式下工作):
a) how can I type a 8bit binary number (eg 10111010) on the terminal, and have that number be put on the Tx line of the arduno. a)如何在终端上键入8位二进制数字(例如10111010),并将该数字放在arduno的Tx行上。 b) since the mega2560 has 3 Tx/Rx modules, can I Tx from one module and Rx from another module, for testing, such that the 8bit binary number I type in terminal appears on the terminal too.
b)由于mega2560具有3个Tx / Rx模块,因此可以从一个模块的I Tx和从另一个模块的Rx进行测试,以便我在终端上输入的8位二进制数也出现在终端上。
note: The reason I want the numbers to be represented in binary is because I want to see each bit, it will make more sense to me that way 注意:我希望数字以二进制表示的原因是因为我想查看每一位,所以这样对我来说更有意义
I am trying to do something similar to Bouni's MateDealer (see github repository) but he is implementing the Arduino as a slave, I want to implement as a master. 我正在尝试做与Bouni的MateDealer类似的事情 (请参阅github存储库),但是他正在将Arduino实现为从属,我想实现为主控。 More on his project here .
更多关于他的项目在这里 。
Thank you kindly! 非常感谢你!
A) There is two solutions: A)有两种解决方案:
I think that the former will be easier, but a little bit slower, while the latter could offload the microcontroller. 我认为前者会容易一些,但会慢一些,而后者则可以减轻微控制器的负担。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.