c - Terminal input serial commands, output Arduino Tx -


i of beginner in space

i using arduino mega2560 , interfacing coin machine vending machine. coin machine runs on protocol called mdb (multi-drop bus) 9bit serial. use arduino ide not cater 9-bit serial. have therefore decided code using c , ubuntu 12.04. have come across usart setup function can bitbash 9bit mode. have installed avr-gcc avr-libc avrdude.

the coin machine acts depending on serial data recieves. i.e reset needs read 100101010 rx (this random 9-bit number, not sure true number @ moment). example if recieves 10101111 on rx dispense coin of desired type etc. there various other commands ack,poll, etc. want send appropriate binary numbers out arduino's tx , coin machine's rx , try communication coin machine.

this context main question more general (lets assume working in 8bit mode):

a) how can type 8bit binary number (e.g 10111010) on terminal, , have number put on tx line of arduno. b) since mega2560 has 3 tx/rx modules, can tx 1 module , rx module, testing, such 8bit binary number type in terminal appears on terminal too.

note: reason want numbers represented in binary because want see each bit, make more sense me way

i trying similar bouni's matedealer (see github repository) implementing arduino slave, want implement master. more on project here.

thank kindly!

a) there 2 solutions:

  • you send binary representation of number, '00001111' through serial line, , in µc use function strtoul, takes parameters array of char (in case '00001111') , base (here 2) , returns corresponding value (here 0x0f, or 16);
  • you create own terminal, converts input binary representations decimal representations (here, converts '00001111' '16'), sends µc uses function atoi corresponding value (here, 16 or 0x0f)

i think former easier, little bit slower, while latter offload microcontroller.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -