Jump to content

Recommended Posts

Posted

So I have a USB Credit card machine that uses JSON 2.0 standard (See bottom of post for the JSON commands).  Thus far, I have not yet seen any good examples of how to incorporate the JSON commands properly.

I believe I have a working script that can open the ports to the USB device using 127.0.0.1 as the IP address & the correct ports needed using the following URL as an example.

Can anyone help me format the commands to properly talk to the device?  

Many thanks!

Pre - Authorize
>> {"jsonrpc": "2.0", "method": "PreAuthorize", "params": {"amount": 1.50, "currencyCode": 840, "timeout": 60}, "id": 123} << {"jsonrpc": "2.0", "result": true, "id": 123}

Get Version
>> {"jsonrpc": "2.0", "method": "GetVersion", "params": {"component ": "Reader"}, "id": 127} << {"jsonrpc": "2.0", "result": "040506", "id": 127}

 

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

  • Moderators
Posted (edited)

First Off, moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

  Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Expand  

 

Secondly, the thread you link to has a suggestion to read the help file on TCPSend, and try out the examples. Have you done this? Please treat the forum like math class and show your work :)

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

I think you are trolling me :) LOL.  And yes, the example script does work but it's a simple script to test the commands.  What I am more interested in is if anyone has more experience using Autoit to manage a PLC and what is involved.   I could show you the mappings of all the databanks and such on the PLC itself if you want Math... :)

I'm not sure how to properly read / write to the databanks on the PLC using autoit and I don't want to smoke the PLC with the wrong commands.  It's like doing brain surgery with a manual and no experience.  Not recommended...

 

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Posted

Ok, so per the docs,  the CC machine uses port 10000 to send data to it & 10001 to receive data from it.

 

Is there anything odd about my approach?  Mind you, I used the example help file script and modified it to test it.  It appears that I can send the command ok as I don't receive an error but I can't seem to listen for the response....

 

Func MyTCP_Client($sIPAddress, $iPort)
    ; Assign a Local variable the socket and connect to a listening socket with the IP Address and Port specified.
    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    Local $iError = 0

    ; If an error occurred display the error code and return False.
    If @error Then
        ; The server is probably offline/port is not opened on the server.
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)
        Return False
    EndIf

    ;Get Version
    $x='{"jsonrpc": "2.0", "method": "GetVersion", "params": {"component": "Reader"}, "id": 127}'
    TCPSend($iSocket, $x)

    ; If an error occurred display the error code and return False.
    If @error Then
        $iError = @error
        MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not send the data, Error code: " & iError)
        Return False
    Else
        msgbox(0,"","No Error found.  Listening for response")

        Local $iListenSocket = 10001
        Do ; Wait for someone to connect (Unlimited).
            ; Accept incomming connections if present (Socket to close when finished; one socket per client).
            $iSocket = TCPAccept($iListenSocket)

            ; If an error occurred display the error code and return False.
            If @error Then
                $iError = @error
                MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Could not accept the incoming connection, Error code: " & $iError)
                Return False
            EndIf
        Until $iSocket <> -1 ;if different from -1 a client is connected.

        msgbox(0,"","Listening for data is complete")

        ; Close the Listening socket to allow afterward binds.
        TCPCloseSocket($iListenSocket)
    EndIf

    ; Close the socket.
    TCPCloseSocket($iSocket)
EndFunc   ;==>MyTCP_Client

Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...