Bouni / MateDealer

MateDealer, a open source MDB cashless device implementation
58 stars 38 forks source link

SETUP command 111H with Sub-command 010H #6

Open maxpromer opened 6 years ago

maxpromer commented 6 years ago

Hello, thank you for make it code and your blog very good !

I have problem. i read your blog at http://blog.bouni.de/2012/the-mdb-protocol-part-3.html, the setup command (111H) will has 2 sub command : 000H and 0001H

I have VMC board. and i try send 100H (ACK) when Reset command and then send 000H 100H when PULL command and then VMC send it

+V: 0x111
+V: 0x010
+V: 0x111
+V: 0x010
+V: 0x117
+V: 0x117

Are you know about sub command 010H in SETUP command ?

Thanks !

This my code (Arduino) without UART file


extern void MDB_write(int data) ;
extern int MDB_read() ;
extern int MDB_available() ;
extern void MDB_setup() ;

void setup() {
  MDB_setup();

  Serial.begin(9600);
  Serial.println("Start !");

}

#define WAIT_DATA_1_Byte() { while (!(UCSR1A & (1 << RXC0))); }
#define READ_DATA_1_Byte() (((UCSR1B & 0x2) << 7) | UDR1)

int isReset = true;

void loop() {
  WAIT_DATA_1_Byte();
  int b = READ_DATA_1_Byte();
  if (b == 0x110) {
    WAIT_DATA_1_Byte();

    if (READ_DATA_1_Byte() == 0x010) {
      MDB_write(0x100);
      isReset = true;
      //Serial.println("Respont RESET command");
    }
  } else if (b == 0x112) {
    WAIT_DATA_1_Byte();

    if (READ_DATA_1_Byte() == 0x012) {
      if (isReset) {
        MDB_write(0x000);
        MDB_write(0x100);
        //Serial.println("Send Just reset");
        isReset = false;
      } else {
        MDB_write(0x100);
        //Serial.println("Send ACK");
      }
    }
  } else if ((b&0xF8) == 0x10) {
    Serial.print("+V: 0x");
    Serial.print(b >> 8, HEX);
    if ((b & 0xFF) < 0x10) Serial.print("0");
    Serial.print(b & 0xFF, HEX);
    Serial.println();
  }
}
Bouni commented 6 years ago

What type of device do you try to implement, a cashless device?

maxpromer commented 6 years ago

I want to make cashless device.

Now, my code has bug. I use logic analyzer to debug i found VMC send 0x111 0x000 but my code show 0x111 0x010

Are you have guidance to fix my code ?