Cctalk protocal

Help
FredArtes
2011-09-23
2013-04-30
  •  FredArtes

    FredArtes - 2011-09-23

    I want to integrate a coin acceptor (connected to my pc on com port) into my Delphi 7 Application. This specific coin acceptor uses the ccTalk protocol. I'm trying using ComPort example : connection is ok (ComPort.Open don't give me any exception) but I can't send/receive data from usb coin accepter.

    This is the manual of protocol used by coin accepter
    https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&
    srcid=0BxKWzL5rJt_gNWEwZDRmMTktODljYy00ZjljLWFhZWQtMzIxZmY0YjVlMmFl&hl=it

    Try calling ComPort.WriteStr("    ") nothing happens, can you help me ?

     
  • Stephen Gaunt

    Stephen Gaunt - 2011-09-23

    The link to your manual doesn't work for me, but I am guessing that the protocol wants the values in the square brackets, what you are doing will send a string containing the square brackets, I doubt is that is correct!
    I usually use .write function
    set up a buffer and do something like this… 

    var TxBuff :array  of byte

    TxBuff := 0;
    TxBuff := 0
    TxBuff := 1;
    TxBuff := 253;
    TxBuff := 2;

    Comport.write(TxBuff, 5);

     
  •  FredArtes

    FredArtes - 2011-09-23

    This command requests the Validator for information about the configuration of the inhibit bits
    of the coins. This command is complementary to ¡Error!No se encuentra el origen de la
    referencia., page ¡Error!Marcador no definido..
    Send:    
    Reply:        -> ACK with 2 data

    I must send this message, so      becomes

    ComPort.WriteStr(chr(2)+chr(0)+chr(1)+chr(230)+chr(23)) ?

     
  • Stephen Gaunt

    Stephen Gaunt - 2011-09-23

    Ok see it now, yes as I said they don't want you to send the brackets that is just for clarity.

    Send the commands in a buffer as I have shown. it looks to me that they want byte commands not ascii codes  (as is usual)  forget trying to use writestr

    I haven't studies the protocol in detail but you need to see if the Coin Mech sends back a specific header byte, if it does, then use the Packet handler component to receive the returned messages, much easier than trying to do it using onrxchar.

     
  • Brian Gochnauer

    Brian Gochnauer - 2011-09-23

    yes, but also can be written;

    Comport.Writestr(#2#0#1#230#23); //  since the # symbol signifies a decimal char

     
  •  FredArtes

    FredArtes - 2011-09-23

    S is always an empty string

    ComPort.Connected := true;
    Comport.Writestr(#2#0#1#230#23);  {Send modem Command}
    Sleep(200);
    ComPort.ReadStr(S,80); {Get modem response.}
    ShowMessage(S);
    

    or

    var TxBuff :array [1..5] of byte;
    TxBuff[1] := 2;
    TxBuff[2] := 0;
    TxBuff[3] := 1;
    TxBuff[4] := 230;
    TxBuff[5] := 23;
    Comport.write(TxBuff, 5);
    Sleep(200);
    ComPort.ReadStr(S,80); {Get modem response.}
    ShowMessage(S);
    
     
  • Brian Gochnauer

    Brian Gochnauer - 2011-09-23

    Comport.write(TxBuff, 5); 

    also returns how many bytes were sent .

    i := Comport.write(TxBuff, 5);
    ShowMessage('bytes sent '+IntToStr(i));

     
  •  FredArtes

    FredArtes - 2011-09-23

    Five bytes sent ….

     
  • Brian Gochnauer

    Brian Gochnauer - 2011-09-23

    I guess I would make sure I understood the ccTalk protocol.

    Modify / Review the MinTerm example application as a test interface.

     
  •  FredArtes

    FredArtes - 2011-09-26

    Yes, I'm review the Minterm exampe application, here my code

    procedure TMainForm.Button1Click(Sender: TObject);
    var  s:String;
        i : integer;
        test : string;
    begin
       ComPort.Port := 'COM3';
       ComPort.Connected := false;
       ComTerminal.Connected := false;
       Application.ProcessMessages;
       ComPort.Connected := true;
       ComPort.Open;
       i := Comport.Writestr('#0#0#1#253#229');
       Sleep(200);
       ComPort.ReadStr(S,80); {Get COM response.}
       ShowMessage(S);
       if Pos('OK',s)>0 then
         Application.MessageBox( PChar('COM is responding normally '+ComPort.Port), 'Test', MB_OK)
       else
         Application.MessageBox( PChar('No COM responding on '+ComPort.Port), 'Test', MB_OK);
       ComPort.Connected := false;
    end;
    

    I think Comport.Writestr('#0#0#1#253#229'); is not correct !

     
  • Brian Gochnauer

    Brian Gochnauer - 2011-09-26

    I think Comport.Writestr('#0#0#1#253#229'); is not correct !

    I was wrong; you are correct in Delphi 7 that uses AnsiStrings as default 'string' the #0 will mark the 'end of the string'  making it an empty string.

    In Delphi 7 you will have to use Comport.write function if you want to send #0 characters using a buffer like;

       var TxBuff :array  of byte;
    or
        var TxBuff :array  of char;

     

Log in to post a comment.