logo elektroda
logo elektroda
X
logo elektroda

WEB server, ESP8266, Lua and transferring ASCII characters from the keyboard to the UART

cze333 1086 12
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17058977
    cze333
    Level 8  
    As in the title, I'm attaching a photo of the server screen and the code which should implement the function of transferring ASCII characters from the keyboard to the UART but there is an error which I can't determine.
    The function of passing characters typed from the keyboard to the 'mycode' variable does not work.
    Lines of code where I think the error is supposed to be:

    Code: Lua
    Log in, to see the code
    .
    Perhaps a different method should be used?
    As you can see in the photo, the program generates a window and you can type characters into it. However after clicking '<--INPUT' the entered characters disappear from the window, nothing happens and the variable 'mycode' remains empty, it has the value 'nil'.
    To handle the programming of the board I used Flasher and ESPlorer as described:
    https://nodemcu.readthedocs.io/en/master/en/flash/#sdk-init-data

    There is a question and request to programmers who understand ESP8266 and LUA programming to look into this.
    All the code:

    Code: Lua
    Log in, to see the code
    .




    [img]WEB server, ESP8266, Lua and transferring ASCII characters from the keyboard to the UART .
  • ADVERTISEMENT
  • #2 17059560
    JacekCz
    Level 42  
    You already have a lack of precision in the story itself.
    "A string of characters from a keyboard" implies a failure to encapsulate them into higher order groups, packets, transactions, etc.... Web does just that.
    Any minute now in this concept you will stand over the problem of timing, packetisation, threads, concurrency etc....
    The *) web server is one of the worse ideas to send character by character from the keyboard to the UART.

    *) and certainly the kind of server you understand on the uK. I could manage something like this in 90%, sorry maybe 80% realised on Apache Tomcat and Java EE, a sophisticated application with AJAX etc....
  • #3 17059663
    cze333
    Level 8  
    JacekCz wrote:
    keyboard string"
    You enter a few characters from the keyboard into the box to the left of the 'INPUT' button (look at the attached photo) and then click on the 'INPUT' button and this typed sequence of characters is supposed to be transferred to the 'mycode' variable. But it is not transferred. This is the problem. The rest of the program function executes correctly. I don't know how to describe this more clearly?
  • #4 17059681
    JacekCz
    Level 42  
    cze333 wrote:
    JacekCz wrote:
    keyboard string"
    You enter a few characters from the keyboard into the box to the left of the 'INPUT' button (look at the attached photo) and then click on the 'INPUT' button and this typed sequence of characters is supposed to be sent to the 'mycode' variable . But it is not sent. This is the problem. The rest of the program function executes correctly. I don't know how to describe this more clearly?
    .

    You can and, in my opinion, need to be clearer. Programming is the domain of accuracy.
    E.g. "string entered into the window" (including not keyboard but e.g. pasted)

    The keyboard does not get blown up (although there has been such a case in the Middle East) and continues to generate characters.
  • ADVERTISEMENT
  • #5 17063883
    cze333
    Level 8  
    JacekCz wrote:
    The keyboard does not blow up
    .
    The code has been updated. Note the lines with the code to send the characters contained in the 'mycode' variable to the UART.

    'if klik=="SENDtoUART" and mycode~=nil then uart.write(0, "zp"..mycode.."$") return end--send to UART string'

    The problem is the same, despite performing the operation to enter these characters with the appropriate clicks on the buttons in the browser i.e. '<--INPUT' and 'SENDtoUART' the contents of the 'mycode' variable remains empty. If you feel like it, please have a look at the attached code.
    I can send you the WEB address of my ESP board, so you can open the page in a browser, click on the buttons and check the messages in the browser console.
  • #6 17065009
    JacekCz
    Level 42  
    On a point of order
    Code: HTML, XML
    Log in, to see the code
    .
    this is a comment, albeit an incomplete one. What do you expect from it?

    The rest is a chaffing of several languages (HTML/JS/Lua) , in several environments (client / server), which to my eyes is a haphazard and incomplete pasting. I don't see it coming together in a coherent way.

    As far as I understand (i.e. I understand "chaff") revert this project to simply sending one POST operation, without any JS, and dotest.
  • ADVERTISEMENT
  • #7 17065065
    cze333
    Level 8  
    JacekCz wrote:
    What do you expect from it?
    .
    It seems to me you did not read the post above with understanding. This code works and performs functions except for this one. There are comments posted that describe the various elements of the code. If I knew how to debug the attached code, or knew how to rewrite it correctly with other methods, I wouldn't bother anyone here. I think this is a matter of course. If I have taken up your valuable time then I am sorry.
    PS
    I have been struggling with this for weeks. I've been trying unsuccessfully to find an example on the web of working (because I haven't found it working) code on the ESP8266 that would implement (in a server set up ESP8266) the function of entering a string of characters typed from the keyboard into a variable, which variable could then be used in other functions of the program. This is what I would like to see.
    Perhaps someone has come across such an example?
  • #8 17065223
    JacekCz
    Level 42  
    cze333 wrote:
    I've been struggling with this for weeks. I've been trying, without success, to find a code example on the web for the ESP8266 that would implement (in a server set up ESP8266) the function of entering a string of characters typed from the keyboard into a variable, which this variable could then be used in other functions of the program.
    Perhaps someone has come across such an example?
    .

    Is there an example of a web server entering the name and first name of a favourite actor?

    Break the problem down into such parts / functionality as it actually is. Server part one (thousands of examples), client part two, i.e. starting with a simple HTML form (millions of examples). This is linked by HTTP POST (millions of examples).

    I can't put it any clearer than that. It's a primer. You are stubbornly stuck with the wrong description of the issue (with this keyboard), it's hard to find examples too.
  • ADVERTISEMENT
  • #9 17065252
    cze333
    Level 8  
    JacekCz wrote:
    Is there an example of a web server entering the name and first name of a favourite actor?
    Why the philosophising and fraying of the keyboard? I offered to email you a link to my ESP board, it is still attached so you can remotely open it in your browser, click on it and see how it works. Also, you have the code above with comments. Unfortunately you have to make an effort and take your time. Do you want to or not?
  • #10 17065464
    krzysiek_krm
    Level 40  
    Hello,
    I'm shooting a bit blind because I'm not generally familiar with this language.
    Maybe you should look for a working example that offers a login facility (user, password). Someone probably must have already created something like this.

    Greetings
  • #11 17065484
    xury
    Automation specialist
    Maybe look for an example of how to make a telnet server on the ESP8266. That might explain a lot.
  • #12 17065750
    JacekCz
    Level 42  
    xury wrote:
    Maybe look for an example of how to make a telnet server on the ESP8266. It might explain a lot.


    Telnet is a fresh (in a positive sense) look at the subject.

    Question for @cze333 whether, for what reasons and to what extent a webserver needs to be present in this - or is this just the idea found "because they showed it on YT".
  • #13 17066436
    cze333
    Level 8  
    xury wrote:
    Maybe look for an example of how to make a telnet server on the ESP8266. That might explain a lot.
    .
    Please enlighten me as to what a telnet server has to do here?
    What is it supposed to explain?
    JacekCz wrote:
    "because on YT they were showing".

    Do you get paid here on the forum for trolling?

Topic summary

The discussion centers on implementing a web server on an ESP8266 module using Lua to transfer ASCII characters typed in a browser input field to the UART interface. The main issue is that the JavaScript function intended to capture the input field value and assign it to a variable ('mycode') does not work as expected, resulting in an empty variable when attempting to send data to UART. The code snippet includes HTML form elements and JavaScript embedded in Lua server responses, but the client-side input is not properly captured or transmitted back to the server. Suggestions highlight the complexity of sending character-by-character data over a simple web server, recommending breaking down the problem into standard HTTP POST form submissions without JavaScript for reliability. Alternative approaches such as using a telnet server on the ESP8266 are mentioned for direct UART interaction. The discussion emphasizes the need for clear separation of client-server roles, proper HTTP request handling, and possibly simpler, proven examples of web form data submission to Lua on ESP8266 for UART transmission.
Summary generated by the language model.
ADVERTISEMENT