Menu

s" and string

2025-08-13
2025-08-16
  • Jan Kromhout

    Jan Kromhout - 2025-08-13

    I wont to send an AT command to the UART. The command layout is:
    AT+CWJAP="username",,"password" , AT needs the apostrophe around the username and password!!

    Is ther a posibility to writeout this in s" xxxxxx"xxxx","xxxxxxx" so there is an adres and length on the stack
    and the string adres contains the ".

    Thanks for any help.
    Cheers
    Jan.

     
  • Pere font vilanova

    to solve this i created the word S':

        :  S'
      [CHAR] '     \ ( -- char ) obtiene el separador "
      PARSE         \ ( char -- c-addr u ) parsea hasta la siguiente     
      comilla
       >R            \ ( c-addr u -- c-addr ) guarda u en return-stack
       POSTPONE LITERAL  \ compila LITERAL que insertará c-addr
       R>            \ recupera u
       POSTPONE LITERAL  \ compila LITERAL que insertará u
    ; IMMEDIATE
    

    then you can use:
    : test S' AT + CWJAP="SSID","pasword" ';

     

    Last edit: Pere font vilanova 2025-08-14
    • Mikael Nordman

      Mikael Nordman - 2025-08-16

      Hi Pere, that does not work. You are storing in flash an adress pointing to data in the terminal input buffer, which is replaced by interpreting the next line.
      You would need to also copy the string to flash and some other stuff.

      I'll come back with a solution.

       
  • Jan Kromhout

    Jan Kromhout - 2025-08-14

    Thanks for your great help. I t is working perfect.
    Cheers,
    Jan

     
  • Jan Kromhout

    Jan Kromhout - 2025-08-15

    Today I have implemented the code you provide.
    To test the code I use :

    : test cr 
    s' AT+CWJAP="RCN 119","xxxxxxx" ' type ; 
    

    This is the answer of my test.

    test
    tT+CWJAP="RCN 119","xxxxxxx" ok

    Sommething is goinig wromg with the the first char, or I do sommething wrong?

    This is the code for s'

    :  s'
      [char] '              \ ( -- char ) krijg de scheidingsteken "
      parse                 \ ( char -- c-addr u ) parsen naar het volgende citaat
       >r                   \ ( c-addr u -- c-addr )save u
       postpone literal     \ compileer LITERAL die c-addr zal invoegen
       r>                   \ restore 
       postpone literal     \ compile LITERAL die zal wordern ingevoegd
    ; immediate
    
     
  • Pere font vilanova

    i tested again and it runs on my scamp3. i don't understand what happen. see picfure attached.

     
  • Pere font vilanova

    the word only works in compile mode......

     
  • Jan Kromhout

    Jan Kromhout - 2025-08-15

    I have a very strange behavior.

    This is my code :

    : getTime ( -- )
        emptybuf 
        s" AT" sendcommand  100 ms
        s" ATE0" sendcommand  100 ms
        rx1>            \ dump buffer
        emptybuf        \ clear buffer
        s" AT+CWMODE=1" sendcommand  200 ms
        rx1>            \ dump buffer
        emptybuf        \ clear buffer
        s' aaaa=“xxxx”,“yyyyy” ' sendcommand 4000 ms
        rx1>            \ dump buffer
        emptybuf        \ clear buffer
    ;
    

    and this is after compiling:

    : getTime ( -- ) 
        emptybuf  
        s" AT" sendcommand  100 ms 
        s" ATE0" sendcommand  100 ms 
        rx1>            \ dump buffer 
        emptybuf        \ clear buffer 
        s" AT+CWMODE=1" sendcommand  200 ms 
        rx1>            \ dump buffer 
        emptybuf        \ clear buffer 
        s' aaaa=“xxxx”,“yyyyy” ' sendcommand 4000 ms 
        rx1>            \ dump buffer 
        emptybuf        \ clear buffer 
    ; 
    

    After compiling is taken from my screen, I use scamp3 and as monitor program Coolterm on Macbook.
    Any idee wy this strange characters apears in the code at compiling?

     
    • Mikael Nordman

      Mikael Nordman - 2025-08-16

      Peres code was not working.
      This is the right way. It works in both interpret and compile mode.
      In interpret mode you have to use the string on the same line, the next input line will overwrite it.

      : s'
        [char] ' parse
        state if
          postpone (s")
          flash here over 1+ allot place align ram
        then
      ; immediate
      
       
  • Pere font vilanova

    Mikael i will try your code, seems good to use in both modes . but to use in compile mode, i'm using my code time ago without any problem. i have used a lot to write LORA modules with AT commands. see the picture in the comment above.
    regarding Jan problem i think is a serial terminal problem o a text editor problem. Ihad similar problems in windows and scamp using the words key, accept and key? or with strange characters in screen. I changed the serial monitor to teraterm an the text editor to notepad and all the problems were solved.....

     

    Last edit: Pere font vilanova 2025-08-16
  • Pere font vilanova

    Jan if you are trying to use the esp-01 with the scamp to send and receive data, you can check the 3 posts i wrote in the udamonic webpage. i connected the scamp to pc and also one scamp to another scamp using the esp01 as wifi module as plug and play modules using the transparent mode ( serial bridge). in this way you dont need to send AT commands fromscamp, you only send data to uart 1.
    make a sight.

     
  • Jan Kromhout

    Jan Kromhout - 2025-08-16

    Pere, I have seen the articles on the facebook page of John. But I think our goals are different, I only need to make contact with the esp01 to make a connectopn to a time server, and to my electricity monitor system. The basics are working only strugling with connecting WiFi. What I go to try is testing the code with Windows using teleterm ed. We have also seen some trouble with the terminal program in the Mac envoirment. I will youse Paralles Let you know my findings today.
    B.t.w. is your code you discribe in your post public?

    Cheer,
    Jan

     
  • Pere font vilanova

    yes of course. you can use freely the code i explain, change it and do anything you need to improve it. also you can use it to use the putty as a terminal. it is faster than the other serial terminals i have.

     

    Last edit: Pere font vilanova 2025-08-16
  • Jan Kromhout

    Jan Kromhout - 2025-08-16

    Is there a special config for using teraterm under windows to work with the scamp. I have no experiance with teraterm.

     
  • Pere font vilanova

    I only adjust in the terminal option, the receiving characters as auto and the semding as cr+ lf.
    i choose the option serial, and the port comX where the scamp is at 115200 bauds.
    the rest dont touch.
    please use better the code from Mikael, it works very well. my code has a bug. see below explanation.

     
  • Pere font vilanova

    hi Mikel, you are rigth! my code is working only if you use it immediately after the definition , ( as i usually do). but if you use it in several definitions, then only the last string is printed or sent, or we have en error message. thank you for your information. i will change it in my tools marker.
    i didn't think that the s" strings are only temporal.

     
  • Jan Kromhout

    Jan Kromhout - 2025-08-16

    Thanks both for your helfull help. My code works fine with the code of Mikael. The garbage in my comilation lies in the ", sommetimes I get another character for the " and the compiler has some problems with that.

    Cheers
    Jan

     
  • Pere font vilanova

    in teraterm, is useful to avoid problems with garbage characters to put a delay of 2 ms for haracter and 10 or 100 ms(try) for line. i think in the terminal or port option.

     

Log in to post a comment.