Search code examples
restweb-servicesbasicplc

Can we call a web Service/REST API from BASIC(Beginner's All-purpose Symbolic Instruction Code) programming language


I've nano 10 PLC which records some data in its memory i need that data on my web application we can program the PLC with "Ladder + BASIC" language that can easily handle sophisticated tasks with just a few lines of codes now my requirement is get PLC recorded data to my web application through Web Service or REST API call is it possible to call api if so how to proceed with it


Solution

  • You just have to use TCPCONNECT to establish the connection.

    PRINT #4 "<TCPCONNECT 192.168.0.51:3000>"

    Use STATUS(3) to check if the connection has been established or not.

    IF STATUS(3)
        SETLCD 1,1,"Connected"
    ELSE
        SETLCD 1,1,"NOT Connected"
        GOTO 100
    ENDIF
    

    Then send the request

    PRINT #4 "GET /hello.htm HTTP/1.1"
    PRINT #4 ""   ' this is important
    

    You have to follow the HTTP protocol format. For other methods, refer https://www.jmarshall.com/easy/http/#othermethods